Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn deploy:file to different repositories for snapshot and release version

Tags:

Is it possible to in some way tell the maven deploy:file goal to deploy to two independent artifactories based on whether the version of the project is a snapshot / release?

I'm hoping there might be a property which indicates the fact the version has -SNAPSHOT prepended, or perhaps the default artifactory to deploy to (which has been worked out based on the version number already).

I thought about using two different profiles and working out if its a snapshot in ant by parsing the pom.xml file, but I'd rather a cleaner solution if possible.

Currently, my deploy plugin looks as follows, but this just deploys to the release artifactory regardless of the version;

<plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-deploy-plugin</artifactId>    <version>2.5</version>    <executions>       <execution>         <id>deploy-zip-created-by-ant-to-artifactory</id>     <phase>deploy</phase>     <goals>        <goal>deploy-file</goal>     </goals>     <configuration>        <repositoryId>${project.distributionManagement.repository.id}</repositoryId>        <url>${project.distributionManagement.repository.url}</url>        <file>${project.basedir}/Build/deploy/MyArtifact.zip</file>        <pomFile>${project.basedir}/MyArtifact-pom.xml</pomFile>     </configuration>       </execution>    </executions> </plugin> 

Many Thanks

like image 359
extorn Avatar asked Jul 29 '11 10:07

extorn


People also ask

What is the difference between snapshot and release in Maven?

A Maven snapshot is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix SNAPSHOT that is appended to the package version.

What is snapshot deployment?

Deploying a snapshot deploys the components in the snapshot. The components are deployed in the order in which they were added to the snapshot or to the environment on which the snapshot is based.

What is the difference between a snapshot and a release?

By definition, snapshots are mutable, releases are immutable. This is why Nexus makes you store them separately because usually you don't care if you lose snapshots, but you will care if you lose releases. It makes snapshot cleanup much easier to deal with that way.

Does mvn deploy also build?

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


1 Answers

If you defined your repositories within your settings.xml you can use the

mvn deploy:deploy-file -DrepositoryId=releases -DartifactId=... -Durl= 
like image 50
khmarbaise Avatar answered Sep 19 '22 14:09

khmarbaise