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
- Direct Known Subclasses:
AnalyzeMojo,AnalyzeOnlyMojo
public abstract class AbstractAnalyzeMojo
extends org.apache.maven.plugin.AbstractMojo
Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused
and declared; compile scoped but only used in tests.
- Since:
- 2.0-alpha-5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringSpecify the project dependency analyzer to use (plexus component role-hint).private FileFlag to use for scriptable outputList Excluded classes patterns from analyze.private booleanWhether to fail the build if a dependency warning is found.private booleanIgnore all dependencies that are used only in test but not test-scoped.private String[]List of dependencies that will be ignored.private String[]List of dependencies that will be ignored if they are in not test scope but are only used in test classes.List of project packaging 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 booleanIgnore Runtime/Provided/Test/System scopes for unused dependency analysis.private booleanIgnore Runtime scope for unused dependency analysis.private FileTarget folderprivate booleanOutput the xml for the missing dependencies (used but not declared).private org.codehaus.plexus.PlexusContainerThe plexusContainer to look-up the rightProjectDependencyAnalyzerimplementation depending on the mojo configuration.private org.apache.maven.project.MavenProjectThe Maven project to analyze.private StringFlag to use for scriptable output.private booleanOutput scriptable values for the missing dependencies (used but not declared).private booleanSkip plugin execution completely.private String[]Force dependencies as used, to override incomplete result caused by bytecode-level analysis.private booleanOutput used dependencies.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanprotected org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzervoidexecute()private voidfilterArtifactsByScope(Set<org.apache.maven.artifact.Artifact> artifacts, String scope) private List<org.apache.maven.artifact.Artifact> filterDependencies(Set<org.apache.maven.artifact.Artifact> artifacts, String[] excludes) protected final booleanisSkip()private voidlogArtifacts(Map<org.apache.maven.artifact.Artifact, Set<String>> artifacts, boolean warn) private voidlogArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts, boolean warn) private voidlogDependencyWarning(CharSequence content) private voidwriteDependencyXML(Set<org.apache.maven.artifact.Artifact> artifacts) private voidwriteScriptableOutput(Set<org.apache.maven.artifact.Artifact> artifacts) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
plexusContainer
@Component private org.codehaus.plexus.PlexusContainer plexusContainerThe plexusContainer to look-up the rightProjectDependencyAnalyzerimplementation depending on the mojo configuration. -
project
@Component private org.apache.maven.project.MavenProject projectThe Maven project to analyze. -
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 failOnWarningWhether to fail the build if a dependency warning is found. -
verbose
@Parameter(property="verbose", defaultValue="false") private boolean verboseOutput used dependencies. -
ignoreNonCompile
@Parameter(property="ignoreNonCompile", defaultValue="false") private boolean ignoreNonCompileIgnore Runtime/Provided/Test/System scopes for unused dependency analysis.Non-test scopedlist will be not affected. -
ignoreUnusedRuntime
@Parameter(property="ignoreUnusedRuntime", defaultValue="false") private boolean ignoreUnusedRuntimeIgnore Runtime scope for unused dependency analysis.- Since:
- 3.2.0
-
ignoreAllNonTestScoped
@Parameter(property="ignoreAllNonTestScoped", defaultValue="false") private boolean ignoreAllNonTestScopedIgnore all dependencies that are used only in test but not test-scoped. Setting this flag has the same effect as adding all dependencies that have been flagged with the Non-test scoped test only dependencies found warning to the<ignoredNonTestScopedDependencies>configuration.- Since:
- 3.3.1-SNAPSHOT
-
outputXML
@Parameter(property="outputXML", defaultValue="false") private boolean outputXMLOutput the xml for the missing dependencies (used but not declared).- Since:
- 2.0-alpha-5
-
scriptableOutput
@Parameter(property="scriptableOutput", defaultValue="false") private boolean scriptableOutputOutput scriptable values for the missing dependencies (used but not declared).- Since:
- 2.0-alpha-5
-
scriptableFlag
Flag to use for scriptable output.- Since:
- 2.0-alpha-5
-
baseDir
Flag to use for scriptable output- Since:
- 2.0-alpha-5
-
outputDirectory
Target folder- Since:
- 2.0-alpha-5
-
usedDependencies
Force dependencies as used, to override incomplete result caused by bytecode-level analysis. Dependency format isgroupId:artifactId.- Since:
- 2.6
-
skip
@Parameter(property="mdep.analyze.skip", defaultValue="false") private boolean skipSkip plugin execution completely.- Since:
- 2.7
-
ignoredDependencies
List of dependencies that will be ignored. Any dependency on this list will be excluded from the "declared but unused", the "used but undeclared", and the "non-test scoped" 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 withorg.apache., and:::*-SNAPSHOTwill match all snapshot artifacts.- Since:
- 2.10
-
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 withorg.apache., and:::*-SNAPSHOTwill match all snapshot artifacts.- Since:
- 2.10
-
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 withorg.apache., and:::*-SNAPSHOTwill match all snapshot artifacts.- Since:
- 2.10
-
ignoredNonTestScopedDependencies
List of dependencies that will be ignored if they are in not test scope but are only used in test classes. 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 withorg.apache., and:::*-SNAPSHOTwill match all snapshot artifacts.- Since:
- 3.3.0
-
ignoredPackagings
List of project packaging that will be ignored.
Default value is:pom, ear- Since:
- 3.2.1
-
excludedClasses
List Excluded classes patterns from analyze. Java regular expression pattern is applied to full class name.- Since:
- 3.7.0
-
-
Constructor Details
-
AbstractAnalyzeMojo
public AbstractAnalyzeMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.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.
-
isSkip
protected final boolean isSkip()- Returns:
skip
-
checkDependencies
private boolean checkDependencies() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
filterArtifactsByScope
-
logArtifacts
-
logArtifacts
-
logDependencyWarning
-
writeDependencyXML
-
writeScriptableOutput
-
filterDependencies
-