Maven release plugin ignores releaseVersion attribute - maven-release-plugin

I'm trying to create a svn branch from the trunk which has the version of TRUNK-SNAPSHOT in its pom and children's pom files with this command:
mvn --batch-mode release:branch -DbranchName=15.1 -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false -DreleaseVersion=15.1
However I'm getting this error:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error parsing version, cannot determine next version: Unable to parse the version string: "TRUNK-SNAPSHOT"
While it's obvious that it was not able to calculate the next version of TRUNK-SNAPSHOT, why would the plugin ignore the releaseVersion argument that I wanted it to use for the new branch instead of trying to calculate the next version from the trunk's version identifier?
Although running in interactive mode allows me to provide the version for the new branch, I'll need it work in the batch mode. Is there any other way I can specify the new branch version in the batch mode regardless of what the branching source (trunk) version is?
Update 1: The plugin version I use is 2.0-beta-8

This was fixed in 2.4 as part of https://issues.apache.org/jira/browse/MRELEASE-511

Related

JaCoCo SonarQube incompatible version 1007

I'm using SonarQube for code quality control and suddenly builds that would otherwise pass can't be analyzed and fails.
[INFO] [00:00:03.630] Analysing /mySuperProject/target/jacoco.exec ->
java.io.IOException: Incompatible version 1007
When I invoke maven build with debug switch, this cause is revealed
Caused by: java.io.IOException: Incompatible version 1007.
at org.jacoco.core.data.ExecutionDataReader.readHeader(ExecutionDataReader.java:127)
at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:107)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:87)
at org.sonar.plugins.jacoco.AbstractAnalyzer.readExecutionData(AbstractAnalyzer.java:134)
at org.sonar.plugins.jacoco.AbstractAnalyzer.analyse(AbstractAnalyzer.java:107)
While inspecting jacoco ExecutionDataReader, I found that exception is thrown from
if (version != ExecutionDataWriter.FORMAT_VERSION) {
throw new IOException(format("Incompatible version %x.",Integer.valueOf(version)));
}
and from ExecutionDataWriter I've found out
/** File format version, will be incremented for each incompatible change. */
public static final char FORMAT_VERSION = 0x1007;
What is this incompatible change and why does it happen?
Any ideas how to fix this challenge?
As already mentioned, this is due to a break in JaCoCo maven plugin code.
You can (temporarily) specify the version in your jenkins maven command like:
clean org.jacoco:jacoco-maven-plugin:<version>:prepare-agent install
e.g.
clean org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:prepare-agent install
This was the workaround that helped us. But like most people, I'm still waiting for the fix to come.
What I did was to specify the jacoco version in my maven project.
<jacoco-maven-plugin.version>0.7.4.201502262128</jacoco-maven-plugin.version>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
</plugin>
That fix my issue!
Most likely that's caused by latest jacoco-maven-plugin update. Everything was working on 0.7.4.201502262128 but today we switched to 0.7.5.201505241946 which resulted in this error.
Run:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
mvn org.jacoco:jacoco-maven-plugin:prepare-agent clean install -Pcoverage-per-test
mvn sonar:sonar
This will re-generate .exec files created by older versions of jacoco.
Try to update the Java plugin in SonarQube Update Center, this works for me. I updated the Java plugin from version 2.4 to latest 3.13.1.
SonarQube Update Center -> Plugin Updates -> Java
As kdowbecki mentionned it, this error is most likely due to an update of jacoco-maven-plugin.
Your SonarQube is most likely now using the new version of Jacoco Maven Plugin (probably the new 0.7.5.201505241946) but is actually trying to read an old version of a jacoco.exec (in your case it might be reading a jacoco.exec generated by jacoco maven plugin version 0.7.4.201502262128) which results in an incompatibility thrown by JaCoCo.
To fix this problem, you should make sure all your SonarQube/Jenkins jobs generate a JaCoCo report each time and do not rely on an older version of jacoco.exec that might have been generated by a previous job.
For me this, when doing a mvn install
Error while creating report: Cannot read execution data version 0x1006. This version of JaCoCo uses execution data version 0x1007
meant I had done an archetype generate but the archetype accidentally included the target directory with old jacoco files in it (or it had been checked into git on accident). Doing a mvn clean first (and checking that in) cleared up the issue. Guess jacoco is reluctant to overwrite the jacoco.exec file with a new one when there are no unit tests to run or something like that, so the old file gets preserved and attempted to used for the jacoco report. FWIW...
In general it means a version mismatch of generator vs. reporter.
I changed pom.xml like
groupId=org.jacoco
artifactId=jacoco-maven-plugin
version=0.8.4-SNAPSHOT
it worked for me

How do I get maven to modify the version in my pom.xml to a SNAPSHOT?

