Update I am flagging this question to be closed as there seems to be no solution - the plugin is simply not behaving as it should and no-one seems to know why. I have ended up writing a small program to manually replicate the desired behaviour of the release plugin myself, using other plugins such as scm
and versions
. If you would like information on how I did this feel free to email me.
I have recently moved my project to maven. However, I am having issues with the release process.
My release procedure is as follows:
mvn scm:checkout -DconnectionUrl=scm:svn:https://my-server/svn/my-project/trunk -DcheckoutDirectory=my-project
cd my-project
mvn --batch-mode release:prepare
mvn release:perform
I start on 1.0.0-SNAPSHOT
, I run the release procedure shown above. This updates my repo to the following (in ascending order of newness):
1.0.0-SNAPSHOT
1.0.0
1.0.1-SNAPSHOT
Everything occurs as expected, including the pom.xml
updated to point to 1.0.1-SNAPSHOT
and a tag called my-project-1.0.0
created in my SCM. However, when I run the procedure again, the following appears in my repo:
1.0.0-SNAPSHOT
1.0.1-SNAPSHOT
1.0.0
1.0.2-SNAPSHOT
That is, release 1.0.1 is never created, and instead 1.0.1-SNAPSHOT is released to 1.0.0. Note that every other aspect runs as expected - the pom.xml
now points to 1.0.2-SNAPSHOT
and a tag is created in my SCM with the name my-project-1.0.1
.
In fact, every time I run the release procedure, the SNAPSHOT increases but the release is written to 1.0.0 with a new release never created. For example, re-running the release procedure 3 further times results in the following:
1.0.0-SNAPSHOT
1.0.1-SNAPSHOT
1.0.2-SNAPSHOT
1.0.3-SNAPSHOT
1.0.4-SNAPSHOT
1.0.0
1.0.5-SNAPSHOT
The expected behaviour for the above is:
1.0.0-SNAPSHOT
1.0.0
1.0.1-SNAPSHOT
1.0.1
1.0.2-SNAPSHOT
1.0.2
1.0.3-SNAPSHOT
1.0.3
1.0.4-SNAPSHOT
1.0.4
1.0.5-SNAPSHOT
The pom.xml
for the very first version is shown below:
<project xmlns="http://maven.apache.org/POM/4.0.0" x mlns: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.foo</groupId>
<artifactId>my-project</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>my-project</name>
<distributionManagement>
<repository>
<id>my-server</id>
<url>file://\\my-server\repo\</url>
</repository>
</distributionManagement>
<scm>
<developerConnection>scm:svn:https://my-server/svn/my-project</developerConnection>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>my-server</id>
<url>file://\\my-server\repo\</url>
</repository>
</repositories>
</project>
One of the answers below suggests I should create a separate release
and snapshot
repo, which I have not. Could this be causing the issue?
Note that I am using Jenkins to automatically invoke mvn deploy
whenever code is committed. However this is acting exactly as expected (i.e. deploying whichever version is specified in the committed pom.xml
to the repo) so I doubt this is part of the problem.
Many thanks for any assistance.
Update
Examining the output from the mvn release:perform
command I see the following:
Checking out the project to perform the release ...
Executing: cmd.exe /X /C "svn --non-interactive checkout https://my-server/svn/my-project/tags/my-project-1.0.2 c:\localrelease\mvn\my-project\target\checkout"
Working directory: c:\localrelease\mvn\my-project\target
Invoking perform goals in directory c:\localrelease\mvn\my-project\target\checkout\tags\my-project-1.0.0\trunk
Executing goals 'deploy'...
And there is the reason it is releasing to 1.0.0
every time - it checks out the updated tag, but releases on the old 1.0.0
tag (even though the 1.0.1
tag IS present in the target/checkout folder). Why is it doing this?
Update 2
I have split to 2 separate repositories (one for snapshot and one for target) and this issue still occurs.
Also, something I have noticed upon investigating log for release:perform
further: The checkout for tag my-project-1.0.1
contains the tag for 1.0.0
. Similarly, the checkout for tag 1.0.2
contains the tags 1.0.0
and 1.0.1
, etc. Is this correct behaviour?
Perhaps the release process is always looking in the tags folder of whatever it checks out and uses the first one it finds, which will always be 1.0.0
for every releases except the first release.
This seems like a very strange explanation but it is the only one I have so far for the behaviour I see. The question now is, what have I configured in my pom.xml
incorrectly to cause this to happen?
Another note: when performing the release the deploy goal complains that 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-xxxx-plugin is missing.
for maven-javadoc-plugin
, maven-deploy-plugin
and maven-source-plugin
. Do I need to explicitly add these?