Package org.codehaus.mojo.build
Class CreateMetadataMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.build.AbstractScmMojo
-
- org.codehaus.mojo.build.CreateMetadataMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="create-metadata", defaultPhase=GENERATE_RESOURCES, requiresProject=true, threadSafe=true) public class CreateMetadataMojo extends AbstractScmMojoThis mojo discovers latest SCM revision, current timestamp, project version, and project name then write them to one or more java property files together with a set of user provided properties. It also has option to add the output file to resource classpath for jar packaging.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanaddOutputDirectoryToResourcesAdd outputDirectory to java resource so that outputName will be under runtime classpath.private java.lang.StringapplicationNameApplication nameprivate java.lang.StringapplicationPropertyNameJava property name to store the project nameprivate booleanattachInstall/Deploy to Maven repositoryprivate booleanautoDetectOutputFormatEnable output format detection.private java.lang.StringclassifierArtifact classifier name when deploying to Maven repositoryprivate java.io.FileoutputDirectoryOutput directoryprivate java.util.List<java.io.File>outputFilesAdditional output filesprivate java.lang.StringoutputNameOutput file nameprivate org.apache.maven.project.MavenProjectHelperprojectHelperMaven ProjectHelper.private java.util.Map<java.lang.String,java.lang.String>propertiesAdditional properties to write outprivate java.lang.StringrevisionPropertyNameJava property name to store the discovered SCM revision valueprivate java.lang.StringtimestampFormatjava.text.SimpleDateFormat for the discover timestamp, if not given use long integer formatprivate java.lang.StringtimestampPropertyNameJava property name to store the discovered timestamp valueprivate java.lang.StringtimezoneThe timezone of the generated timestamp.private java.lang.StringversionVersionprivate java.lang.StringversionPropertyNameJava property name to store the project version-
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 CreateMetadataMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()java.lang.StringgetRevision()private voidwriteToFile(java.util.Properties props, java.io.File file)private voidwriteToFile(java.util.Properties props, java.io.File file, OutputFormat outputFormat)-
Methods inherited from class org.codehaus.mojo.build.AbstractScmMojo
checkResult, getScmRepository, getScmRevision, info
-
-
-
-
Field Detail
-
applicationName
@Parameter(defaultValue="${project.name}") private java.lang.String applicationNameApplication name- Since:
- 1.4
-
applicationPropertyName
@Parameter(defaultValue="name") private java.lang.String applicationPropertyName
Java property name to store the project name- Since:
- 1.4
-
versionPropertyName
@Parameter(defaultValue="version") private java.lang.String versionPropertyName
Java property name to store the project version- Since:
- 1.4
-
version
@Parameter(defaultValue="${project.version}") private java.lang.String versionVersion- Since:
- 1.4
-
revisionPropertyName
@Parameter(defaultValue="revision") private java.lang.String revisionPropertyName
Java property name to store the discovered SCM revision value- Since:
- 1.4
-
timestampPropertyName
@Parameter(defaultValue="timestamp") private java.lang.String timestampPropertyName
Java property name to store the discovered timestamp value- Since:
- 1.4
-
timestampFormat
@Parameter(property="maven.build.timestamp.format") private java.lang.String timestampFormat
java.text.SimpleDateFormat for the discover timestamp, if not given use long integer format- Since:
- 1.4
-
timezone
@Parameter(property="maven.buildNumber.timestampTimeZone", defaultValue="") private java.lang.String timezoneThe timezone of the generated timestamp. If blank will default toTimeZone.getDefault()
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}/generated/build-metadata", required=true) private java.io.File outputDirectoryOutput directory- Since:
- 1.4
-
outputName
@Parameter(defaultValue="build.properties", required=true) private java.lang.String outputNameOutput file name- Since:
- 1.4
-
addOutputDirectoryToResources
@Parameter(defaultValue="false") private boolean addOutputDirectoryToResources
Add outputDirectory to java resource so that outputName will be under runtime classpath. outputName can contain '/'- Since:
- 1.4
-
attach
@Parameter(defaultValue="false") private boolean attach
Install/Deploy to Maven repository- Since:
- 1.4
-
classifier
@Parameter(defaultValue="build") private java.lang.String classifier
Artifact classifier name when deploying to Maven repository- Since:
- 3.0
-
outputFiles
@Parameter private java.util.List<java.io.File> outputFiles
Additional output files- Since:
- 1.4
-
properties
@Parameter private java.util.Map<java.lang.String,java.lang.String> properties
Additional properties to write out- Since:
- 1.4
-
autoDetectOutputFormat
@Parameter(defaultValue="false") private boolean autoDetectOutputFormat
Enable output format detection. (Disabled per default for compatibility.)- Since:
- 3.0
-
projectHelper
@Component private org.apache.maven.project.MavenProjectHelper projectHelper
Maven ProjectHelper.
-
-
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
-
writeToFile
private void writeToFile(java.util.Properties props, java.io.File file) throws org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoFailureException
-
writeToFile
private void writeToFile(java.util.Properties props, java.io.File file, OutputFormat outputFormat) throws java.io.IOException- Throws:
java.io.IOException
-
getRevision
public java.lang.String getRevision() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
-