Class 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 Detail

      • applicationName

        @Parameter(defaultValue="${project.name}")
        private java.lang.String applicationName
        Application 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 version
        Version
        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 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 java.io.File outputDirectory
        Output directory
        Since:
        1.4
      • outputName

        @Parameter(defaultValue="build.properties",
                   required=true)
        private java.lang.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 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.
    • Constructor Detail

      • CreateMetadataMojo

        public CreateMetadataMojo()
    • Method Detail

      • 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​(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