シーケンシャルアントコントリブを備えたメイブンアントランは実行できません

StackOverflow https://stackoverflow.com/questions/4368243

質問

サブフォルダー内のファイルをエクステンションに爆発させる特別なルーチンがあり、コピーされてJaredが単一の拡張機能ファイルになります。この特別なアプローチのために、私はそれを使いたいと思っていました maven-antrun-plugin, 、シーケンシャルイテレーションとディルセットを介したJARパッケージには、ライブラリアリコントリブが必要です。

今後のプラグイン構成はエラーで失敗します。私は何を誤解しましたか?ありがとうございました。

プラグイン構成

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

エラー

[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
役に立ちましたか?

解決

あなたが欠けているように見えます taskdef それは必要です Ant-Contribタスクを宣言します, 、アリがそれらについて知っているので、エラーメッセージのこの部分は次のとおりです。

Problem: failed to create task or type for

(失敗したタスクがあれば、おそらく少し明確なでしょう - 'for' - 引用された。)

taskDefを追加する1つの方法は、直前にすぐに挿入することです for ループ:

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

他のヒント

したがって、私は少なくとも1時間も無駄にして、以下のエラーを見つけるために...

上記のようにmaven3と残りを使用しますが、使用する必要があります maven.dependency.classpathそれ以外の maven.plugin.classpath!それ以外の場合は、Mavenはコントリブタスクを見つけることができません。これが誰にでも役立つことを願っています。

2時間無駄にして答えを読んだ後、これは私がチェックする必要があるものです

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

これを使用してすべてのMaven ClassPathsを印刷しました

<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}"/>

また、どのClassPathに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>

私もこれで数時間無駄にしました。 for タスクは見つかりませんでした。

最後に、私はそれを見つけました for で定義されていないタスク antcontrib.properties, 、しかしで antlib.xml!

antcontrib.properties 事前の1.6のことをする方法です - 現代の方法は使用することです antlib.xml.

だから、これはaです Maven 3.5, アリ1.8, 、作業例:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <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>
    </dependencies>

    <execution>
        <id>deploy_to_distrib_folder</id>
        <phase>package</phase>
        <configuration>

            <target>
                <taskdef resource="net/sf/antcontrib/antlib.xml" />

                <macrodef name="deploy_extra_dir">
                    <attribute name="dir" />
                    <sequential>
                        <basename property="basename" file="@{dir}" />
                        <sync todir="${outputDir}/${basename}">
                            <fileset dir="@{dir}" />
                        </sync>
                        <var name="basename" unset="true" />
                    </sequential>
                </macrodef>

                <for param="dir">
                    <path>
                        <dirset dir="${project.build.directory}/maven-shared-archive-resources" includes="*" />
                    </path>
                    <sequential>
                        <deploy_extra_dir dir="@{dir}" />
                    </sequential>
                </for>

            </target>
        </configuration>
        <goals>
            <goal>run</goal>
        </goals>
    </execution>
</plugin>

お役に立てれば!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top