-
Notifications
You must be signed in to change notification settings - Fork 47
Require Maven 3.2.5+ #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,19 +19,21 @@ | |
* under the License. | ||
*/ | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Set; | ||
import java.util.zip.ZipException; | ||
|
||
import org.codehaus.plexus.component.annotations.Component; | ||
|
||
/** | ||
* <p>DefaultClassAnalyzer class.</p> | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Hobson</a> | ||
*/ | ||
@Component( role = ClassAnalyzer.class ) | ||
@Named | ||
@Singleton | ||
public class DefaultClassAnalyzer | ||
implements ClassAnalyzer | ||
{ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ | |
* under the License. | ||
*/ | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
|
@@ -35,28 +39,27 @@ | |
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.project.MavenProject; | ||
import org.codehaus.plexus.component.annotations.Component; | ||
import org.codehaus.plexus.component.annotations.Requirement; | ||
|
||
/** | ||
* <p>DefaultProjectDependencyAnalyzer class.</p> | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Hobson</a> | ||
*/ | ||
@Component( role = ProjectDependencyAnalyzer.class ) | ||
@Named | ||
@Singleton | ||
public class DefaultProjectDependencyAnalyzer | ||
implements ProjectDependencyAnalyzer | ||
{ | ||
/** | ||
* ClassAnalyzer | ||
*/ | ||
@Requirement | ||
@Inject | ||
private ClassAnalyzer classAnalyzer; | ||
|
||
/** | ||
* DependencyAnalyzer | ||
*/ | ||
@Requirement | ||
@Inject | ||
private DependencyAnalyzer dependencyAnalyzer; | ||
|
||
/** {@inheritDoc} */ | ||
|
@@ -75,17 +78,17 @@ public ProjectDependencyAnalysis analyze( MavenProject project ) | |
Set<Artifact> declaredArtifacts = buildDeclaredArtifacts( project ); | ||
|
||
Map<Artifact, Set<String>> usedArtifacts = buildUsedArtifacts( artifactClassMap, dependencyClasses ); | ||
Set<Artifact> mainUsedArtifacts = buildUsedArtifacts( artifactClassMap, mainDependencyClasses ).keySet(); | ||
Set<Artifact> mainUsedArtifacts = buildUsedArtifacts( artifactClassMap, mainDependencyClasses ).keySet(); | ||
|
||
Set<Artifact> testArtifacts = buildUsedArtifacts( artifactClassMap, testOnlyDependencyClasses ).keySet(); | ||
Set<Artifact> testArtifacts = buildUsedArtifacts( artifactClassMap, testOnlyDependencyClasses ).keySet(); | ||
Set<Artifact> testOnlyArtifacts = removeAll( testArtifacts, mainUsedArtifacts ); | ||
|
||
Set<Artifact> usedDeclaredArtifacts = new LinkedHashSet<>( declaredArtifacts ); | ||
usedDeclaredArtifacts.retainAll( usedArtifacts.keySet() ); | ||
|
||
Map<Artifact, Set<String>> usedUndeclaredArtifactsWithClasses = new LinkedHashMap<>( usedArtifacts ); | ||
Set<Artifact> usedUndeclaredArtifacts = removeAll( | ||
usedUndeclaredArtifactsWithClasses.keySet(), declaredArtifacts ); | ||
usedUndeclaredArtifactsWithClasses.keySet(), declaredArtifacts ); | ||
usedUndeclaredArtifactsWithClasses.keySet().retainAll( usedUndeclaredArtifacts ); | ||
|
||
Set<Artifact> unusedDeclaredArtifacts = new LinkedHashSet<>( declaredArtifacts ); | ||
|
@@ -94,7 +97,7 @@ public ProjectDependencyAnalysis analyze( MavenProject project ) | |
Set<Artifact> testArtifactsWithNonTestScope = getTestArtifactsWithNonTestScope( testOnlyArtifacts ); | ||
|
||
return new ProjectDependencyAnalysis( usedDeclaredArtifacts, usedUndeclaredArtifactsWithClasses, | ||
unusedDeclaredArtifacts, testArtifactsWithNonTestScope ); | ||
unusedDeclaredArtifacts, testArtifactsWithNonTestScope ); | ||
slawekjaranowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
catch ( IOException exception ) | ||
{ | ||
|
@@ -105,8 +108,8 @@ public ProjectDependencyAnalysis analyze( MavenProject project ) | |
/** | ||
* This method defines a new way to remove the artifacts by using the conflict id. We don't care about the version | ||
* here because there can be only 1 for a given artifact anyway. | ||
* | ||
* @param start initial set | ||
* | ||
* @param start initial set | ||
* @param remove set to exclude | ||
* @return set with remove excluded | ||
*/ | ||
|
@@ -231,9 +234,9 @@ private Set<String> buildDependencyClasses( MavenProject project ) | |
|
||
return dependencyClasses; | ||
} | ||
|
||
private Set<String> buildMainDependencyClasses( MavenProject project ) | ||
throws IOException | ||
throws IOException | ||
{ | ||
|
||
String outputDirectory = project.getBuild().getOutputDirectory(); | ||
|
@@ -263,7 +266,7 @@ private Set<Artifact> buildDeclaredArtifacts( MavenProject project ) | |
} | ||
|
||
private Map<Artifact, Set<String>> buildUsedArtifacts( Map<Artifact, Set<String>> artifactClassMap, | ||
Set<String> dependencyClasses ) | ||
Set<String> dependencyClasses ) | ||
slawekjaranowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
Map<Artifact, Set<String>> usedArtifacts = new HashMap<>(); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,20 +19,23 @@ | |
* under the License. | ||
*/ | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Set; | ||
|
||
import org.apache.maven.shared.dependency.analyzer.ClassFileVisitorUtils; | ||
import org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer; | ||
import org.codehaus.plexus.component.annotations.Component; | ||
|
||
/** | ||
* ASMDependencyAnalyzer | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Hobson</a> | ||
*/ | ||
@Component( role = DependencyAnalyzer.class ) | ||
@Named | ||
@Singleton | ||
public class ASMDependencyAnalyzer | ||
implements DependencyAnalyzer | ||
{ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.