I'm trying to migrate our legacy build system to maven. I've successfully managed to get maven doing some tagging in CVS, by using the release:prepare and release:perform tasks.
I'm new to maven, and my understanding of tags in CVS is a bit hazy, so please bear with me.
Our code consists of a series of modules, and each module is versioned in CVS using tags.
So for example the module ER_api_test has a version 0.18.0, 0.19.0, etc, each corresponding to tags in CVS (eg ER_api_test_0-18).
Now I want to do some branching. So I need to take an old version of the module, and branch it. If I use version 0.8.0, then when I commit and promote (create the CVS tag using our build system), that will give me 0-8-1.
Now when I check out the code for 0-8-0, the pom.xml has a version 0.8.0. I believe that in order to branch this module, I will need to modify this to 0.8.1-SNAPSHOT. Indeed, when I make the modification manually, I can then use my maven release:perform command to create 0.8.1.
I'd like to run a command which will make this modification of version automatically. There is a maven command called "release:update-versions" which I'm trying to use to do this, but it complains because my version is not a snapshot:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:update-versions (default-cli) on project ER_api_test: You don't have a SNAPSHOT project in the reactor projects list.
How do I modify the version automatically? I would like to use a maven command if possible, as opposed to awk or sed, since the build system runs in java.
Edit:
one option would be to try to use maven to do the branching. Here are the commands which CVS runs in order to check out the branch:
cvs -z3 -d :pserver:user#cvshost:2401/opt/cvs/us -q tag -c -b ER_api_test_0-4_patches
cvs -z3 -d :pserver:user#cvshost:2401/opt/cvs/us -q tag -c ER_api_test_0-4-0
If I can get maven to run an equivalent command, and simultaneously update the version to a snapshot, that will also work.

Maven-release plugin: Branch without snapshot in version

I want to automate our branching process and for that i am using maven-release-plugin.
Following command is used for branching:
mvn --batch-mode release:branch -DupdateBranchVersions=true
-DupdateWorkingCopyVersions=$MoveWorkingCopyToNextVersion
-DautoVersionSubmodules=true -Darguments="-DskipTests"
-DreleaseVersion=$BranchVersion -DbranchName=$BranchVersion
-DscmCommentPrefix=$ReleaseJira:
-Dusername=$BuildUser -Dpassword=$BuildUserPassword
My problem is that with above command version of pom created in branch is "BranchVersion-SNAPSHOT" while i want pom version in branch should be "BranchVersion" i.e. it should not contain snapshot.
I know this is not standard approach but our current release process will not work if branch contains "SNAPSHOT".
Any suggestions?
If you don't get updateVersionsToSnapshot working could you use the versions plugin afterwards to set the version on the Pom
http://mojo.codehaus.org/versions-maven-plugin/set-mojo.html

How to exclude file on maven release:prepare and release:perform?

I am using maven to release/tag my projects, and I am using some propery files and want mvn:prepare to exclude those under release. I tried using the following command:
mvn release:prepare -DpreparationGoals="clean install"
-DcheckModificationExcludeList=props.properties
But it still gives me the following error:
[INFO] Cannot prepare the release because you have local modifications :
[props.properties:unknown]
So the question is: how can ACTUALLY make maven mvn:release skip checking for certian local modifications? Thanks for your time.
This feature was implemented in version 2.1

maven release:prepare fails to release pom.xml with patch version

I am not sure if I am doing something wrong here, or if there is a bug in maven-release-plugin. But when I try to release a version 1.2.1, maven creates a tag with the right version, but the version number set in the tag's pom.xml is set at 1.2 (not 1.2.1 as it should).
This is what I do when I tried to fix a bug in 1.2:
svn cp URL/tags/myapp-1.2 URL/branches/myapp-1.2
edit project.version in URL/branches/myapp-1.2/pom.xml to be 1.2.1-SNAPSHOT (was 1.2)
fix the bug in the source
commit changes
mvn release:prepare
#when asked, use the defaults: release version 1.2.1, next dev version 1.2.2-SNAPSHOT
[INFO] BUILD SUCCESSFUL
OK so far, but if I check out the code in the new tag the version is wrong! URL/tags/myapp-1.2.1/pom.xml has version 1.2, not 1.2.1 as the tag name should suggest. If I just run mvn release:perform now, the new uploaded jar will have its name set to myapp-1.2.jar, overwriting the original in the repository.
I have upped the maven-release-plugin version from 2.0 to 2.1, but with no greater success. I know the thing that causes this error is the part of the process where the plugin does this:
svn --non-interactive copy --file /tmp/maven-scm-2371633.commit --revision 19866 URL/tags/myapp-1.2 URL/tags/myapp-1.2.1
This copies the source from tags/myapp-1.2 to tags/myapp-1.2.1, but this does not contain any changes. Do you agree that it should have copied from branches/myapp-1.2, not the tag?
Is this working for anyone else, and do you see if I am doing anything wrong?
You need to verify if the repository link in your pom is pointing to a branch instead of the trunk.
If that is the case, then you'll get the error. Point it to the trunk, instead.

Resources