具有顺序 ant-contrib 的 Maven antrun 无法运行 [英] Maven antrun with sequential ant-contrib fails to run

查看:36
本文介绍了具有顺序 ant-contrib 的 Maven antrun 无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个特殊的例程来将子文件夹中的文件分解为扩展名,这些扩展名将被复制并压缩成单个扩展名文件.对于这种特殊的方法,我想使用 maven-antrun-plugin,对于通过 dirset 进行顺序迭代和 jar 打包,我们需要库 ant-contrib.

We have a special routine to explode files in a subfolder into extensions, which will be copied and jared into single extension files. For this special approach I wanted to use the maven-antrun-plugin, for the sequential iteration and jar packaging through the dirset, we need the library ant-contrib.

即将到来的插件配置失败并出现错误.我配置错误是什么?谢谢.

The upcoming plugin configuration fails with an error. What did I misconfigured? Thank you.

插件配置

<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

推荐答案

您似乎缺少 声明 ant-contrib 任务 所需的noreferrer">taskdef,以便 Ant知道他们,因此这部分错误消息:

It looks like you're missing the taskdef that's needed to declare the ant-contrib tasks, so that Ant knows about them, hence this part of the error message:

Problem: failed to create task or type for

(如果引用失败的任务 - 'for' - 可能会更清楚一些.)

(It would perhaps be a little clearer if the failed task - 'for' - were quoted.)

添加 taskdef 的一种方法是在 for 循环之前立即插入它:

One way to add the taskdef is to insert it immediately prior to the for loop:

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

这篇关于具有顺序 ant-contrib 的 Maven antrun 无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