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 booleanWhether to allow snapshots when searching for the latest version of an artifact.protected booleanWhether to add next version number and-SNAPSHOTto the existing version.protected IntegerSpecifies the version index to increment when usingnextSnapshot.protected final org.apache.maven.project.ProjectBuilderThe (injected) instance ofProjectBuilderFields inherited from class AbstractVersionsUpdaterMojo
artifactFactory, generateBackupPoms, ignoredVersions, mojoExecution, project, reactorProjects, repositorySystem, ruleSet, rulesUri, serverId, session, skip, wagonMapFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsConstructorDescriptionSetMojo(ArtifactFactory artifactFactory, 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) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Called when this mojo is executed.protected booleantrueif snapshots should be allowed when searching for newer versions of artifacts.protected StringgetIncrementedVersion(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 voidUpdates the pom file.Methods inherited from class AbstractVersionsUpdaterMojo
findLatestVersion, getChangeRecorder, getHelper, getProject, getVersion, process, saveChangeRecorderResults, setProject, shouldApplyUpdate, shouldApplyUpdate, updatePropertyToNewestVersion, validateInputMethods 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-SNAPSHOTto the existing version. Unless specified bynextSnapshotIndexToIncrement, will increment the last minor index of the snapshot version, e.g. thezinx.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 @{code -DnextSnapshotIndexToIncrement=1} whilst all lesser components will become 0's.For example, the version being @{code 1.2.3-SNAPSHOT}, the new version will become
2.0.0-SNAPSHOT.Only valid with
nextSnapshot.- Since:
- 2.12
-
allowSnapshots
@Parameter(property="allowSnapshots", defaultValue="false") protected boolean allowSnapshotsWhether to allow snapshots when searching for the latest version of an artifact.- Since:
- 1.0-alpha-1
-
projectBuilder
protected final org.apache.maven.project.ProjectBuilder projectBuilderThe (injected) instance ofProjectBuilder- Since:
- 2.14.0
-
-
Constructor Details
-
SetMojo
@Inject public SetMojo(ArtifactFactory artifactFactory, 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) throws org.apache.maven.plugin.MojoExecutionException Creates a new instance.- Parameters:
artifactFactory- the artifact factoryrepositorySystem- the repository systemprojectBuilder- the project builderwagonMap- the map of wagon implementationschangeRecorders- the change recordersprompter- the prompter- Throws:
org.apache.maven.plugin.MojoExecutionException- when things go wrong
-
-
Method Details
-
getAllowSnapshots
protected boolean getAllowSnapshots()Description copied from class:AbstractVersionsUpdaterMojotrueif snapshots should be allowed when searching for newer versions of artifacts. This can be overridden on a per-call basis by passing a non-nullvalue to theAbstractVersionsUpdaterMojo.findLatestVersion(Artifact, VersionRange, Boolean, boolean)method. Default isfalsefor all Mojos exceptversions:use-latest-versionsandversions:use-latest-releaseswhere it istrue- Specified by:
getAllowSnapshotsin classAbstractVersionsUpdaterMojo- Returns:
trueif snapshots should be allowed when searching for newer versions of artifacts.- See Also:
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionExceptionCalled when this mojo is executed.- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Overrides:
executein classAbstractVersionsUpdaterMojo- Throws:
org.apache.maven.plugin.MojoExecutionException- 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:
updatein 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.
-