Technical Notes

My online notepad

How to attach Maven artifact from external build.xml file

Posted by Anton Khitrenovich on December 16, 2013

As you probably know, maven-antrun-plugin provides a custom AttachArtifact task that is able to attach artifacts generated by Ant to the current Maven project. The usage is really straightforward with inline Ant targets, but an attempt to use this task with external build.xml results in an error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (...) on project ...: 
  An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] C:\...\build.xml:158: Maven project reference not found: maven.project

[ The solution described here does not really work. See update at the bottom. ]

The solution is simple – external Ant invocation should inherit references from the inline target:

					<ant antfile="build.xml" target="..." inheritRefs="true" />

Update: It appears that this change eliminates the error, but the artifact is not actually attached. I’ve opened a bug report to the Maven Antrun Plugin team about that.

Leave a Comment

Your email address will not be published. Required fields are marked *