Discussion:
[m2] The packaging for this project did not assign a file to the build artifact
Adrian Herscu
2006-03-04 14:59:20 UTC
Permalink
Hi all,

I have followed the
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
to add custom packaging and artifact handler to my plugin.

In the ArtifactHandler configuration section I have defined:
<extension>war</extension>
<type>my-type</type>
<packaging>war</packaging>
<language>my-language</language>
<addedToClasspath>false</addedToClasspath>

When binding my WAR mojo to the build lifecycle, i.e.

<package>com.acme:my-plugin:war</package>

then I get a build error with the following description:
"The packaging for this project did not assign a file to the build
artifact".

I tried to see what happens if I bind the Maven JAR mojo, i.e.
<package>org.apache.maven.plugins:maven-jar-plugin:jar</package>

and changed the ArtifactHandler configuration section to:

<extension>jar</extension>
<type>my-type</type>
<packaging>jar</packaging>
<language>my-language</language>
<addedToClasspath>false</addedToClasspath>


then I get a successful build but the extension type of the installed
artifact is not ".jar" but ".my-type". Why?!


Please help I am stuck!

In the lifecycle guide there is a line of Java code
[project.getArtifact().setFile( new File( "target/myFile-2.0.jar" ) );]
which must be executed by the packaging goal. I have built my mojos in
ANT -- how do I accomplish this with ANT code? (I tried the ANT's
<property name="project.artifact.file" value="my.war" /> but did not work)

...and TIA.
Adrian.
Adrian Herscu
2006-03-05 22:39:49 UTC
Permalink
SOLVED
-------
I made one mistake in the components.xml -- the packaging element should
match the role-hint element.
The ANT script task (apparently) must be used to access Maven's object
model -- I have used the following code in my.build.xml file:

<script language="beanshell"><![CDATA[
mavenProject.getArtifact().setFile( new java.io.File( myWarPath ) );
]]></script>

This of course requires maven-script-beanshell, bsf and ant-apache-bsf
dependencies.
Is there a more elegant way?
E.g. using only clean ANT syntax?

Adrian.
Post by Adrian Herscu
Hi all,
I have followed the
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
to add custom packaging and artifact handler to my plugin.
<extension>war</extension>
<type>my-type</type>
<packaging>war</packaging>
<language>my-language</language>
<addedToClasspath>false</addedToClasspath>
When binding my WAR mojo to the build lifecycle, i.e.
<package>com.acme:my-plugin:war</package>
"The packaging for this project did not assign a file to the build
artifact".
I tried to see what happens if I bind the Maven JAR mojo, i.e.
<package>org.apache.maven.plugins:maven-jar-plugin:jar</package>
<extension>jar</extension>
<type>my-type</type>
<packaging>jar</packaging>
<language>my-language</language>
<addedToClasspath>false</addedToClasspath>
then I get a successful build but the extension type of the installed
artifact is not ".jar" but ".my-type". Why?!
Please help I am stuck!
In the lifecycle guide there is a line of Java code
[project.getArtifact().setFile( new File( "target/myFile-2.0.jar" ) );]
which must be executed by the packaging goal. I have built my mojos in
ANT -- how do I accomplish this with ANT code? (I tried the ANT's
<property name="project.artifact.file" value="my.war" /> but did not work)
...and TIA.
Adrian.
Loading...