Class ScmMetadataMavenPluginMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="metadata",
          defaultPhase=INITIALIZE)
    public class ScmMetadataMavenPluginMojo
    extends org.apache.maven.plugin.AbstractMojo
    Generates metadata about the project's SCM, and injects it into the build context as Maven Properties for re-use by other plugins.

    Metadata Calculated:

    • revision - the current project revision (e.g. git commit SHA)
    • revision.short - a potentially truncated version of the revision property
    • branch - the current SCM branch (e.g. master)
    • dirty - true if there are any uncommitted local changes in files which are not excluded from SCM, false otherwise (equivalent to checking git status --porcelain)

    Remote Path Segment Properties

    Additionally, properties prefixed with remote.path.segment will be injected for each path segment in the scm.developerConnection configuration (or scm.connection if scm.developerConnection is not set). Each segment can be accessed by its positive 0 based index in the path, as well as a negative index based on its position relative to the end of the path (i.e. the last path segment can be accessed at index -1, the second to last at -2, etc...).

    For example, the elements of the path /alpha/bravo can be accessed via the following indices:
    SegmentIndexNegative Index
    alpha0-2
    bravo1-1
    See the remotePathNotation configuration for details about the format of the remote.path.segment properties.

    Property Prefix

    Note that the name of each property is prefixed with the value of the prefix configuration option, meaning the properties set when using the default configuration are:
    • scm.metadata.revision
    • scm.metadata.revision.short
    • scm.metadata.branch
    • scm.metadata.dirty
    • scm.metadata.remote.path.segment[*]
    Since:
    1.0
    • Field Detail

      • project

        @Parameter(defaultValue="${project}",
                   required=true,
                   readonly=true)
        protected org.apache.maven.project.MavenProject project
        Maven project
        Since:
        1.0
    • Constructor Detail

      • ScmMetadataMavenPluginMojo

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