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?
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}withjar. Should work in most cases.