2011-01-18 3 views
15

私のmaven-javaプラグインはmaven-antrun-pluginを使用して、私のアプリケーションをデプロイするdeploy.xml antスクリプトを実行します。 deploy.xmlは<if>タスクを使用していますが、これは問題を引き起こしているようです。antcontribの使用<if>タスクからmaven-antrun-plugin

[INFO]実行タスク
[のtaskdef]リソースネット/ SF/antcontrib/antlib.xmlから定義をロードできませんでした。それは見つけることができませんでした。

展開:
[INFO] --------------------------------------- ---------------------------------
[エラー] BUILD ERROR
[情報] ----- -------------------------------------------------- -----------------
[INFO] Antビルドエラーが発生しました:この行の実行中に次のエラーが発生しました:
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> 

は、なぜ私はant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jarを見ることができ、私のMavenのレポで見て、私は瓶の中を見たとき、私はそう問題はないがnet/sf/antcontrib/antcontrib.propertiesを見ることができます。私はantcontribへの参照を見ることができないmaven.compile.classpathmaven.compile.classpathmaven.compile.classpathの値を確認する場合

、これが問題になるだろうか?なぜ彼らはantcontribが依存として定義されているときに表示されませんか?

+0

https://stackoverflow.com/questions/4368243/maven-antrun-with-sequential-ant-contrib-fails-to-run/45958355#45958355 –

答えて

3

いいえ、私はそれを解決しました。

<build><plugin>タグから依存関係を移動し、他のプロジェクト依存関係に入れているように見せかけたようです。

+1

別の答えで説明したように、antの依存関係を含めることはお勧めできませんMavenプラグインを実行するためにクラスパスをコンパイルしてください。 –

+0

奇妙なことに、私はダウンロードするためにこれを行う必要がありました。次に、それをプラグインの依存関係に戻しました。私はちょうどそれがIDEの問題だったと思っています。 – RockMeetHardplace

24

mavenプラグインを実行するために、クラスパスをコンパイルするantを追加することは非常に良い考えではないと思います。

私はMavenの3.0.4を使用して、例えば、アリ - 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 - プラグインの依存関係:

<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> 
+0

それは素晴らしいです、ありがとう! –

+0

私のために働いた唯一のもの! – electrotype

+0

あなたは私の人生を救った! – cthiebaud

0

別の解決策でしょう以下のようになります:ant-contrib-1.0b3を維持します。パスにjarファイル、その後、この

<property name="runningLocation" location="" /> 
<taskdef resource="net/sf/antcontrib/antcontrib.properties"> 
    <classpath> 
     <pathelement location="${runningLocation}/ant-contrib-1.0b3.jar" /> 
    </classpath> 
</taskdef> 

のようにそれを定義

<target name="doSomething"> 
    <if> 
     <equals arg1="${someProp}" arg2="YES" /> 
     <then> 
      <echo message="It is YES" /> 
     </then> 
     <else> 
      <echo message="It is not YES" /> 
     </else> 
    </if> 
</target> 

私はあなたがhttps://www.surasint.com/run-ant-with-if-from-maven/

2

をダウンロードすることができ、ここで完全なコード例を置く私はあなたがant-を含める必要があることを発見プラグイン内のcontrib依存関係によって、taskdefタグがantcontrib.propertiesを見つけることができるようになります。

<plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <dependencies> 
       <dependency> 
        <groupId>ant-contrib</groupId> 
        <artifactId>ant-contrib</artifactId> 
        <version>20020829</version> 
       </dependency> 
      </dependencies> 
      <executions> 
       <execution> 
        <id>copy-and-rename-template-files</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <target name = "copy-and-rename-template-files"> 
          <taskdef resource="net/sf/antcontrib/antcontrib.properties"/> 
          <if> 
           <available file="src/main/resources/docker/templates" type="dir"/> 
           <then> 
            <copy todir="${project.build.directory}/docker"> 
             <fileset dir="src/main/resources/docker/templates"> 
              <include name="**/*"/> 
             </fileset> 
            </copy> 


            <move todir="${project.build.directory}/docker"> 
             <fileset dir="${project.build.directory}/docker"> 
              <include name="*"/> 
             </fileset> 
             <mapper> 
              <regexpmapper from="(.*)project(.*)" to="\1${project.artifactId}\2"/> 
             </mapper> 
            </move> 
           </then> 

           <else> 
            <echo>src/main/resources/docker/templates does not exist, skipping processing docker templates</echo> 
           </else> 
          </if> 
         </target> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
+0

StackOverflowで助けてくれてありがとう、ありがとうございます。しかし、あなたのコードを説明してくれれば、あなたの答えはもっと高く評価されます。 – Yunnosch

+0

問題はありません、私の説明が追加されました。 – Gapmeister66

+0

ありがとう!これはまさに私が探していたものでした! – rcantrel

関連する問題