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 -DnextSnapshotIndexToIncrement=1 and the version being 1.2.3-SNAPSHOT, the new version will become 2.2.3-SNAPSHOT.

      Only valid with nextSnapshot.

      Since:
      2.12
    • projectBuilder

      protected final org.apache.maven.project.ProjectBuilder projectBuilder
      The (injected) instance of ProjectBuilder
      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.MojoFailureException
      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.
      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 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.