Reputation: 7596
I try to configure the maven ant plugin to copy the built artifact to a custom location:
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy verbose="true"
file="target/${project.build.finalName}.${project.packaging}"
tofile="${user.home}/tmp/test/${project.build.finalName}.${project.packaging}"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
This works fine, as long as the packaging is one of the standard ones... but if the packaging of the project is "bundle" (which generates a .jar), then the ${project.packaging} variable is "bundle" and the actual file ends with ".jar" = the copy fails.
How can I get the "real" name of the file that is put into the output directory?
Upvotes: 5
Views: 13854
Reputation: 1694
In ant build.xml using:
${project.build.directory}/${project.artifactId}-${project.version}.jar
Upvotes: 11
Reputation: 14399
One way is to create a property called packaging-suffix
or something similair. In all your projects (or in the super pom if you have one) you can define this property to have the value ${project.packaging}
but in the bundle projects your define the value as jar
. You then reference the property in your antrun plugin congfiguration.
Depending on how your project(s) are set up, this may or may not be a good solution.
I.e:
<properties>
<packaging-suffix>${project.packaging}</packaging-suffix>
</properties>
vs
<properties>
<packaging-suffix>jar</packaging-suffix>
</properties>
then
<copy verbose="true"
file="target/${project.build.finalName}.${packaging-suffix}"
tofile="${user.home}/tmp/test/${project.build.finalName}.${packaging-suffix}"/>
Upvotes: 1
Reputation: 328624
There is no way to do that reliably. For example, a POM can have several artifacts as result (binary JAR, sources JAR, test binary JAR, test sources JAR). Which one of them is the correct one to copy?
Possible solutions:
${project.packaging}
with jar
. Should work in most cases.Upvotes: 3