蚂蚁的可选罐子和马文


Maven是构建和维护大型多模块项目的便捷工具。不过,有时修复带有各种插件的大型项目可能会很棘手。我试图使用maven-antrun-plugin将一些Ant脚本合并到Maven中,但遇到了以下错误。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (compile-dist) on project distribution: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /home/pradeeban/bindaas/build.xml:149: Problem: failed to create task or type propertyfile
[ERROR] Cause: the class org.apache.tools.ant.taskdefs.optional.PropertyFile was not found.
[ERROR] This looks like one of Ant's optional components.
[ERROR] Action: Check that the appropriate optional JAR exists in
[ERROR] -ANT_HOME/lib
[ERROR] -the IDE Ant configuration dialogs
[ERROR]
[ERROR] Do not panic, this is a common problem.
[ERROR] The commonest cause is a missing JAR.
[ERROR]
[ERROR] This is not a bug; it is a configuration problem
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn -rf :distribution

根据我从互联网上找到的信息,我下载并移动了:

  • ant-contrib-1.0b3.jar

  • ant-nodeps-1.8.1.jar

添加到ant-home/lib目录,以修复此问题。

然后我得到以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (compile-dist) on project distribution: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /home/pradeeban/bindaas/build.xml:149: Problem: failed to create task or type propertyfile
[ERROR] Cause: Could not load a dependent class org/apache/tools/ant/util/LayoutPreservingProperties
[ERROR] It is not enough to have Ant's optional JARs
[ERROR] you need the JAR files that the optional tasks depend upon.
[ERROR] Ant's optional task dependencies are listed in the manual.
[ERROR] Action: Determine what extra JAR files are needed, and place them in one of:
[ERROR] -ANT_HOME/lib
[ERROR] -the IDE Ant configuration dialogs
[ERROR]
[ERROR] Do not panic, this is a common problem.
[ERROR] The commonest cause is a missing JAR.
[ERROR]
[ERROR] This is not a bug; it is a configuration problem
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn -rf :distribution

经过几分钟的思考,并确保我的Maven和Ant是最新版本(到目前为止),我意识到这一定与maven-antrun-plugin的版本有关。我是对的!

如果您遇到此问题,请检查插件的版本,如果没有定义插件(或定义为较早版本),请将其定义为最新版本。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.8</version>
</plugin>

该问题已成功修复。