17

私の Maven Java プロジェクトは、maven-antrun-plugin を使用して、私のアプリをデプロイする deploy.xml ant スクリプトを実行します。deploy.xml は<if>タスクを使用しており、これが問題を引き起こしているようです。

[INFO] タスクを実行
中 [taskdef] リソース net/sf/antcontrib/antlib.xml から定義を読み込めませんでした。見つかりませんでした。

デプロイ:
[情報] ---------------------------------------------- ---------------------------
[エラー] ビルド エラー
[情報] --------------- -------------------------------------------------- -------
[情報] Ant BuildException が発生しました: この行の実行中に次のエラーが発生しました:
E:\My_Workspace\xxxxxx\xxxxxx\xxxxxxx\deploy.xml:24: 問題: タスクまたはタイプの作成に失敗しました原因: 名前が
定義されていません。
処置: スペルを確認してください。
処置: カスタム・タスク/タイプが宣言されていることを確認してください。
処置: <presetdef>/<macrodef>宣言が行われたことを確認してください。

これが私のpomからのantrunプラグイン構成です。

<plugin>
    <inherited>false</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <id>remote-deploy</id>
            <phase>install</phase>
            <configuration>
                <tasks>
                    <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>

                        <property name="compile_classpath" refid="maven.compile.classpath" />
                        <property name="runtime_classpath" refid="maven.runtime.classpath" />
                        <property name="plugin_classpath" refid="maven.plugin.classpath" />
                                
                        <echo message="compile classpath: ${compile_classpath}"/>
                        <echo message="runtime classpath: ${runtime_classpath}"/>
                        <echo message="plugin classpath: ${plugin_classpath}"/>

                        <ant antfile="${basedir}/deploy.xml">
                            <target name="deploy" />
                        </ant>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>ant-contrib</artifactId>
            <version>1.0b3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.7.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-jsch</artifactId>
            <version>1.7.1</version>
        </dependency>
    </dependencies>
</plugin>

.. これが私の deploy.xml の関連セクションです。

<target name="deploy" if="deploy">
    <if>    <!-- line 24 -->
        <and>

なぜ私は自分のmavenレポを見ることant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jarができ、瓶の中を見るとnet/sf/antcontrib/antcontrib.properties問題がないことがわかります。

の値を確認すると、maven.compile.classpathへの参照が表示されません。これが問題でしょうか? が依存関係として定義されている場合に表示されないのはなぜですか?maven.compile.classpathmaven.compile.classpathantcontribantcontrib

4

4 に答える 4

29

Mavenプラグインを実行するためにクラスパスをコンパイルするためにantを追加するのはあまり良い考えではないと思います。

私はMaven 3.0.4を使用しており、ant-contribタグの名前空間を指定することで機能しました。次に例を示します。

<configuration>
  <target>
    <echo message="The first five letters of the alphabet are:"/>
    <ac:for list="a,b,c,d,e" param="letter" xmlns:ac="antlib:net.sf.antcontrib">
      <sequential>
        <echo>Letter @{letter}</echo>
      </sequential>
    </ac:for>
  </target>
</configuration>

私のmaven-antrun-plugin依存関係:

<dependencies>
  <dependency>
    <groupId>ant-contrib</groupId>
    <artifactId>ant-contrib</artifactId>
    <version>1.0b3</version>
    <exclusions>
      <exclusion>
        <groupId>ant</groupId>
        <artifactId>ant</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>org.apache.ant</groupId>
    <artifactId>ant-nodeps</artifactId>
    <version>1.8.1</version>
  </dependency>
</dependencies>
于 2012-12-04T10:56:08.070 に答える
3

わかりました、解決しました。

<build><plugin>依存関係をタグから移動し、他のプロジェクトの依存関係と一緒に配置すると、うまくいったようです。

于 2011-01-18T13:22:22.617 に答える