Class CreateMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- 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 org.apache.maven.plugin.AbstractMojoThis 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.- Version:
- $Id: CreateMojo.java 19675 2014-04-26 21:50:31Z baptiste $
- Author:
- Julian Wood
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.maven.execution.MavenSessionsession
-
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.protected StringgetScmBranchFromUrl()List<org.apache.maven.scm.ScmFile>getStatus()org.apache.maven.scm.command.info.InfoScmResultinfo(org.apache.maven.scm.repository.ScmRepository repository, org.apache.maven.scm.ScmFileSet fileSet)Get info from scm.voidsetBuildNumberPropertiesFileLocation(File buildNumberPropertiesFileLocation)voidsetDoCheck(boolean doCheck)voidsetDoUpdate(boolean doUpdate)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()
-
-
-
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
-
getScmBranchFromUrl
protected String getScmBranchFromUrl() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.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
-
info
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.ScmExceptionGet info from scm.- Parameters:
repository-fileSet-- Returns:
- Throws:
org.apache.maven.scm.ScmException
-
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)
-
-