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?
In ant build.xml using:
${project.build.directory}/${project.artifactId}-${project.version}.jar
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.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With