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 AbstractScmMojoThis 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
doFooparameters. 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
-
-
Field Summary
-
Fields inherited from class org.codehaus.mojo.build.AbstractScmMojo
password, project, revisionOnScmFailure, scmConnectionUrl, scmDeveloperConnectionUrl, scmDirectory, scmManager, scmTag, settings, shortRevisionLength, skip, username
-
-
Constructor Summary
Constructors Constructor Description CreateMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()protected StringfilterBranchFromScmUrl(String scmUrl)StringgetRevision()Get the revision info from the repository.StringgetScmBranch()Get the branch info for this revision from the repository.List<org.apache.maven.scm.ScmFile>getStatus()voidsetBuildNumberPropertiesFileLocation(File buildNumberPropertiesFileLocation)voidsetDoCheck(boolean doCheck)voidsetDoUpdate(boolean doUpdate)voidsetFailTheBuild(boolean failTheBuild)voidsetPassword(String password)voidsetRevisionOnScmFailure(String revisionOnScmFailure)voidsetScmDirectory(File scmDirectory)voidsetScmManager(org.apache.maven.scm.manager.ScmManager scmManager)voidsetShortRevisionLength(int shortRevision)voidsetUrlScm(String urlScm)voidsetUsername(String username)List<org.apache.maven.scm.ScmFile>update()-
Methods inherited from class org.codehaus.mojo.build.AbstractScmMojo
checkResult, getScmRepository, getScmRevision, info
-
-
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.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.MojoExecutionExceptionorg.apache.maven.plugin.MojoExecutionException
-
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)
-
setFailTheBuild
public void setFailTheBuild(boolean failTheBuild)
-
-