22

I'm trying to release a project using maven but instead of releasing to the Releases repository it puts it in our Snapshots repo.

My pom looks like:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                             http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.my.profiler</groupId>
<artifactId>profilerlib</artifactId>
<name>Profiler Lib</name>
<version>1.0.2-SNAPSHOT</version>
<description>Profiler Library</description>
<scm>
    <connection>scm:svn:https://svn.example.com/my-project/profilerlib/trunk
    </connection>
    <developerConnection>scm:svn:https://svn.example.com/my-project/profilerlib/trunk
    </developerConnection>
</scm>
<distributionManagement>
    <!-- Publish the versioned releases here -->
    <repository>
        <id>nexus</id>
        <name>nexus</name>
        <url>http://repo.example.com:8081/nexus/content/repositories/releases
        </url>
    </repository>
    <!-- Publish the versioned releases here -->
    <snapshotRepository>
        <id>nexus</id>
        <name>nexus</name>
        <url>http://repo.example.com:8081/nexus/content/repositories/snapshots
        </url>
    </snapshotRepository>
</distributionManagement>
<!-- download artifacts from this repo -->
<repositories>
    <repository>
        <id>nexus</id>
        <name>EXAMPLE Public Repository</name>
        <url>http://repo.example.com:8081/nexus/content/groups/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<dependencies>
    ...
</dependencies>
<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
                <tagBase>https://svn.example.com/my-project/profilerlib/tags
                </tagBase>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <powermock.version>1.4.6</powermock.version>
</properties>
</project>
Betlista
  • 10,327
  • 13
  • 69
  • 110
Leon Roy
  • 580
  • 1
  • 5
  • 16

5 Answers5

25

In case anyone else is having this problem and find the existing answers do not solve their issues:

There have been a handful of bugs which mean that release:prepare does not commit to the git repository before creating the release tag. This means that the version number in the pom files that the release:perform finds contains -SNAPSHOT and the deployer will try to release to the snapshot repository.

Here is the most recent defect responsible for this behavior: MRELEASE-875 (affects 2.5, fixed in 2.5.1)

Ken
  • 654
  • 8
  • 18
  • This was exactly my problem, thanks! For some reason Maven was picking up the broken 2.5 release; forcing it to choose 2.5.1 (http://mvnrepository.com/artifact/org.apache.maven.plugins/maven-release-plugin/2.5.1) by specifying the version in the POM sorted it out. – Alice Purcell Jan 14 '15 at 23:07
  • Just confirm that ! thanks a lots. I found [an help page](https://maven.apache.org/guides/mini/guide-releasing.html) that is showing `2.5` version of `maven-release-plugin`. I just send an email on the [ML](http://mail-archives.apache.org/mod_mbox/maven-users/201507.mbox/thread) to ask them to update this page. – boly38 Jul 31 '15 at 14:04
19
<repository>
    <id>nexus</id><!--etc-->
</repository>
<snapshotRepository>
    <id>nexus</id><!--etc-->
</snapshotRepository>
<!-- etc -->
<repositories>
    <repository>
        <id>nexus</id>
        <!-- etc -->
    </repository>
</repositories>

This is the problem, you are using the same id for three different repositories. Maven manages these repositories by ID, so each ID must be unique! E.g. use "nexus-releases", "nexus-snapshots" and "nexus".

Betlista
  • 10,327
  • 13
  • 69
  • 110
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
14

The POM shows the version number to be a SNAPSHOT version. So if you ran mvn deploy with the POM in this state, it would naturally deploy a snapshot to the snapshots repository.

To do a release, you need to use the goals of the release plugin.


On the other hand, maybe you already know this, and the real answer is in Sean Patrick Floyd's answer.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Haha, I overlooked the obvious (+1)!! – Sean Patrick Floyd Sep 07 '11 at 11:59
  • I'm running: mvn release:prepare release:perform NOT mvn deploy. From what I understand, the release plugin should remove the -SNAPSHOT suffix before deploying, no? – Leon Roy Sep 07 '11 at 13:28
  • 1
    @user932509 you should run prepare and perform in two separate steps, because I doubt that prepare changes the version of the running execution artifact (that would be evil) – Sean Patrick Floyd Sep 07 '11 at 13:41
  • 1
    Run it separately as well. Same issue. According to this prepare does change the version: http://stackoverflow.com/questions/810957/maven-release-plugin-war-stories/811717#811717 – Leon Roy Sep 07 '11 at 14:58
3

Fell foul of this problem with a different cause... make sure that the release-plugin is checking out a tag, and not a branch with the same name!

I just fell foul of this... I created a branch called "1.9.0" in which to do my release, and then ran mvn release:prepare which also created a "1.9.0" tag. When mvn release:perform ran it did a git checkout of "1.9.0, and ended up picking up the HEAD of the 1.9.0 branch, which, of course, had a SNAPSHOT in it (1.10-SNAPSHOT).

That's two hours of my life I won't get back... In future I shall be adding a "-release" suffix to the branch name (eg "1.9.0-release").

Dan Haywood
  • 2,215
  • 2
  • 17
  • 23
0

If the problems persist they're probably related to the version of maven-release-plugin you are specifying in the parent pom. Specifying 2.2.2 of the maven-release-plugin definitely fails and will only deploy a snapshot (under certain conditions yet to be fully explained). The latest plugin (ie. remove the tag from the pom.xml) however works.

PGP
  • 365
  • 2
  • 6