可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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?
回答1:
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>
回答2:
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.
回答3:
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:
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
回答5:
This problem is still unresolved for complex project structure.
See here for patch preview :
http://jira.codehaus.org/browse/SCM-740
回答6:
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.
回答7:
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.
回答8:
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.
回答9:
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.
回答10:
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
回答11:
This issue is resolved with the combination of Maven 3.2.2 and Maven Release Plugin 2.5.
回答12:
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