Is maven release:branch supposed to update scm url of the branch? - maven

I have this in my pom:
<scm>
<connection>scm:javasvn:http://url.com/repo/myProject/trunk</connection>
<developerConnection>scm:javasvn:http://url.com/repo/myProject/trunk</developerConnection>
<url>http://url.com/websvn/listing.php?repname=repo&path=/myProject/trunk</url>
</scm>
When I run:
mvn release:branch -DbranchName=myBranch
It creates successfully the branch here :
http://url.com/repo/myProject/branches/myBranch
But when I look into the pom.xml of this branch, the "scm" part remains the same as the trunk
<scm>
<connection>scm:javasvn:http://url.com/repo/myProject/trunk</connection>
<developerConnection>scm:javasvn:http://url.com/repo/myProject/trunk</developerConnection>
<url>http://url.com/websvn/listing.php?repname=repo&path=/myProject/trunk</url>
</scm>
Doc says:
Transform the SCM information in the POM to include the final
destination of the tag
Isn't the plugin supposed to replace "/trunk" by "/branches/myBranch"? Or are we supposed to do this manually?

The plugin replaces "trunk" by the "branches/myBranch" but don't switch your working copy. In the new created branch, viewing the remote pom.xml the scm info should have changed for that branch. maven:release fails if it cannot commit the changes.
r1643
[maven-release-plugin] prepare for next development iteration
---------------------
r1642
[maven-release-plugin] copy for branch a-project-1.0
---------------------
r1641
[maven-release-plugin] prepare branch a-project-1.0
---------------------
Is your svn log looking like this at the revision you created the branch?
In this example, r1641 changed the pom scm info from "trunk" to "branches/a-project-1.0".
r1642 copied the trunk to the branch, creating it.
r1643 changed the pom scm info from "branches/a-project-1.0" to "trunk" again so you remain at trunk in your working copy.
When I've used maven release and it failed, always has shown an error at the command line and left temporal files at my working copy that have to be deleted or cleaned with mvn --batch-mode release:clean.
Try changing your scm.url to "http://url.com/repo/myProject/trunk" instead of "http://url.com/websvn/listing.php?repname=repo&path=/myProject/trunk" (I don't think maven can change your current url parameter)
Then go again with: mvn --batch-mode -DbranchName="A_TEST" -Darguments="-DskipTests=true"
and check console errors, the svn log at the svn projects root folder, and also check for local working copy modifications.
If all should have been OK and it's not, check your maven runtime version. I've got some problems working with maven:release and maven 3.0.5 when releasing tags. I only use maven 3.1+ for branching/releasing automation purposes.

I replaced
scm:javasvn:http://...
with
scm:svn:http://...
And the transformation is done now.

Related

create tag from a branch SVN

I have a problem with SVN. I want to commit a file (myFile.xml) from a branch and after create a tag of that branch, but when I check the new tag, myFile.xml is not modified... I will write the steps that I am doing:
1.- Checkout the branch
2.- I modify the file and commit it
3.- Checkout the branch again (to check the file and it is right)
4.- With maven mvn release:prepare and mvn release:perfom
5.- I check the new tag and myFile.xml is not modified....
What am I doing wrong??
Thank you so much.
In order for the maven release plugin to work correctly, the pom.xml must contain a
<scm>
<developerConnection>
tag, and the developerConnection must point exactly to where you want to release from.
If you created your branch "by hand" (not using the release plugin) and didn't update the developerConnection in your pom.xml, your developerConnection still points to the location you branched from (e.g. trunk).
This is for me a very hot candidate to create exactly the behaviour you describe.

Branch through maven from subversion tag with correct developerConnection

I am trying to create a branch from a tag with maven but the developerConnection property is not updated. How do I do this through maven or editing the pom.xml file manually?
We use subversion for scm and maven for build/release. I want to create a branch from the latest tag (release). We will use the branch for maintenance of the code, including bug fixes, and continue developing on the trunk. (I know that discussion of developing on trunk versus on branch is involved, and I don't want to open that up.)
When I use release:branch to create the branch, the developerConnection property refers to the tag that I checked out of to create my working copy. I want it to point to the branch.
I checked out the latest tag. (foo-80.0.8)
From the command line in the working copy directory of that tag, I ran:
mvn release:branch -DbranchName=foo-80.0.8.1.x -DupdateWorkingCopyVersions=false
(The .1.x refers to the 1 st branch with x as a placeholder indicator for branch version.)
In the resulting pom.xml in the branch on the repository, the developerConnection property was set to
...Foo/tags/foo-80.0.8 (I omitted the beginning of the URL to prevent the automatic hyperlink.) I want it to be ...Foo/branches/foo-80.0.8.1.x
I tried again, but this time, I edited the pom.xml file, and changed developerConnection to ...Foo/branches/foo-80.0.8.1.x. After running mvn release:branch ..., developerConnection in the pom.xml file still pointed to the tag.
UPDATE:
I took #twomey1's suggestion. (Thanks!) Now developerConnection points to ...\tags\foo-80.0.8.1.x which is not the original tag (good), but that tag doesn't exist (bad). I checked out a fresh copy of the new branch, modified pom.xml to point to the branch, and committed the change. When I tried mvn release:prepare I got this error message:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.0-beta-7:prepare (default-cli) on
project foo: You don't have a SNAPSHOT project in the reactor projects list.
UPDATE:
#twomey1's comment about SNAPSHOT helped. Using -DupdateVersionsToSnapshot on the command line, I got release:prepare to go forward but there still seems to be confusion with tags and branches. Again, my workflow:
Run svn checkout https:.../tags/foo-80.0.8.
Run mvn -DupdateVersionsToSnapshot=true -DupdateBranchVersions=true
-DupdateWorkingCopyVersions=false -DbranchName=foo-80.0.8.1 release:branch from the working copy of the tag that was just checked out.
Run svn checkout https:.../branches/foo-80.0.8.1 from the parent directory of the working copy.
Run mvn release:prepare from the working copy of the branch that was just checked out.
Then I get a svn error passed from maven that tag foo-80.0.8.1 already exists. I want to create a release from the branch which should not conflict. The developerConnection property still points to ...\tags\foo-80.0.8.1 which doesn't exist.
UPDATE:
I repeated with this difference, I added .1 to the end of the release version, the SCM release tag, and the portion of the development version before SNAPSHOT. This seems to work. I did this during mvn release:prepare.
From the official release plugin documentation
By default, the POM in the new branch keeps the same version as the
local working copy, and the local POM is incremented to the next
revision. If you want to update versions in the new branch and not in
the working copy, run:
mvn release:branch -DbranchName=my-branch -DupdateBranchVersions=true
-DupdateWorkingCopyVersions=false
Note: This can be useful if you want to create a branch from a tag
http://maven.apache.org/maven-release/maven-release-plugin/examples/branch.html
I think you are just missing -updateBranchVersions=true from your command

How to use mvn:release with GitHub when projects are in subdirectory?

I am trying to use mvn release plugin with my github project https://github.com/inder123/playn-ext
The Java project is in a subdirectory of playn-ext, under playn-headless-android. To use mvn release plugin, I need to setup the scm portion of the pom. Here is what I wrote initially:
<scm>
<connection>scm:git:git#github.com:inder123/playn-ext.git</connection>
<url>scm:git:git#github.com:inder123/playn-ext.git</url>
<developerConnection>scm:git:git#github.com:inder123/playn-ext.git</developerConnection>
</scm>
However, mvn release (when run from playn-headless-android) fails since the project pom is not available at the top-level.
How do I configure the scm section? Thanks for the help.
One approach would be to create a parent pom in playn-ext directory. However, mvn release only seems to commit the parent project in this case.

maven release:branch - where to perform?

I tried today to switch our release build so that it uses branches. Before my change, I just did
mvn release:prepare -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -Dtag=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION
mvn release:perform
Now I changed to use
mvn release:branch -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -DbranchName=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION -DautoVersionSubmodules=true -DbranchBase=$SVN_BRANCH_BASE -DdryRun=false -DsuppressCommitBeforeBranch=false -DremoteTagging=false -DupdateBranchVersions=true -DupdateVersionsToSnapshot=false -DupdateWorkingCopyVersions=true -DgenerateBackupPoms=false
then I checked that branch out and tried to perform a release on it. But this does not work, it tells me:
Unable to configure SCM repository: No such provider: 's'
SCM config is:
<scm>
<connection>scm:svn:https://svn2.mycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</connection>
<developerConnection>scm:svn:https://svn2.cmycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</developerConnection>
<url>https://svn2.mycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</url>
</scm>
This url might look a bit strange, but we do not have a default layout and this is a correct branch URL.
This is done with maven 3. I´m not sure if it´s correct to do the release:perform in another location than I did the release:branch, but I don´t have a better idea, specifically because I can not set any release.properties file like it is created with release:prepare. Or would it be necessary to do the release:branch AND the release:prepare? A first try on that did not work and got the same error.
Any suggestions?
Thanks
Michael
After lots of struggle, I found the following approach working:
Ensure that your trunk has definitely correct scm info in the pom.
run mvn release:branch -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -DbranchName=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION -DautoVersionSubmodules=true -DbranchBase=$SVN_BRANCH_BASE -DupdateWorkingCopyVersions=true.
This will create a branch in SVN where all versions are kept like they are in the trunk and will then increase version number in the trunk to $NEXT_DEV_VERSION and commit this as well. Branchbase can be set in the plugin configuration as well (in this case it can be omitted here).
checkout the new-made branch and change into the local branch dir
run mvn release:prepare -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -Dtag=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION to update the release number in your branch to $RELEASE_VERSION (will be changed locally + commit into the branch by this single command). This command will on top create a release tag.
run mvn release:perform in your local branch dir to start the actual build. This will checkout the tag created in the previous step and build upon this code.

Maven release:branch

I have a maven multi module project.
When the code is development complete, we would want to write a branch build job in Jenkins which branches the code, increment the pom versions in the trunk, and remove the
-SNAPSHOT from the pom versions in the branch.
So, if the trunk is 2.2-SNAPSHOT, by the end of the operation, the trunk should be 2.3-SNAPSHOT, and the newly created branch should have poms with 2.2.
When I use release:branch the trunk is getting updated but it's not removing the -SNAPSHOT from the poms in the branch.
Please let me know if you have any ideas of achieving this.
Thanks in advance.
From Maven Release plugin: Create a branch
By default, the POM in the new branch keeps the same version as the local working copy, and the local POM is incremented to the next revision. If you want to update versions in the new branch and not in the working copy, run:
mvn release:branch -DbranchName=my-branch -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false
Note: This can be useful if you want to create a branch from a tag
As an alternative, you might want to try the Versions Maven plugin:
mvn versions:set versions:commit -DnewVersion=2.2.0
You would still need to create the branch by hand though...

Resources