Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 642
jayunit100 Avatar asked Jun 10 '13 14:06

jayunit100


People also ask

Where does mvn deploy deploy to?

Maven Install Command: mvn install The mvn deploy runs the deploy plugin which deploys an artifact to the remote repository. A project may include the main jar and associated sources and Javadoc jars. The sources jar contains the Java sources, and the Javadoc jar contains the generated Javadoc.

Does mvn deploy also install?

So, the answer is yes, mvn deploy will execute install and build the project artifacts.

How do I publish artifacts to Artifactory using Maven?

Once you have created your Maven repository, go to Application | Artifactory | Artifacts, select your Maven repository and click Set Me Up. In the Set Me Up dialog, click Generate Maven Settings. You can now specify the repositories you want to configure for Maven.


2 Answers

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 ...)

like image 86
mglauche Avatar answered Sep 18 '22 11:09

mglauche


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.

like image 31
khmarbaise Avatar answered Sep 18 '22 11:09

khmarbaise