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.AbstractMojoAnalyzes 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
Fields Modifier and Type Field Description private java.lang.StringanalyzerSpecify the project dependency analyzer to use (plexus component role-hint).private java.io.FilebaseDirFlag to use for scriptable output.private java.util.Set<java.lang.String>excludedClassesList of class patterns excluded from analyze.private booleanfailOnWarningWhether to fail the build if a dependency warning is found.private booleanignoreAllNonTestScopedIgnore all dependencies that are used only in test but not test-scoped.private java.lang.String[]ignoredDependenciesList of dependencies that will be ignored.private java.lang.String[]ignoredNonTestScopedDependenciesList of dependencies that are ignored if they are in not test scope but are only used in test classes.private java.util.List<java.lang.String>ignoredPackagingsList of project packaging that will be ignored.private java.lang.String[]ignoredUnusedDeclaredDependenciesList of dependencies that are ignored if they are declared but unused.private java.lang.String[]ignoredUsedUndeclaredDependenciesList of dependencies that will be ignored if they are used but undeclared.private booleanignoreNonCompileIgnore runtime/provided/test/system scopes for unused dependency analysis.private booleanignoreUnusedRuntimeIgnore runtime scope for unused dependency analysis.private java.io.FileoutputDirectoryTarget folder.private booleanoutputXMLOutput the xml for the missing dependencies (used but not declared).private org.codehaus.plexus.PlexusContainerplexusContainerThe plexusContainer to look up theProjectDependencyAnalyzerimplementation depending on the mojo configuration.private org.apache.maven.project.MavenProjectprojectThe Maven project to analyze.private java.lang.StringscriptableFlagFlag to use for scriptable output.private booleanscriptableOutputOutput scriptable values for the missing dependencies (used but not declared).private booleanskipSkip plugin execution completely.private java.lang.String[]unconditionallyIgnoredDeclaredDependenciesprivate java.lang.String[]usedDependenciesForce dependencies as used, to override incomplete result caused by bytecode-level analysis.private booleanverboseOutput used dependencies.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAnalyzeMojo(org.codehaus.plexus.PlexusContainer plexusContainer, org.apache.maven.project.MavenProject project)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleancheckDependencies()protected org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzercreateProjectDependencyAnalyzer()voidexecute()private voidfilterArtifactsByScope(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, java.lang.String scope)private java.util.Set<org.apache.maven.artifact.Artifact>filterDependencies(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, java.lang.String[] excludes)protected booleanisSkip()private voidlogArtifacts(java.util.Map<org.apache.maven.artifact.Artifact,java.util.Set<java.lang.String>> artifacts)private voidlogArtifacts(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean warn)private voidlogDependencyWarning(java.lang.CharSequence content)private voidwriteDependencyXML(java.util.Set<org.apache.maven.artifact.Artifact> artifacts)private voidwriteScriptableOutput(java.util.Set<org.apache.maven.artifact.Artifact> artifacts)
-
-
-
Field Detail
-
analyzer
@Parameter(property="analyzer", defaultValue="default") private java.lang.String analyzerSpecify 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
@Parameter(property="scriptableFlag", defaultValue="$$$%%%") private java.lang.String scriptableFlagFlag to use for scriptable output.- Since:
- 2.0-alpha-5
-
baseDir
@Parameter(defaultValue="${basedir}", readonly=true) private java.io.File baseDirFlag to use for scriptable output.- Since:
- 2.0-alpha-5
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}", readonly=true) private java.io.File outputDirectoryTarget folder.- Since:
- 2.0-alpha-5
-
usedDependencies
@Parameter private java.lang.String[] 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
@Parameter private java.lang.String[] 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
@Parameter private java.lang.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 withorg.apache., and:::*-SNAPSHOTwill match all snapshot artifacts.- Since:
- 2.10
-
ignoredUnusedDeclaredDependencies
@Parameter private java.lang.String[] ignoredUnusedDeclaredDependencies
List of dependencies that are 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.*matches all artifacts whose group id starts withorg.apache., and:::*-SNAPSHOTmatches all snapshot artifacts.Certain dependencies that are known to be used and loaded by reflection are always ignored. This includes
org.slf4j:slf4j-simple::.- Since:
- 2.10
-
unconditionallyIgnoredDeclaredDependencies
private java.lang.String[] unconditionallyIgnoredDeclaredDependencies
-
ignoredNonTestScopedDependencies
@Parameter(defaultValue="org.slf4j:slf4j-simple::") private java.lang.String[] ignoredNonTestScopedDependencies
List of dependencies that are 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.*matched all artifacts whose group id starts withorg.apache., and:::*-SNAPSHOTwill match all snapshot artifacts.- Since:
- 3.3.0
-
ignoredPackagings
@Parameter(defaultValue="pom,ear") private java.util.List<java.lang.String> ignoredPackagings
List of project packaging that will be ignored.
Default value is:pom, ear- Since:
- 3.2.1
-
excludedClasses
@Parameter(property="mdep.analyze.excludedClasses") private java.util.Set<java.lang.String> excludedClasses
List of class patterns excluded from analyze. Java regular expression pattern is applied to full class name.- Since:
- 3.7.0
-
plexusContainer
private final org.codehaus.plexus.PlexusContainer plexusContainer
The plexusContainer to look up theProjectDependencyAnalyzerimplementation depending on the mojo configuration.
-
project
private final org.apache.maven.project.MavenProject project
The Maven project to analyze.
-
-
Method Detail
-
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
private void filterArtifactsByScope(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, java.lang.String scope)
-
logArtifacts
private void logArtifacts(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean warn)
-
logArtifacts
private void logArtifacts(java.util.Map<org.apache.maven.artifact.Artifact,java.util.Set<java.lang.String>> artifacts)
-
logDependencyWarning
private void logDependencyWarning(java.lang.CharSequence content)
-
writeDependencyXML
private void writeDependencyXML(java.util.Set<org.apache.maven.artifact.Artifact> artifacts)
-
writeScriptableOutput
private void writeScriptableOutput(java.util.Set<org.apache.maven.artifact.Artifact> artifacts)
-
filterDependencies
private java.util.Set<org.apache.maven.artifact.Artifact> filterDependencies(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, java.lang.String[] excludes)
-
-