Class ProjectDependencyAnalysis
java.lang.Object
org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis
Project dependencies analysis result.
Class names, maps keyed by class name and dependency usages are returned sorted; artifacts keep the order in which they were passed in.
- Author:
- Mark Hobson
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.ProjectDependencyAnalysis(Map<org.apache.maven.artifact.Artifact, Set<DependencyUsage>> usedDeclaredArtifacts, Map<org.apache.maven.artifact.Artifact, Set<DependencyUsage>> usedUndeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> unusedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> testArtifactsWithNonTestScope) Creates an analysis result with usage details.ProjectDependencyAnalysis(Map<org.apache.maven.artifact.Artifact, Set<DependencyUsage>> usedDeclaredArtifacts, Map<org.apache.maven.artifact.Artifact, Set<DependencyUsage>> usedUndeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> unusedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> testArtifactsWithNonTestScope, Set<String> usedDependencyClasses, Map<String, Set<org.apache.maven.artifact.Artifact>> candidateArtifactsByUsedClass, Map<String, org.apache.maven.artifact.Artifact> selectedArtifactByUsedClass) Creates an analysis result with usage details, raw used classes and candidate artifacts.ProjectDependencyAnalysis(Set<org.apache.maven.artifact.Artifact> usedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> usedUndeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> unusedDeclaredArtifacts) Deprecated.useProjectDependencyAnalysis(Set, Set, Set, Set)insteadProjectDependencyAnalysis(Set<org.apache.maven.artifact.Artifact> usedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> usedUndeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> unusedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> testArtifactsWithNonTestScope) Constructor for ProjectDependencyAnalysis. -
Method Summary
Modifier and TypeMethodDescriptionbooleanforceDeclaredDependenciesUsage(String[] forceUsedDependencies) Force use status of some declared dependencies, to manually fix consequences of bytecode-level analysis which happens to not detect some effective use (constants, annotation with source-retention, javadoc).Returns referenced dependency classes provided by more than one artifact.Returns the artifacts that provide each referenced dependency class.Returns the artifact selected for each referenced dependency class.Set<org.apache.maven.artifact.Artifact>Returns artifacts only used in tests but not declared with test scope.Returns referenced dependency classes that no dependency artifact provides, for example classes of a dependency that is missing from the build.Set<org.apache.maven.artifact.Artifact>Returns artifacts declared but not used.Set<org.apache.maven.artifact.Artifact>Returns artifacts both used and declared.Map<org.apache.maven.artifact.Artifact,Set<DependencyUsage>> Returns artifacts both used and declared.Returns the class names referenced by the analyzed bytecode that can come from a dependency.Set<org.apache.maven.artifact.Artifact>Returns artifacts used but not declared.Returns artifacts used but not declared.Map<org.apache.maven.artifact.Artifact,Set<DependencyUsage>> Returns artifacts used but not declared with their usages.inthashCode()hashCode.Filter non-compile scoped artifacts from unused declared.toString()toString.
-
Constructor Details
-
ProjectDependencyAnalysis
Deprecated.useProjectDependencyAnalysis(Map, Map, Set, Set)insteadConstructor for ProjectDependencyAnalysis.
-
ProjectDependencyAnalysis
@Deprecated public ProjectDependencyAnalysis(Set<org.apache.maven.artifact.Artifact> usedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> usedUndeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> unusedDeclaredArtifacts) Deprecated.useProjectDependencyAnalysis(Set, Set, Set, Set)insteadConstructor for ProjectDependencyAnalysis to maintain compatibility with old API
- Parameters:
usedDeclaredArtifacts- artifacts both used and declaredusedUndeclaredArtifacts- artifacts used but not declaredunusedDeclaredArtifacts- artifacts declared but not used
-
ProjectDependencyAnalysis
public ProjectDependencyAnalysis(Set<org.apache.maven.artifact.Artifact> usedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> usedUndeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> unusedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> testArtifactsWithNonTestScope) Constructor for ProjectDependencyAnalysis.- Parameters:
usedDeclaredArtifacts- artifacts both used and declaredusedUndeclaredArtifacts- artifacts used but not declaredunusedDeclaredArtifacts- artifacts declared but not usedtestArtifactsWithNonTestScope- artifacts only used in tests but not declared with test scope
-
ProjectDependencyAnalysis
public ProjectDependencyAnalysis(Map<org.apache.maven.artifact.Artifact, Set<DependencyUsage>> usedDeclaredArtifacts, Map<org.apache.maven.artifact.Artifact, Set<DependencyUsage>> usedUndeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> unusedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> testArtifactsWithNonTestScope) Creates an analysis result with usage details.- Parameters:
usedDeclaredArtifacts- artifacts both used and declaredusedUndeclaredArtifacts- artifacts used but not declaredunusedDeclaredArtifacts- artifacts declared but not usedtestArtifactsWithNonTestScope- artifacts only used in tests but not declared with test scope
-
ProjectDependencyAnalysis
public ProjectDependencyAnalysis(Map<org.apache.maven.artifact.Artifact, Set<DependencyUsage>> usedDeclaredArtifacts, Map<org.apache.maven.artifact.Artifact, Set<DependencyUsage>> usedUndeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> unusedDeclaredArtifacts, Set<org.apache.maven.artifact.Artifact> testArtifactsWithNonTestScope, Set<String> usedDependencyClasses, Map<String, Set<org.apache.maven.artifact.Artifact>> candidateArtifactsByUsedClass, Map<String, org.apache.maven.artifact.Artifact> selectedArtifactByUsedClass) Creates an analysis result with usage details, raw used classes and candidate artifacts.- Parameters:
usedDeclaredArtifacts- artifacts both used and declaredusedUndeclaredArtifacts- artifacts used but not declaredunusedDeclaredArtifacts- artifacts declared but not usedtestArtifactsWithNonTestScope- artifacts only used in tests but not declared with test scopeusedDependencyClasses- dependency class names referenced by the analyzed bytecodecandidateArtifactsByUsedClass- candidate artifacts that provide each used dependency classselectedArtifactByUsedClass- artifact selected for each used dependency class- Since:
- 1.18.0
-
-
Method Details
-
getUsedDeclaredArtifacts
Returns artifacts both used and declared.- Returns:
- artifacts both used and declared
-
getUsedDeclaredArtifactsWithUsages
public Map<org.apache.maven.artifact.Artifact,Set<DependencyUsage>> getUsedDeclaredArtifactsWithUsages()Returns artifacts both used and declared.- Returns:
- artifacts both used and declared
-
getUsedUndeclaredArtifacts
Returns artifacts used but not declared.- Returns:
- artifacts used but not declared
-
getUsedUndeclaredArtifactsWithClasses
Returns artifacts used but not declared.- Returns:
- artifacts used but not declared
-
getUsedUndeclaredArtifactsWithUsages
public Map<org.apache.maven.artifact.Artifact,Set<DependencyUsage>> getUsedUndeclaredArtifactsWithUsages()Returns artifacts used but not declared with their usages.- Returns:
- artifacts used but not declared with their usages
-
getUnusedDeclaredArtifacts
Returns artifacts declared but not used.- Returns:
- artifacts declared but not used
-
getTestArtifactsWithNonTestScope
Returns artifacts only used in tests but not declared with test scope.- Returns:
- artifacts only used in tests but not declared with test scope
-
getUsedDependencyClasses
Returns the class names referenced by the analyzed bytecode that can come from a dependency. The project's own classes, the classes of the JDK running the analysis and excluded classes are left out unless a dependency provides them too.- Returns:
- dependency class names referenced by the analyzed bytecode
- Since:
- 1.18.0
-
getCandidateArtifactsByUsedClass
Returns the artifacts that provide each referenced dependency class.- Returns:
- candidate artifacts per referenced dependency class
- Since:
- 1.18.0
-
getSelectedArtifactByUsedClass
Returns the artifact selected for each referenced dependency class.- Returns:
- selected artifact per referenced dependency class
- Since:
- 1.18.0
-
getAmbiguousUsedDependencyClasses
Returns referenced dependency classes provided by more than one artifact.- Returns:
- ambiguous referenced dependency classes
- Since:
- 1.18.0
-
getUnmappedUsedDependencyClasses
Returns referenced dependency classes that no dependency artifact provides, for example classes of a dependency that is missing from the build. The project's own classes, the classes of the JDK running the analysis and excluded classes are left out.- Returns:
- unmapped referenced dependency classes
- Since:
- 1.18.0
-
ignoreNonCompile
Filter non-compile scoped artifacts from unused declared.- Returns:
- updated project dependency analysis
- Since:
- 1.3
-
forceDeclaredDependenciesUsage
public ProjectDependencyAnalysis forceDeclaredDependenciesUsage(String[] forceUsedDependencies) throws ProjectDependencyAnalyzerException Force use status of some declared dependencies, to manually fix consequences of bytecode-level analysis which happens to not detect some effective use (constants, annotation with source-retention, javadoc).The dependencies already detected as used keep their usages; a newly forced dependency has an empty usage set. The used classes and their candidate and selected artifacts are kept unchanged.
- Parameters:
forceUsedDependencies- dependencies to move from "unused-declared" to "used-declared", withgroupId:artifactIdformat- Returns:
- updated project dependency analysis
- Throws:
ProjectDependencyAnalyzerException- if dependencies forced were either not declared or already detected as used- Since:
- 1.3
-
hashCode
public int hashCode()hashCode.
-
equals
-
toString
toString.
-
ProjectDependencyAnalysis(Map, Map, Set, Set)instead