Wednesday, June 15, 2016

Ant's optional JARs and Maven

Maven is a convenient tool for building and maintaining large multi-module projects. At times it can be tricky to fix a large project that comes with various plugins though. I was trying to incorporate some ant scripts into Maven with 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.

Now, 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 in 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.

No comments:

Post a Comment

You are welcome to provide your opinions in the comments. Spam comments and comments with random links will be deleted.