2010-12-06 3 views
6

サブフォルダ内のファイルを拡張子に分解して、単一の拡張子ファイルにコピーしてjaredする特別なルーチンがあります。この特別なアプローチでは、maven-antrun-pluginを使用したかったので、逐次反復とdirsetによるjarパッケージ化にはant-contribライブラリが必要です。連続したant-contribを持つMaven antrunの実行に失敗する

今後のプラグインの設定に失敗し、エラーが発生します。私は何を構成しましたか?ありがとうございました。

プラグインの設定

<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> 
     <target> 
      <for param="extension"> 
      <path> 
       <dirset dir="${basedir}/src/main/webapp/WEB-INF/resources/extensions/"> 
       <include name="*" /> 
       </dirset> 
      </path> 

      <sequential> 
       <basename property="extension.name" file="${extension}" /> 
       <echo message="Creating JAR for extension '${extension.name}'." /> 
       <jar destfile="${basedir}/target/extension-${extension.name}-1.0.0.jar"> 
       <zipfileset dir="${extension}" prefix="WEB-INF/resources/extensions/${extension.name}/"> 
        <include name="**/*" /> 
       </zipfileset> 
       </jar> 
      </sequential> 
      </for> 
     </target> 
     </configuration> 
    </execution> 
    </executions> 
    <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> 
</plugin> 

エラーAntはそれらについて知っているので、あなたは、の、したがってこの部分declare the ant-contrib tasksに必要なのtaskdefが欠落しているように見えます

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project extension-platform: An Ant BuildException has occured: Problem: failed to create task or type for 
[ERROR] Cause: The name is undefined. 
[ERROR] Action: Check the spelling. 
[ERROR] Action: Check that any custom tasks/types have been declared. 
[ERROR] Action: Check that any <presetdef>/<macrodef> declarations have taken place. 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

答えて

9

エラーメッセージ:

Problem: failed to create task or type for 

(失敗したタスクならばそれはおそらく少し明確になります - 'for'を - 引用された。)のtaskdefを追加する

一つの方法は、前forループにすぐにそれを挿入することです:

<target> 
    <taskdef resource="net/sf/antcontrib/antlib.xml" 
      classpathref="maven.plugin.classpath" /> 
    <for param="extension"> 
    ... 
+0

が、これは私のために素晴らしい仕事、ありがとうございます。私もこれを試みたが、間違ったクラスパス参照を使用した。 – codevour

10

は、したがって、私は

私はmaven3、上記のように残りの部分を使用しますが、私はmaven.dependency.classpath の代わりmaven.plugin.classpathを使用する必要が...少し下のヒントにエラーを見つけるために、少なくとも1時間を無駄に!そうしないと、mavenはcontribタスクを見つけられません。これが誰にも役立つことを願っています。

0

2時間を無駄にし、あまりにも多くの答えを読んだ後、これは私が

http://www.thinkplexx.com/learn/howto/maven2/plugins/could-not-load-definitions-from-resource-antlib-xml-understanding-the-problem-and-fix-worklow

をチェックするために必要なものである私は、クラスパスに含まれている。この

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

、チェックを使用して、すべてのMavenのクラスパスを印刷しましたantrib jarファイル。だからclasspathhrefmaven.runtime.classpathからmaven.plugin.classpath に変更しました。だから私のtaskdef

<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.runtime.classpath" /> 

で、依存関係

<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> 
関連する問題