maven : deploy artifact file name
Hi : Im finding that maven deploys by default change the file name to match the version+artifact id. For example
Deploying a jar file, with artifact=A and version=V-0.1 will result in a jar file named AV-0.1.jar.
Is there a way to change the default name of the jar file in the deployment, so that it doesnt concatenate these feilds or to specify the final deployed jar name explicitly?
Complex answer to that: Yes
It is a bit tricky and you need to be careful, as the pom won't get re-written. So only the maven remote repository (artifactory, or nexus) will put it into the correct folder structure.
If you overwrite the deploy-file goal in the maven deploy goal, you can overwrite the parameters: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html
One example which would always post version 4.5.1 to nexus would look like this:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>deploy-file</goal>
</goals>
<phase>deploy</phase>
<configuration>
<repositoryId>nexus-site</repositoryId>
<url>http://nexus.some.where/nexus-2/content/repositories/releases</url>
<file>${build.directory}/${project.build.finalName}.${project.packaging}</file>
<generatePom>false</generatePom>
<pomFile>pom.xml</pomFile>
<version>4.5.1</version>
</configuration>
</execution>
</executions>
</plugin>
(and before someone asks, one reason to do something like this is to make builds more CI friendly. in CI everything is just a build number, there is not really a "build a release", every checkin does yield a production-ready artifact. So by replacing 4.5.1 with ${BUILD_NUMBER}
will leave you with many many releases in your artifact storage ...)
Simple answer to that is: No.
The problem behind it is if you would change the naming schema it will not be possible to find artifacts in a repository. That's the reason having a fixed naming schema.
mvn deploy:deploy-file -DartifactId=AAA -Dversion=VVV -Dpackaging=jar
The command above will place the file in the following structure.
AAA
-VVV
--AAA_VVV.jar
If you just want to make the name of the created file different between consecutive pushes to the artifactory, you can use -Dpackaging parameter. ie. Set the value to the current timestamp
mvn deploy:deploy-file -DartifactId=AAA -Dversion=VVV -Dpackaging=2017_01_31_01_37.jar
AAA
-VVV
--AAA_VVV.jar
--AAA_VVV2017_01_31_01_37.jar
链接地址: http://www.djcxy.com/p/14042.html
上一篇: 尝试了几个修正:Heroku / Rails 4资产预编译错误
下一篇: maven:部署工件文件名