Package org.codehaus.mojo.versions
Class SetMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
org.codehaus.mojo.versions.SetMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="set",
aggregator=true,
threadSafe=true)
public class SetMojo
extends AbstractVersionsUpdaterMojo
Sets the current project's version and based on that change propagates that change onto any child modules as
necessary.
- Since:
- 1.0-beta-1
- Author:
- Stephen Connolly
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Whether to add next version number and-SNAPSHOT
to the existing version.protected Integer
Specifies the version index to increment when usingnextSnapshot
.protected final org.apache.maven.project.ProjectBuilder
The (injected) instance ofProjectBuilder
Fields inherited from class org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
allowSnapshots, artifactHandlerManager, generateBackupPoms, ignoredVersions, project, reactorProjects, repositorySystem, ruleSet, session, wagonMap
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
ConstructorsConstructorDescriptionSetMojo
(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager, org.eclipse.aether.RepositorySystem repositorySystem, org.apache.maven.project.ProjectBuilder projectBuilder, Map<String, org.apache.maven.wagon.Wagon> wagonMap, Map<String, ChangeRecorder> changeRecorders, org.codehaus.plexus.components.interactivity.Prompter prompter) -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Called when this mojo is executed.protected String
getIncrementedVersion
(String version, Integer nextSnapshotIndexToIncrement) Returns the incremented version, with the nextSnapshotIndexToIncrement indicating the 1-based index, from the left, or the most major version component, of the version string.protected void
Updates the pom file.Methods inherited from class org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
findLatestVersion, getChangeRecorder, getHelper, getProject, getVersion, process, saveChangeRecorderResults, setProject, shouldApplyUpdate, shouldApplyUpdate, updatePropertyToNewestVersion, validateInput
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
nextSnapshot
@Parameter(property="nextSnapshot", defaultValue="false") protected boolean nextSnapshotWhether to add next version number and-SNAPSHOT
to the existing version. Unless specified bynextSnapshotIndexToIncrement
, will increment the last minor index of the snapshot version, e.g. thez
inx.y.z-SNAPSHOT
- Since:
- 2.10
-
nextSnapshotIndexToIncrement
Specifies the version index to increment when using
nextSnapshot
. Will increment the (1-based, counting from the left, or the most major component) index of the snapshot version, e.g. for-DnextSnapshotIndexToIncrement=1
and the version being1.2.3-SNAPSHOT
, the new version will become2.2.3-SNAPSHOT.
Only valid with
nextSnapshot
.- Since:
- 2.12
-
projectBuilder
protected final org.apache.maven.project.ProjectBuilder projectBuilderThe (injected) instance ofProjectBuilder
- Since:
- 2.14.0
-
-
Constructor Details
-
SetMojo
@Inject public SetMojo(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager, org.eclipse.aether.RepositorySystem repositorySystem, org.apache.maven.project.ProjectBuilder projectBuilder, Map<String, org.apache.maven.wagon.Wagon> wagonMap, Map<String, ChangeRecorder> changeRecorders, org.codehaus.plexus.components.interactivity.Prompter prompter)
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionCalled when this mojo is executed.- Specified by:
execute
in interfaceorg.apache.maven.plugin.Mojo
- Overrides:
execute
in classAbstractVersionsUpdaterMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
- when things go wrong.org.apache.maven.plugin.MojoFailureException
- when things go wrong.
-
getIncrementedVersion
protected String getIncrementedVersion(String version, Integer nextSnapshotIndexToIncrement) throws org.apache.maven.plugin.MojoExecutionException Returns the incremented version, with the nextSnapshotIndexToIncrement indicating the 1-based index, from the left, or the most major version component, of the version string.- Parameters:
version
- input versionnextSnapshotIndexToIncrement
- 1-based segment number to be incremented- Returns:
- version with the incremented index specified by nextSnapshotIndexToIncrement or last index
- Throws:
org.apache.maven.plugin.MojoExecutionException
- thrown if the input parameters are invalid
-
update
protected void update(MutableXMLStreamReader pom) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, XMLStreamException Updates the pom file.- Specified by:
update
in classAbstractVersionsUpdaterMojo
- Parameters:
pom
- The pom file to update.- Throws:
org.apache.maven.plugin.MojoExecutionException
- when things go wrong.org.apache.maven.plugin.MojoFailureException
- when things go wrong.XMLStreamException
- when things go wrong.
-