Class DescriptorGeneratorMojo

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

    @Mojo(name="descriptor",
          defaultPhase=PROCESS_CLASSES,
          requiresDependencyResolution=COMPILE_PLUS_RUNTIME,
          threadSafe=true)
    public class DescriptorGeneratorMojo
    extends AbstractGeneratorMojo

    Generate a plugin descriptor.

    Note: Since 3.0, for Java plugin annotations support, default phase defined by this goal is after the "compilation" of any scripts. This doesn't override the default binding coded at generate-resources phase in Maven core.

    Since:
    2.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.sonatype.plexus.build.incremental.BuildContext buildContext  
      private boolean checkExpectedProvidedScope
      Flag controlling is "expected dependencies in provided scope" check to be performed or not.
      private java.lang.String encoding
      The file encoding of the source files.
      private java.util.List<java.lang.String> expectedProvidedScopeExclusions
      List of groupId:artifactId strings of artifact coordinates that are to be excluded from "expected provided scope" check.
      private java.util.List<java.lang.String> expectedProvidedScopeGroupIds
      List of groupId strings of artifact coordinates that are expected to be in "provided" scope.
      protected java.util.List<java.net.URI> externalJavadocBaseUrls
      Creates links to existing external javadoc-generated documentation.
      private java.util.Set<java.lang.String> extractors
      The role names of mojo extractors to use.
      protected java.net.URI internalJavadocBaseUrl
      The base URL for the Javadoc site containing the current project's API documentation.
      protected java.lang.String internalJavadocVersion
      The version of the javadoc tool (equal to the container JDK version) used to generate the internal javadoc Only relevant if internalJavadocBaseUrl is set.
      private org.apache.maven.execution.MavenSession mavenSession  
      private java.util.List<java.lang.String> mojoDependencies
      Specify the dependencies as groupId:artifactId containing (abstract) Mojos, to filter dependencies scanned at runtime and focus on dependencies that are really useful to Mojo analysis.
      private org.apache.maven.tools.plugin.scanner.MojoScanner mojoScanner
      The component used for scanning the source tree for mojos.
      private java.io.File outputDirectory
      The directory where the generated plugin.xml file will be put.
      (package private) java.lang.String requiredJavaVersion
      The required Java version to set in the plugin descriptor.
      (package private) java.lang.String requiredMavenVersion
      The required Maven version to set in the plugin descriptor.
      private boolean skipDescriptor
      A flag to disable generation of the plugin.xml in favor of a hand authored plugin descriptor.
      private boolean skipErrorNoDescriptorsFound
      By default, an exception is throw if no mojo descriptor is found.
      private static java.lang.String VALUE_AUTO  
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.util.Set<org.apache.maven.artifact.Artifact> dependenciesNotInProvidedScope()
      Collects all dependencies expected to be in "provided" scope but are NOT in "provided" scope.
      private org.apache.maven.plugin.descriptor.PluginDescriptor extendPluginDescriptor​(org.apache.maven.tools.plugin.PluginToolsRequest request)  
      private java.util.Set<org.apache.maven.artifact.Artifact> filterMojoDependencies()
      Get dependencies filtered with mojoDependencies configuration.
      void generate()  
      private java.lang.String getRequiredJavaVersion​(org.apache.maven.tools.plugin.PluginToolsRequest request)  
      private java.lang.String getRequiredMavenVersion​(org.apache.maven.tools.plugin.PluginToolsRequest request)  
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • outputDirectory

        @Parameter(defaultValue="${project.build.outputDirectory}/META-INF/maven",
                   readonly=true)
        private java.io.File outputDirectory
        The directory where the generated plugin.xml file will be put.
      • encoding

        @Parameter(property="encoding",
                   defaultValue="${project.build.sourceEncoding}")
        private java.lang.String encoding
        The file encoding of the source files.
        Since:
        2.5
      • skipDescriptor

        @Parameter(defaultValue="false")
        private boolean skipDescriptor
        A flag to disable generation of the plugin.xml in favor of a hand authored plugin descriptor.
        Since:
        2.6
      • extractors

        @Parameter
        private java.util.Set<java.lang.String> extractors

        The role names of mojo extractors to use.

        If not set, all mojo extractors will be used. If set to an empty extractor name, no mojo extractors will be used.

        Example:
          <!-- Use all mojo extractors -->
          <extractors/>
        
          <!-- Use no mojo extractors -->
          <extractors>
              <extractor/>
          </extractors>
        
          <!-- Use only bsh mojo extractor -->
          <extractors>
              <extractor>bsh</extractor>
          </extractors>
         
        The extractors with the following names ship with maven-plugin-tools:
        1. java-annotations
        2. java-javadoc, deprecated
        3. ant, deprecated
        4. bsh, deprecated
      • skipErrorNoDescriptorsFound

        @Parameter(property="maven.plugin.skipErrorNoDescriptorsFound",
                   defaultValue="false")
        private boolean skipErrorNoDescriptorsFound
        By default, an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the descriptor generator mojo is bound to generate-resources phase. But for annotations, the compiled classes are needed, so skip error
        Since:
        3.0
      • checkExpectedProvidedScope

        @Parameter(defaultValue="true",
                   property="maven.plugin.checkExpectedProvidedScope")
        private boolean checkExpectedProvidedScope
        Flag controlling is "expected dependencies in provided scope" check to be performed or not. Default value: true.
        Since:
        3.6.3
      • expectedProvidedScopeGroupIds

        @Parameter
        private java.util.List<java.lang.String> expectedProvidedScopeGroupIds
        List of groupId strings of artifact coordinates that are expected to be in "provided" scope. Default value: ["org.apache.maven"].
        Since:
        3.6.3
      • expectedProvidedScopeExclusions

        @Parameter
        private java.util.List<java.lang.String> expectedProvidedScopeExclusions
        List of groupId:artifactId strings of artifact coordinates that are to be excluded from "expected provided scope" check. Default value: ["org.apache.maven:maven-archiver", "org.apache.maven:maven-jxr", "org.apache.maven:plexus-utils"].
        Since:
        3.6.3
      • mojoDependencies

        @Parameter
        private java.util.List<java.lang.String> mojoDependencies
        Specify the dependencies as groupId:artifactId containing (abstract) Mojos, to filter dependencies scanned at runtime and focus on dependencies that are really useful to Mojo analysis. By default, the value is null and all dependencies are scanned (as before this parameter was added). If specified in the configuration with no children, no dependencies are scanned.
        Since:
        3.5
      • externalJavadocBaseUrls

        @Parameter(property="externalJavadocBaseUrls",
                   alias="links")
        protected java.util.List<java.net.URI> externalJavadocBaseUrls
        Creates links to existing external javadoc-generated documentation.
        Notes: all given links should have a fetchable /package-list or /element-list file. For instance:
         <externalJavadocBaseUrls>
           <externalJavadocBaseUrl>https://docs.oracle.com/javase/8/docs/api/</externalJavadocBaseUrl>
         </externalJavadocBaseUrls>
         
        is valid because https://docs.oracle.com/javase/8/docs/api/package-list exists. See link option of the javadoc tool. Using this parameter requires connectivity to the given URLs during the goal execution.
        Since:
        3.7.0
      • internalJavadocBaseUrl

        @Parameter(property="internalJavadocBaseUrl")
        protected java.net.URI internalJavadocBaseUrl
        The base URL for the Javadoc site containing the current project's API documentation. This may be relative to the root of the generated Maven site. It does not need to exist yet at the time when this goal is executed. Must end with a slash. In case this is set the javadoc reporting goal should be executed prior to Plugin Report.
        Since:
        3.7.0
      • internalJavadocVersion

        @Parameter(property="internalJavadocVersion",
                   defaultValue="${java.version}")
        protected java.lang.String internalJavadocVersion
        The version of the javadoc tool (equal to the container JDK version) used to generate the internal javadoc Only relevant if internalJavadocBaseUrl is set. The default value needs to be overwritten in case toolchains are being used for generating Javadoc.
        Since:
        3.7.0
      • mavenSession

        @Component
        private org.apache.maven.execution.MavenSession mavenSession
      • requiredJavaVersion

        @Parameter(defaultValue="auto")
        java.lang.String requiredJavaVersion
        The required Java version to set in the plugin descriptor. This is evaluated by Maven 4 and ignored by earlier Maven versions. Can be either one of the following formats:
        • A version range which specifies the supported Java versions. It can either use the usual mathematical syntax like "[1.7,9),[11,)" or use a single version like "1.8". The latter is a short form for "[1.8,)", i.e. denotes the minimum version required.
        • "auto" to determine the minimum Java version from the binary class version being generated during compilation (determined by the extractor).
        Since:
        3.8.0
      • requiredMavenVersion

        @Parameter(defaultValue="auto")
        java.lang.String requiredMavenVersion
        The required Maven version to set in the plugin descriptor. This is evaluated by Maven 4 and ignored by earlier Maven versions. Can be either one of the following formats:
        • A version range which specifies the supported Maven versions. It can either use the usual mathematical syntax like "[2.0.10,2.1.0),[3.0,)" or use a single version like "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required.
        • "auto" to determine the minimum Maven version from the POM's Maven prerequisite, or if not set the referenced Maven Plugin API version.
        This value takes precedence over the POM's Maven prerequisite in Maven 4.
        Since:
        3.8.0
      • mojoScanner

        @Component
        private org.apache.maven.tools.plugin.scanner.MojoScanner mojoScanner
        The component used for scanning the source tree for mojos.
      • buildContext

        @Component
        protected org.sonatype.plexus.build.incremental.BuildContext buildContext
    • Constructor Detail

      • DescriptorGeneratorMojo

        public DescriptorGeneratorMojo()
    • Method Detail

      • generate

        public void generate()
                      throws org.apache.maven.plugin.MojoExecutionException
        Specified by:
        generate in class AbstractGeneratorMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • extendPluginDescriptor

        private org.apache.maven.plugin.descriptor.PluginDescriptor extendPluginDescriptor​(org.apache.maven.tools.plugin.PluginToolsRequest request)
      • getRequiredMavenVersion

        private java.lang.String getRequiredMavenVersion​(org.apache.maven.tools.plugin.PluginToolsRequest request)
      • getRequiredJavaVersion

        private java.lang.String getRequiredJavaVersion​(org.apache.maven.tools.plugin.PluginToolsRequest request)
      • dependenciesNotInProvidedScope

        private java.util.Set<org.apache.maven.artifact.Artifact> dependenciesNotInProvidedScope()
        Collects all dependencies expected to be in "provided" scope but are NOT in "provided" scope.
      • filterMojoDependencies

        private java.util.Set<org.apache.maven.artifact.Artifact> filterMojoDependencies()
        Get dependencies filtered with mojoDependencies configuration.
        Returns:
        eventually filtered dependencies, or even null if configured with empty mojoDependencies list
        See Also:
        mojoDependencies