Package org.codehaus.mojo.buildhelper
Class ParseVersionMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.buildhelper.AbstractDefinePropertyMojo
-
- org.codehaus.mojo.buildhelper.ParseVersionMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="parse-version", defaultPhase=VALIDATE, threadSafe=true) public class ParseVersionMojo extends AbstractDefinePropertyMojo
Parse a version string and set properties containing the component parts of the version. This mojo sets the following properties:[propertyPrefix].majorVersion [propertyPrefix].minorVersion [propertyPrefix].incrementalVersion [propertyPrefix].qualifier [propertyPrefix].buildNumber
Where the propertyPrefix is the string set in the mojo parameter. Note that the behaviour of the parsing is determined by org.apache.maven.artifact.versioning.DefaultArtifactVersion An osgi compatible version will also be created and made available through the property:[propertyPrefix].osgiVersion
This version is simply the original version string with the first instance of '-' replaced by '.' For example, 1.0.2-beta-1 will be converted to 1.0.2.beta-1- Since:
- 1.3
- Version:
- $Id: ParseVersionMojo.java 19908 2014-09-01 20:30:06Z dantran $
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
propertyPrefix
Prefix string to use for the set of version properties.private java.lang.String
versionString
The version string to parse.
-
Constructor Summary
Constructors Constructor Description ParseVersionMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
defineVersionProperty(java.lang.String name, int value)
private void
defineVersionProperty(java.lang.String name, java.lang.String value)
void
execute()
Execute the mojo.java.lang.String
getOsgiVersion(org.apache.maven.artifact.versioning.ArtifactVersion version)
Make an osgi compatible version String from an ArtifactVersionvoid
parseVersion(java.lang.String version)
Parse a version String and add the components to a properties object.void
setPropertyPrefix(java.lang.String prefix)
Set property name prefix.-
Methods inherited from class org.codehaus.mojo.buildhelper.AbstractDefinePropertyMojo
defineProperty, getProject
-
-
-
-
Method Detail
-
execute
public void execute()
Execute the mojo. This sets the version properties on the project.- Throws:
org.apache.maven.plugin.MojoExecutionException
- if the plugin execution fails.
-
defineVersionProperty
private void defineVersionProperty(java.lang.String name, java.lang.String value)
-
defineVersionProperty
private void defineVersionProperty(java.lang.String name, int value)
-
parseVersion
public void parseVersion(java.lang.String version)
Parse a version String and add the components to a properties object.- Parameters:
version
- the version to parse
-
setPropertyPrefix
public void setPropertyPrefix(java.lang.String prefix)
Set property name prefix.- Parameters:
prefix
- The prefix to be used.
-
getOsgiVersion
public java.lang.String getOsgiVersion(org.apache.maven.artifact.versioning.ArtifactVersion version)
Make an osgi compatible version String from an ArtifactVersion- Parameters:
version
- The artifact version.- Returns:
- The OSGi version as string.
-
-