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 AbstractScmMojo
This 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 Details

    • applicationName

      @Parameter(defaultValue="${project.name}") private String applicationName
      Application name
      Since:
      1.4
    • applicationPropertyName

      @Parameter(defaultValue="name") private String applicationPropertyName
      Java property name to store the project name
      Since:
      1.4
    • versionPropertyName

      @Parameter(defaultValue="version") private String versionPropertyName
      Java property name to store the project version
      Since:
      1.4
    • version

      @Parameter(defaultValue="${project.version}") private String version
      Version
      Since:
      1.4
    • revisionPropertyName

      @Parameter(defaultValue="revision") private String revisionPropertyName
      Java property name to store the discovered SCM revision value
      Since:
      1.4
    • timestampPropertyName

      @Parameter(defaultValue="timestamp") private String timestampPropertyName
      Java property name to store the discovered timestamp value
      Since:
      1.4
    • timestampFormat

      @Parameter(property="maven.build.timestamp.format") private 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 String timezone
      The timezone of the generated timestamp. If blank will default to TimeZone.getDefault()
    • outputDirectory

      @Parameter(defaultValue="${project.build.directory}/generated/build-metadata", required=true) private File outputDirectory
      Output directory
      Since:
      1.4
    • outputName

      @Parameter(defaultValue="build.properties", required=true) private String outputName
      Output 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 String classifier
      Artifact classifier name when deploying to Maven repository
      Since:
      3.0
    • outputFiles

      @Parameter private List<File> outputFiles
      Additional output files
      Since:
      1.4
    • properties

      @Parameter private Map<String,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.
  • Constructor Details

    • CreateMetadataMojo

      public CreateMetadataMojo()
  • 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
    • writeToFile

      private void writeToFile(Properties props, File file) throws org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • writeToFile

      private void writeToFile(Properties props, File file, OutputFormat outputFormat) throws IOException
      Throws:
      IOException
    • getRevision

      public String getRevision() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException