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 Details

    • nextSnapshot

      @Parameter(property="nextSnapshot", defaultValue="false") protected boolean nextSnapshot
      Whether to add next version number and -SNAPSHOT to the existing version. Unless specified by nextSnapshotIndexToIncrement, will increment the last minor index of the snapshot version, e.g. the z in x.y.z-SNAPSHOT
      Since:
      2.10
    • nextSnapshotIndexToIncrement

      @Parameter(property="nextSnapshotIndexToIncrement") protected Integer 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 allowSnapshots
      Whether 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 projectBuilder
      The (injected) instance of ProjectBuilder
      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 factory
      repositorySystem - the repository system
      projectBuilder - the project builder
      wagonMap - the map of wagon implementations
      changeRecorders - the change recorders
      prompter - the prompter
      Throws:
      org.apache.maven.plugin.MojoExecutionException - when things go wrong
  • Method Details

    • getAllowSnapshots

      protected boolean getAllowSnapshots()
      Description copied from class: AbstractVersionsUpdaterMojo
      true if snapshots should be allowed when searching for newer versions of artifacts. This can be overridden on a per-call basis by passing a non-null value to the AbstractVersionsUpdaterMojo.findLatestVersion(Artifact, VersionRange, Boolean, boolean) method. Default is false for all Mojos except versions:use-latest-versions and versions:use-latest-releases where it is true
      Specified by:
      getAllowSnapshots in class AbstractVersionsUpdaterMojo
      Returns:
      true if snapshots should be allowed when searching for newer versions of artifacts.
      See Also:
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Called when this mojo is executed.
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Overrides:
      execute in class AbstractVersionsUpdaterMojo
      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 version
      nextSnapshotIndexToIncrement - 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 class AbstractVersionsUpdaterMojo
      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.