@Mojo(name="parse-version", defaultPhase=VALIDATE, threadSafe=true) public class ParseVersionMojo extends AbstractDefinePropertyMojo
[propertyPrefix].majorVersion [propertyPrefix].minorVersion [propertyPrefix].incrementalVersion [propertyPrefix].qualifier [propertyPrefix].buildNumberWhere the propertyPrefix is the string set in the mojo parameter. The parsing of the above is based on the following format of the version:
<majorversion [> . <minorversion [> . <incrementalversion ] ] [> - <buildnumber | qualifier ]>It will be tried to parse the version as an OSGi version. It this is successful the following property will be set accordingly. If this is not possible a warning will be emitted.
[propertyPrefix].osgiVersionThis goal also sets the following properties:
[propertyPrefix].nextMajorVersion [propertyPrefix].nextMinorVersion [propertyPrefix].nextIncrementalVersion [propertyPrefix].nextBuildNumberThis goal also sets the following properties:
[formattedPropertyPrefix].majorVersion [formattedPropertyPrefix].minorVersion [formattedPropertyPrefix].incrementalVersion [formattedPropertyPrefix].buildNumberThis goal also sets the following properties:
[formattedPropertyPrefix].nextMajorVersion [formattedPropertyPrefix].nextMinorVersion [formattedPropertyPrefix].nextIncrementalVersion [formattedPropertyPrefix].nextBuildNumberThere is another property set which is named
[propertyPrefix].qualifier
and furthermore
another property which is named [propertyPrefix].qualifier?
which contains a prefix
-
if the qualifier contains anything otherwise the whole property is simply empty.
mvn build-helper:parse-version versions:set \ -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.\${parsedVersion.incrementalVersion}\${parsedVersion.qualifier?}The above properties contain simply incremented versions of the parsed version informations. Those can now be used to update the version of your project via the following to the next Major version:
mvn build-helper:parse-version versions:set \ -DnewVersion=\${parsedVersion.nextMajorVersion}.0.0 \ versions:commitIt can of course being used to increment the minor version:
mvn build-helper:parse-version versions:set \ -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 \ versions:commitThis can make an upgrade of the versions of your project very convenient.
Constructor and Description |
---|
ParseVersionMojo() |
Modifier and Type | Method and Description |
---|---|
void |
execute()
Execute the mojo.
|
void |
parseVersion(String version)
Parse a version String and add the components to a properties object.
|
void |
setFormatBuildNumber(String formatBuildNumber) |
void |
setFormatIncremental(String formatIncremental) |
void |
setFormatMajor(String formatMajor) |
void |
setFormatMinor(String formatMinor) |
void |
setFormattedPropertyPrefix(String formattedPropertyPrefix) |
void |
setPropertyPrefix(String prefix)
Set property name prefix.
|
defineProperty, getProject
public void execute()
public void parseVersion(String version)
version
- the version to parsepublic void setPropertyPrefix(String prefix)
prefix
- The prefix to be used.public void setFormattedPropertyPrefix(String formattedPropertyPrefix)
formattedPropertyPrefix
- The prefix used for formatted properties.public void setFormatMajor(String formatMajor)
formatMajor
- Set the format for major part.public void setFormatMinor(String formatMinor)
formatMinor
- Set the format for minor part.public void setFormatIncremental(String formatIncremental)
formatIncremental
- Set format for incremental part.public void setFormatBuildNumber(String formatBuildNumber)
formatBuildNumber
- Set the format for the buildNumber part.Copyright © 2005–2020 MojoHaus. All rights reserved.