Search code examples
javamavenmaven-2pom.xml

How to install a tagged version (i.e. not a snapshot) of your project locally and not to the maven central?


So I have done mvn release:clean and mvn release:prepare.

As a result I have a clean tag on my subversion with the latest version 1.3.3 of my artifact.

Now I want to install that version 1.3.3 on my local maven repo (.m2) and NOT to the remote central maven repo.

How to do that?

Do I need to change something on my settings.xml ???

Do I need to run mvn release:perform with some kind of local options ??? Right now if I run mvn release:perform it will try to release my artifact to the maven central repo, which is exactly what I do not want. I want to release it locally to my other local projects, so I can do:

<dependency>
  <groupId>com.mycompany</groupId>
  <artifactId>myartifact</artifactId>
  <version>1.3.3</version>
</dependency>

Interestingly enough, snapshots work fine:

<dependency>
      <groupId>com.mycompany</groupId>
      <artifactId>myartifact</artifactId>
      <version>1.3.4-SNAPSHOT</version>
    </dependency>

So I am installing snapshots, but not full releases.

Here is my settings.xml:

<settings>

  <profiles>

  <profile>
     <id>allow-snapshots</id>
        <activation><activeByDefault>true</activeByDefault></activation>
     <repositories>
       <repository>
         <id>snapshots-repo</id>
         <url>https://oss.sonatype.org/content/repositories/snapshots</url>
         <releases><enabled>false</enabled></releases>
         <snapshots><enabled>true</enabled></snapshots>
       </repository>
     </repositories>
   </profile>

    <profile>
      <id>mac-profile</id>
      <properties>

        <project.build.sourceEncoding>
          UTF-8
        </project.build.sourceEncoding>

        <project.reporting.outputEncoding>
          UTF-8
        </project.reporting.outputEncoding>

      </properties>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>mac-profile</activeProfile>
  </activeProfiles>

  <pluginGroups>
    <pluginGroup>org.sonatype.plugins</pluginGroup>
  </pluginGroups>
  <servers>
    <server>
      <id>sonatype-nexus-snapshots</id>
      <username>myUsername</username>
      <password>myPassword</password>
    </server>
    <server>
      <id>sonatype-nexus-staging</id>
      <username>myUsername</username>
      <password>myPassword</password>
    </server>
  </servers>
</settings>

Solution

  • The simplest thing to do is to checkout the tag in another directory and then run

    mvn install
    

    However, if you want to use release:perform, you need to change the goals.

    http://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html#goals is the parameter, make it say install instead of deploy.