2011-01-21 15 views
7

mavenビルド内で "if" antタスクを使用しようとしています。maven3 - maven-antrun-plugin - "タスクの作成に失敗した場合、またはタイプした場合"

"ant-nodeps"依存関係の使用を提案する記事が多数見つかりました。結局、このトリックはすべてmaven3 + ant 1.8.1 + maven-antrun-plugin 1.6では動作しませんでした。

「アンアリと、BuildExceptionが発生しました::問題は場合タスクまたはタイプの作成に失敗しました」何を助けることができますか?

は、ここで(むしろ、それは必要ではないが、念のため)実際のコードです:

<profiles> 
    <profile> 
     <id>smtpConfigurationProfile</id> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-antrun-plugin</artifactId> 
        <version>1.6</version> 
        <executions> 
         <execution> 
          <phase>validate</phase> 
          <goals> 
           <goal>run</goal> 
          </goals> 
          <configuration> 
           <tasks> 
            <if> 
             <isset property="${smtpFile}"/> 
             <then> 
              <delete file="${project.build.outputDirectory}/smtp.properties"/> 
              <copy file="${smtpFile}" 
                tofile="${project.build.outputDirectory}/smtp.properties"/> 
             </then> 
             <elseif> 
              <isset property="${smtpProfile}"/> 
              <then> 
               <delete file="${project.build.outputDirectory}/smtp.properties"/> 
               <copy file="src/main/resources/${smtpProfile}.smtp.properties" 
                 tofile="${project.build.outputDirectory}/smtp.properties"/> 
              </then> 
              <else> 
               <delete file="${project.build.outputDirectory}/smtp.properties"/> 
               <copy file="src/main/resources/production.smtp.properties" 
                 tofile="${project.build.outputDirectory}/smtp.properties"/> 
              </else> 
             </elseif> 
            </if> 
           </tasks> 
          </configuration> 
         </execution> 
        </executions> 
        <dependencies> 
         <dependency> 
          <groupId>org.apache.ant</groupId> 
          <artifactId>ant-nodeps</artifactId> 
          <version>1.8.1</version> 
         </dependency> 
        </dependencies> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
</profiles> 

答えて

17

1)対象区間内のAntタスクの前に次の行を追加します。

<taskdef resource="net/sf/antcontrib/antlib.xml" 
classpathref="maven.plugin.classpath" /> 

2)プラグインに正確次の依存関係を追加します。

     <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

[taskdef]リソースnet/sf/antcontrib/antlib.xmlから定義をロードできませんでした。それは見つけることができませんでした。 –

1

私は同じ問題を抱えていた私の質問hereを参照してください。

私はant-contrib依存関係をプラグインからプロジェクトに移動して解決しました。

+0

は、Qwerkyをありがとう!私はtaskdefsとは異なる問題を発見しました。 –

関連する問題