Class CreateMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.build.AbstractScmMojo
org.codehaus.mojo.build.CreateMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="create", defaultPhase=INITIALIZE, requiresProject=true, threadSafe=true) public class CreateMojo extends AbstractScmMojo
This mojo is designed to give you a build number. So when you might make 100 builds of version 1.0-SNAPSHOT, you can differentiate between them all.

The build number is based on the revision number retrieved from SCM. It is known to work with Subversion, GIT, and Mercurial.

This mojo can also check to make sure that you have checked everything into SCM, before issuing the build number. That behaviour can be suppressed, and then the latest local build number is used.

Build numbers are not automatically reflected in your artifact's filename, but can be added to the metadata. You can access the build number in your pom with ${buildNumber}. You can also access ${timestamp} and the SCM branch of the build (if applicable) in ${scmBranch}

Note that there are several doFoo parameters. These parameters (doCheck, doUpdate, etc) are the first thing evaluated. If there is no matching expression, we get the default-value. If there is (ie -Dmaven.buildNumber.doUpdate=false), we get that value. So if the XML contains <doCheck>true</doCheck>, then normally that's the final value of the param in question. However, this mojo reverses that behaviour, such that the command line parameters get the last say.

Author:
Julian Wood
  • Constructor Details

    • CreateMojo

      public CreateMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • update

      public List<org.apache.maven.scm.ScmFile> update() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getStatus

      public List<org.apache.maven.scm.ScmFile> getStatus() throws org.apache.maven.scm.ScmException
      Throws:
      org.apache.maven.scm.ScmException
    • getScmBranch

      public String getScmBranch() throws org.apache.maven.plugin.MojoExecutionException
      Get the branch info for this revision from the repository. For svn, it is in svn info.
      Returns:
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoExecutionException
    • filterBranchFromScmUrl

      protected String filterBranchFromScmUrl(String scmUrl)
    • getRevision

      public String getRevision() throws org.apache.maven.plugin.MojoExecutionException
      Get the revision info from the repository. For svn, it is svn info
      Returns:
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • setScmManager

      public void setScmManager(org.apache.maven.scm.manager.ScmManager scmManager)
    • setUrlScm

      public void setUrlScm(String urlScm)
    • setUsername

      public void setUsername(String username)
    • setPassword

      public void setPassword(String password)
    • setDoCheck

      public void setDoCheck(boolean doCheck)
    • setDoUpdate

      public void setDoUpdate(boolean doUpdate)
    • setBuildNumberPropertiesFileLocation

      public void setBuildNumberPropertiesFileLocation(File buildNumberPropertiesFileLocation)
    • setScmDirectory

      public void setScmDirectory(File scmDirectory)
    • setRevisionOnScmFailure

      public void setRevisionOnScmFailure(String revisionOnScmFailure)
    • setShortRevisionLength

      public void setShortRevisionLength(int shortRevision)