Maven: artifact file name

Hi: Im, finding that maven is deploying by default, changes the file name according to the version identifier + artifact. for example

Deploying a jar file with artifact = A and version = V-0.1 will create a jar file named AV-0.1.jar.

Is it possible to change the default name of the jar file in the deployment so that it does not bind these feilds or indicate the final expanded name of the jar explicitly?

+7
source share
3 answers

Comprehensive answer to this question: Yes

This is a bit complicated, and you need to be careful as pom will not correspond. Thus, only the remote maven repository (artifactory or nexus) puts it in the correct folder structure.

If you write the deployment target to the maven deployment target, you can overwrite the options: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html

One example that will always send 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 of the reasons to do something like this is to make assemblies more friendly to CI. In CI, everything is just an assembly number, in fact there is no โ€œrelease buildโ€, each checkin gives performance So, replacing 4.5.1 with ${BUILD_NUMBER} will leave you with many releases in your artifact repository ...)

+3
source

The simple answer to this is: No.

The problem is that if you change the naming scheme, you cannot find artifacts in the repository. This is the reason for having a fixed naming scheme.

0
source

mvn deploy: deploy-file -DartifactId = AAA -Dversion = VVV -Dpackaging = jar

The above command will put the file in the following structure.

 AAA -VVV --AAA_VVV.jar 

If you just want the name of the generated file to differ between successive clicks on artifactory, you can use the -Dpackaging option. i.e. Set value to 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 
0
source

All Articles