16
votes

I have following project structure:

  • framework
    • framework-parent-pom
    • framework-something
    • ...

In the pom.xml of framework-parent-pom I have defined following plugin:

<plugin>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <branchBase>http://.../svn/REPO/branches/framework</branchBase>
        <tagBase>http://.../svn/REPO/tags/releases/framework</tagBase>
        <tagNameFormat>release-@{project.version}</tagNameFormat>
        <releaseProfiles>release</releaseProfiles>
    </configuration>
</plugin>

And following SCM:

<scm>
    <developerConnection>scm:svn:http://.../svn/REPO/trunk/framework/framework-parent-pom</developerConnection>
</scm>

When I run following command...

mvn release:prepare -DautoVersionSubmodules=true -Darguments="-DskipTests" -Dresume=false

...everything seems to go well.

Locally the JAR's with the release version were created and the POM's are nicely updated to the next SNAPSHOT version. Also in SVN, at first sight it seems ok. The tag has been created with all the framework projects inside it.

However, when looking at the POM's of the tag I see that they still have the initial snapshot version as version. This then of course causes the perform step to build the snapshot version and not the release version.

What am I doing wrong?

12
Bottom line, release works as expected but the version in tag does not have -SNAPSHOT suffix removed. Right?Nishant
Indeed, that's the base problemStijn Geukens
prepare actually tags. But did you go ahead and ran mvn release:perform too?Nishant
yes and that one checks out the tag with the snapshot versions and (surprisingly with no errors) installs it on my local repo (but the snapshot version). In framework-parent-pom/checkout (where Maven checks out the tag) I also see nothing but SNAPSHOT versions). What do you mean with 'prepare actually tags'?Stijn Geukens
I release this may not be tooo helpful, but I had a lot of issues with the release plugin not doing what it was supposed to do (see this question) so perhaps consider saving yourself some time and implementing it yourself. the maven scm plugin gives you a lot of the functionality you need.Overlord_Dave

12 Answers

9
votes

I find the workaround in the maven-release-plugin issue tracker MRELEASE-812 :

In my case the change was :

       <plugin>
         <artifactId>maven-release-plugin</artifactId>
-        <version>2.2.2</version>
+        <version>2.4.1</version>
         <configuration>
           <releaseProfiles>release</releaseProfiles>
           <goals>install animal-sniffer:check deploy site</goals>
         </configuration>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.maven.scm</groupId>
+            <artifactId>maven-scm-api</artifactId>
+            <version>1.8.1</version>
+          </dependency>
+          <dependency>
+            <groupId>org.apache.maven.scm</groupId>
+            <artifactId>maven-scm-provider-gitexe</artifactId>
+            <version>1.8.1</version>
+          </dependency>
+        </dependencies>
       </plugin>
5
votes

I had a similar problem to this. It was tagging the snapshot version because it wasn't committing the POM change before tagging.

I found it would only work if I used the following configuration options:

<remoteTagging>false</remoteTagging>
<suppressCommitBeforeTag>false</suppressCommitBeforeTag>
4
votes

I was also facing same issue. In my came it was because of wrong SCM developerConnection string.

<scm>
<developerConnection>scm:svn:http://.../../trunk</developerConnection>
</scm>

I have ckeckout the code from Branch and was executing release:prepare.

you can check your developerConnection path, It should same as your code repository path.

2
votes

If you are running into this problem you are most likely experiencing https://jira.codehaus.org/browse/MRELEASE-812 and will need to change version of the release plugin (or git) that you use.

HTH, Jan

2
votes

This problem is still unresolved for complex project structure.

See here for patch preview : http://jira.codehaus.org/browse/SCM-740

2
votes

If you are seeing this error with version 2.5 of the maven release plugin then you could be experiencing this bug: http://jira.codehaus.org/browse/MRELEASE-875

If your top level pom.xml is not in the git root then release:prepare does not commit the pom before tagging.

The only work around seems to be to rearrange your project structure in git.

1
votes

I had exactly the same problem when cutting my first release (which was really messy). The second time this problem vanished - so just do a second (clean/fresh) release.

1
votes

I had the same problem. I circumvented the problem by manually editing the tag's POM to set it to the released version. Then the release:perform at least works.

But it's a weird problem that I don't have a clue about where it's coming from.

1
votes

As a workaround, you can also git config --global status.displayCommentPrefix true to output in the old format so that maven can parse the git status command.

1
votes

just for the records, the only workaround that worked for me was the workaround of Andreas Dangel of adding a git config to set the old behavior of parsing localized git output, the command is this one

git config --add status.displayCommentPrefix true

here is the explanation of the workaround: http://jira.codehaus.org/browse/SCM-740?focusedCommentId=341325&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-341325

one last hint, this workaround works only for version 2.4.2, I tested with 2.5 and it does not work

0
votes

This issue is resolved with the combination of Maven 3.2.2 and Maven Release Plugin 2.5.

0
votes

This is how I managed the release plugin to work for me. I wrote the following script. Hopefully it will help someone.

# Reads release.properties and extracts properties by key
function prop {
    grep -E "${1}=" ./release.properties|cut -d'=' -f2
}

echo "Performing a release [Dry run]..."    
mvn release:clean release:prepare -DautoVersionSubmodules=true --offline -DdryRun=true

TAG_NAME=$(prop 'scm.tag')

echo "Tagging a release $TAG_NAME..."   
find .. -maxdepth 2 -mindepth 2 -name "*pom.xml.tag" -exec rename -f 's/\.tag$//' {} ";"
find .. -maxdepth 2 -mindepth 2 -name "*pom.xml" -exec git add {} ";"
git commit -m "Release $TAG_NAME"
git tag -a -m "Release $TAG_NAME" $TAG_NAME

DEV_VERSION=$(prop 'project.dev.cp\\:cp-builder')
echo "Creating next development version $TAG_NAME..."
find .. -maxdepth 2 -mindepth 2 -name "*pom.xml.next" -exec rename -f 's/\.next$//' {} ";"
find .. -maxdepth 2 -mindepth 2 -name "*pom.xml" -exec git add {} ";"
git commit -m "Development version $DEV_VERSION"

echo "Pushing changes to GitLab..."
git push --follow-tags
echo "Deploying a release $TAG_NAME..."
mvn release:perform
echo "Cleaning release..."
mvn release:clean