Class CreateMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
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
-
Field Summary
Fields inherited from class org.codehaus.mojo.build.AbstractScmMojo
password, project, revisionOnScmFailure, scmConnectionUrl, scmDeveloperConnectionUrl, scmDirectory, scmManager, scmTag, settings, shortRevisionLength, skip, username
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
protected String
filterBranchFromScmUrl
(String scmUrl) Get the revision info from the repository.Get the branch info for this revision from the repository.List
<org.apache.maven.scm.ScmFile> void
setBuildNumberPropertiesFileLocation
(File buildNumberPropertiesFileLocation) void
setDoCheck
(boolean doCheck) void
setDoUpdate
(boolean doUpdate) void
setPassword
(String password) void
setRevisionOnScmFailure
(String revisionOnScmFailure) void
setScmDirectory
(File scmDirectory) void
setScmManager
(org.apache.maven.scm.manager.ScmManager scmManager) void
setShortRevisionLength
(int shortRevision) void
void
setUsername
(String username) List
<org.apache.maven.scm.ScmFile> update()
Methods inherited from class org.codehaus.mojo.build.AbstractScmMojo
checkResult, getScmRepository, getScmRevision, info
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
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
- Throws:
org.apache.maven.scm.ScmException
-
getScmBranch
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
-
getRevision
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
-
setUsername
-
setPassword
-
setDoCheck
public void setDoCheck(boolean doCheck) -
setDoUpdate
public void setDoUpdate(boolean doUpdate) -
setBuildNumberPropertiesFileLocation
-
setScmDirectory
-
setRevisionOnScmFailure
-
setShortRevisionLength
public void setShortRevisionLength(int shortRevision)
-