Reputation: 3815
I want to be able to auto-increment a java project's release version by using non-interactive mode in Maven release plugin (mvn -B release:prepare
). However I do not want to use the default Maven versioning schema.
The schema that I would like to use is <major>.<minor>.<bugfix>-SNAPSHOT
. I did manage to do this inside the pom file, however Maven tries to increment it as follows:
1.0.0-SNAPSHOT
1.0.1-SNAPSHOT
1.0.2-SNAPSHOT
...
However I want to be able to have control on this and while some of the time I do have bugfixes and the above incrementing works, most of the times I would like to release minor releases and therefore an increment that looks like this:
1.0.0-SNAPSHOT
1.1.0-SNAPSHOT
1.2.0-SNAPSHOT
...
Upvotes: 9
Views: 15710
Reputation: 51
"The maven way"is to follow maven rules, or to create a custom plugin. Maven plays nice as long as you want to do what it expects that you want to do. Maybe solution for you would be to use just "1.1" most of the cases, and if you want to do a bugfix release, then to add 3rd number by hand.
However if you really wish to fight against maven, there is a possibility to setup properties from within some other plugin.. i.e. like this:
<profile>
<id>customversionnumber</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<execution>
<id>set-release-version</id>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
project.properties.setProperty("releaseVersion","1.3.0")
System.out.println("releaseVersion set to 1.3.0")
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Then, you'd invoke release plugin like this
mvn -Pcustomversionnumber initialize release:prepare
.
And it will release it as "1.3.0" regardless whats in 'version' tag. I'll have to code that number increment on your own of course.
Upvotes: 1
Reputation: 97399
You can handle this via build-helper-maven-plugin like this:
mvn build-helper:parse-version versions:set \
release:prepare \
-DdevelopmentVersion =\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT \
release:perform
This will set the 1.1.0-SNAPSHOT
as next development version..The next time you call release plugin it will make 1.1.0
from it and will automatically increment 1.1.1-SNAPSHOT
if you don't like just use the call above...
Upvotes: 6