Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ant's Optional JARs and Maven

DZone's Guide to

Ant's Optional JARs and Maven

Maven error messages always tell you exactly what the problem is, right? Sure.

· Java Zone
Free Resource

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

Maven is a convenient tool for building and maintaining large multi-module projects. At times, though, it can be tricky to fix a large project that comes with various plugins. I was trying to incorporate some Ant scripts into Maven with the maven-antrun-plugin and encountered the below error.

[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

From what I found from the Internet, I downloaded and moved:

  • ant-contrib-1.0b3.jar

  • ant-nodeps-1.8.1.jar

to the ANT-HOME/lib directory in order to fix this.

Then I got the below error:

[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

After a few minutes of thinking, and ensuring that my Maven and Ant are at the latest versions (as of now), I realized this must be something to do with the version of the maven-antrun-plugin. I was right!

If you encounter this issue, check the version of the plugin, and define it to the latest if it is not defined (or if it is defined to an earlier version).

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

The issue was fixed successfully.

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.

Topics:
ant ,maven

Published at DZone with permission of Pradeeban Kathiravelu, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}