@Mojo(name="create",
defaultPhase=INITIALIZE,
requiresProject=true,
threadSafe=true)
public class CreateMojo
extends org.apache.maven.plugin.AbstractMojo
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.
Modifier and Type | Field and Description |
---|---|
protected org.apache.maven.execution.MavenSession |
session |
Constructor and Description |
---|
CreateMojo() |
Modifier and Type | Method and Description |
---|---|
void |
execute() |
protected String |
filterBranchFromScmUrl(String scmUrl) |
String |
getRevision()
Get the revision info from the repository.
|
String |
getScmBranch()
Get the branch info for this revision from the repository.
|
protected String |
getScmBranchFromUrl() |
List<org.apache.maven.scm.ScmFile> |
getStatus() |
org.apache.maven.scm.command.info.InfoScmResult |
info(org.apache.maven.scm.repository.ScmRepository repository,
org.apache.maven.scm.ScmFileSet fileSet)
Get info from scm.
|
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 |
setUrlScm(String urlScm) |
void |
setUsername(String username) |
List<org.apache.maven.scm.ScmFile> |
update() |
@Parameter(defaultValue="${session}", readonly=true, required=true) protected org.apache.maven.execution.MavenSession session
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
public List<org.apache.maven.scm.ScmFile> update() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
public List<org.apache.maven.scm.ScmFile> getStatus() throws org.apache.maven.scm.ScmException
org.apache.maven.scm.ScmException
public String getScmBranch() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected String getScmBranchFromUrl() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
public String getRevision() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
public org.apache.maven.scm.command.info.InfoScmResult info(org.apache.maven.scm.repository.ScmRepository repository, org.apache.maven.scm.ScmFileSet fileSet) throws org.apache.maven.scm.ScmException
repository
- fileSet
- org.apache.maven.scm.ScmException
public void setScmManager(org.apache.maven.scm.manager.ScmManager scmManager)
public void setUrlScm(String urlScm)
public void setUsername(String username)
public void setPassword(String password)
public void setDoCheck(boolean doCheck)
public void setDoUpdate(boolean doUpdate)
public void setBuildNumberPropertiesFileLocation(File buildNumberPropertiesFileLocation)
public void setScmDirectory(File scmDirectory)
public void setRevisionOnScmFailure(String revisionOnScmFailure)
public void setShortRevisionLength(int shortRevision)
Copyright © 2007–2021 MojoHaus. All rights reserved.