Created
August 23, 2018 09:28
-
-
Save michl-b/65797f4b38751c0f7eae678b99b4a3d4 to your computer and use it in GitHub Desktop.
increment project version by maven profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<profiles> | |
<profile> | |
<id>incrementVersion</id> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>build-helper-maven-plugin</artifactId> | |
<version>3.0.0</version> | |
<executions> | |
<execution> | |
<id>parse-version</id> | |
<phase>validate</phase> | |
<goals> | |
<goal>parse-version</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.1</version> | |
<executions> | |
<execution> | |
<id>run</id> | |
<phase>validate</phase> | |
<goals> | |
<goal>run</goal> | |
</goals> | |
<configuration> | |
<tasks> | |
<echo>Major: ${parsedVersion.majorVersion}</echo> | |
<echo>Minor: ${parsedVersion.minorVersion}</echo> | |
<echo>Incremental: ${parsedVersion.incrementalVersion}</echo> | |
<echo>Qualifier: ${parsedVersion.qualifier}</echo> | |
<echo>BuildNumber: ${parsedVersion.buildNumber}</echo> | |
<echo>nextMajorVersion: ${parsedVersion.nextMajorVersion}</echo> | |
<echo>nextMinorVersion: ${parsedVersion.nextMinorVersion}</echo> | |
<echo>nextIncrementalVersion: ${parsedVersion.nextIncrementalVersion}</echo> | |
</tasks> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>versions-maven-plugin</artifactId> | |
<version>2.5</version> | |
<executions> | |
<execution> | |
<id>set</id> | |
<phase>validate</phase> | |
<goals> | |
<goal>set</goal> | |
</goals> | |
<configuration> | |
<newVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}</newVersion> | |
</configuration> | |
</execution> | |
<execution> | |
<id>commit</id> | |
<phase>validate</phase> | |
<goals> | |
<goal>commit</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</profile> | |
</profiles> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
increment the version by
mvn validate -P incrementVersion