Keep maven artifact name on maven

I try to include the git commit hash in the artifact name to distinguish between Snapshot-Versions in an CI scenario. The git hash is successfully included in the target/ folder of my project, but in the last maven step it copies the artifact into my HOME/.m2/repositories folder and changes the name to ARTIFACTID-VERSION-mta.jar.

How can I keep the file name from the target/ folder that includes the commit hash?

I had a look at the maven-install-plugin, but couldn't find a "finalName" property or something like this.

[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ projectname ---
[INFO] Installing PROJECTDIR/pom.xml to ~/.m2/repository/GroupIdDir/projectname/1.0.1/projectname-1.0.1.pom
[INFO] Installing PROJECTDIR/target/projectname-1.0.1-d054c42-mta.jar to ~/.m2/repository/GroupIdDir/projectname/1.0.1/projectname-1.0.1-mta.jar

I would like the last line to be

[INFO] Installing PROJECTDIR/target/projectname-1.0.1-d054c42-mta.jar to ~/.m2/repository/GroupIdDir/projectname/1.0.1/projectname-1.0.1-d054c42-mta.jar

Controlling maven final name of jar artifact does not solve the problem because it modifies the output folder.


it is probrably because of repository layout.

Repository Layout Definition

This is the final layout for the repository available in Maven 2.x and its related Ant tasks.

For primary artifacts: /$groupId[0]/../${groupId[n]/$artifactId/$version/$artifactId-$version.$extension

For secondary artifacts: /$groupId[0]/../$groupId[n]/$artifactId/$version/$artifactId-$version-$classifier.$extension

See https://cwiki.apache.org/confluence/display/MAVENOLD/Repository+Layout+-+Final

链接地址: http://www.djcxy.com/p/79978.html

上一篇: Maven在测试时部署

下一篇: 在Maven上保留Maven工件名称