Class AbstractAnalyzeMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.dependency.analyze.AbstractAnalyzeMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Direct Known Subclasses:
AnalyzeMojo, AnalyzeOnlyMojo

public abstract class AbstractAnalyzeMojo extends org.apache.maven.plugin.AbstractMojo implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.
Since:
2.0-alpha-5
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Specify the project dependency analyzer to use (plexus component role-hint).
    private File
    Flag to use for scriptable output
    private org.codehaus.plexus.context.Context
    The plexus context to look-up the right ProjectDependencyAnalyzer implementation depending on the mojo configuration.
    private boolean
    Whether to fail the build if a dependency warning is found.
    private String[]
    List of dependencies that will be ignored.
    private String[]
    List of dependencies that will be ignored if they are declared but unused.
    private String[]
    List of dependencies that will be ignored if they are used but undeclared.
    private boolean
    Ignore Runtime/Provided/Test/System scopes for unused dependency analysis.
    private File
    Target folder
    private boolean
    Output the xml for the missing dependencies (used but not declared).
    private org.apache.maven.project.MavenProject
    The Maven project to analyze.
    private String
    Flag to use for scriptable output.
    private boolean
    Output scriptable values for the missing dependencies (used but not declared).
    private boolean
    Skip plugin execution completely.
    private String[]
    Force dependencies as used, to override incomplete result caused by bytecode-level analysis.
    private boolean
    Output used dependencies.

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
     
    void
    contextualize(org.codehaus.plexus.context.Context theContext)
     
    protected org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer
     
    void
     
    private List<org.apache.maven.artifact.Artifact>
    filterDependencies(Set<org.apache.maven.artifact.Artifact> artifacts, String[] excludes)
     
    protected final boolean
     
    private void
    logArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts, boolean warn)
     
    private void
    writeDependencyXML(Set<org.apache.maven.artifact.Artifact> artifacts)
     
    private void
    writeScriptableOutput(Set<org.apache.maven.artifact.Artifact> artifacts)
     

    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 Details

    • context

      private org.codehaus.plexus.context.Context context
      The plexus context to look-up the right ProjectDependencyAnalyzer implementation depending on the mojo configuration.
    • project

      @Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject project
      The Maven project to analyze.
    • analyzer

      @Parameter(property="analyzer", defaultValue="default") private String analyzer
      Specify the project dependency analyzer to use (plexus component role-hint). By default, maven-dependency-analyzer is used. To use this, you must declare a dependency for this plugin that contains the code for the analyzer. The analyzer must have a declared Plexus role name, and you specify the role name here.
      Since:
      2.2
    • failOnWarning

      @Parameter(property="failOnWarning", defaultValue="false") private boolean failOnWarning
      Whether to fail the build if a dependency warning is found.
    • verbose

      @Parameter(property="verbose", defaultValue="false") private boolean verbose
      Output used dependencies.
    • ignoreNonCompile

      @Parameter(property="ignoreNonCompile", defaultValue="false") private boolean ignoreNonCompile
      Ignore Runtime/Provided/Test/System scopes for unused dependency analysis.
    • outputXML

      @Parameter(property="outputXML", defaultValue="false") private boolean outputXML
      Output the xml for the missing dependencies (used but not declared).
      Since:
      2.0-alpha-5
    • scriptableOutput

      @Parameter(property="scriptableOutput", defaultValue="false") private boolean scriptableOutput
      Output scriptable values for the missing dependencies (used but not declared).
      Since:
      2.0-alpha-5
    • scriptableFlag

      @Parameter(property="scriptableFlag", defaultValue="$$$%%%") private String scriptableFlag
      Flag to use for scriptable output.
      Since:
      2.0-alpha-5
    • baseDir

      @Parameter(defaultValue="${basedir}", readonly=true) private File baseDir
      Flag to use for scriptable output
      Since:
      2.0-alpha-5
    • outputDirectory

      @Parameter(defaultValue="${project.build.directory}", readonly=true) private File outputDirectory
      Target folder
      Since:
      2.0-alpha-5
    • usedDependencies

      @Parameter private String[] usedDependencies
      Force dependencies as used, to override incomplete result caused by bytecode-level analysis. Dependency format is groupId:artifactId.
      Since:
      2.6
    • skip

      @Parameter(property="mdep.analyze.skip", defaultValue="false") private boolean skip
      Skip plugin execution completely.
      Since:
      2.7
    • ignoredDependencies

      @Parameter private String[] ignoredDependencies
      List of dependencies that will be ignored. Any dependency on this list will be excluded from the "declared but unused" and the "used but undeclared" list. The filter syntax is:
       [groupId]:[artifactId]:[type]:[version]
       
      where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard. *

      For example, org.apache.* will match all artifacts whose group id starts with org.apache., and :::*-SNAPSHOT will match all snapshot artifacts.

      Since:
      2.10
    • ignoredUsedUndeclaredDependencies

      @Parameter private String[] ignoredUsedUndeclaredDependencies
      List of dependencies that will be ignored if they are used but undeclared. The filter syntax is:
       [groupId]:[artifactId]:[type]:[version]
       
      where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard. *

      For example, org.apache.* will match all artifacts whose group id starts with org.apache., and :::*-SNAPSHOT will match all snapshot artifacts.

      Since:
      2.10
    • ignoredUnusedDeclaredDependencies

      @Parameter private String[] ignoredUnusedDeclaredDependencies
      List of dependencies that will be ignored if they are declared but unused. The filter syntax is:
       [groupId]:[artifactId]:[type]:[version]
       
      where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard. *

      For example, org.apache.* will match all artifacts whose group id starts with org.apache., and :::*-SNAPSHOT will match all snapshot artifacts.

      Since:
      2.10
  • Constructor Details

    • AbstractAnalyzeMojo

      public AbstractAnalyzeMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • createProjectDependencyAnalyzer

      protected org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer createProjectDependencyAnalyzer() throws org.apache.maven.plugin.MojoExecutionException
      Returns:
      ProjectDependencyAnalyzer
      Throws:
      org.apache.maven.plugin.MojoExecutionException - in case of an error.
    • contextualize

      public void contextualize(org.codehaus.plexus.context.Context theContext) throws org.codehaus.plexus.context.ContextException
      Specified by:
      contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
      Throws:
      org.codehaus.plexus.context.ContextException
    • isSkip

      protected final boolean isSkip()
      Returns:
      skip
    • checkDependencies

      private boolean checkDependencies() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • logArtifacts

      private void logArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts, boolean warn)
    • writeDependencyXML

      private void writeDependencyXML(Set<org.apache.maven.artifact.Artifact> artifacts)
    • writeScriptableOutput

      private void writeScriptableOutput(Set<org.apache.maven.artifact.Artifact> artifacts)
    • filterDependencies

      private List<org.apache.maven.artifact.Artifact> filterDependencies(Set<org.apache.maven.artifact.Artifact> artifacts, String[] excludes) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException