Fixed unused import
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1685373 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
index bc0056c..1030a9b 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
@@ -19,14 +19,8 @@
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.DependencyResolutionResult;
import org.apache.maven.project.ProjectBuilder;
@@ -34,9 +28,14 @@
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingResult;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
/**
* This filter will exclude everything that is not a dependency of the selected artifact.
- *
+ *
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
*/
@@ -49,22 +48,22 @@
private Set<String> transitiveArtifacts;
/**
- * Use {@link MavenSession#getProjectBuildingRequest()} to get the buildingRequest.
+ * Use {@link org.apache.maven.execution.MavenSession#getProjectBuildingRequest()} to get the buildingRequest.
* The projectBuilder should be resolved with CDI.
- *
+ * <p/>
* <pre>
* // For Mojo
* @Component
* private ProjectBuilder projectBuilder;
*
* // For Components
- * @Requirement // or @Inject
+ * @Requirement // or @Inject
* private ProjectBuilder projectBuilder;
* </pre>
- *
- * @param artifact the artifact to resolve the dependencies from
+ *
+ * @param artifact the artifact to resolve the dependencies from
* @param buildingRequest the buildingRequest
- * @param projectBuilder the projectBuilder
+ * @param projectBuilder the projectBuilder
* @throws ProjectBuildingException if the project descriptor could not be successfully built
*/
public ArtifactTransitivityFilter( Artifact artifact, ProjectBuildingRequest buildingRequest,
@@ -72,9 +71,9 @@
throws ProjectBuildingException
{
ProjectBuildingRequest request = new DefaultProjectBuildingRequest( buildingRequest );
-
+
request.setResolveDependencies( true );
-
+
ProjectBuildingResult buildingResult = projectBuilder.build( artifact, request );
DependencyResolutionResult resolutionResult = buildingResult.getDependencyResolutionResult();
@@ -84,16 +83,15 @@
{
try
{
- @SuppressWarnings( "unchecked" )
- List<org.eclipse.aether.graph.Dependency> dependencies =
- (List<org.eclipse.aether.graph.Dependency>) Invoker.invoke( resolutionResult, "getDependencies" );
+ @SuppressWarnings( "unchecked" ) List<org.eclipse.aether.graph.Dependency> dependencies =
+ (List<org.eclipse.aether.graph.Dependency>) Invoker.invoke( resolutionResult,
+ "getDependencies" );
for ( org.eclipse.aether.graph.Dependency dependency : dependencies )
{
- Artifact mavenArtifact =
- (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.eclipse.aether.artifact.Artifact.class,
- dependency.getArtifact() );
+ Artifact mavenArtifact = (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact",
+ org.eclipse.aether.artifact.Artifact.class,
+ dependency.getArtifact() );
transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
@@ -118,17 +116,15 @@
{
try
{
- @SuppressWarnings( "unchecked" )
- List<org.sonatype.aether.graph.Dependency> dependencies =
+ @SuppressWarnings( "unchecked" ) List<org.sonatype.aether.graph.Dependency> dependencies =
(List<org.sonatype.aether.graph.Dependency>) Invoker.invoke( resolutionResult,
"getDependencies" );
for ( org.sonatype.aether.graph.Dependency dependency : dependencies )
{
- Artifact mavenArtifact =
- (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact",
- org.sonatype.aether.artifact.Artifact.class,
- dependency.getArtifact() );
+ Artifact mavenArtifact = (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact",
+ org.sonatype.aether.artifact.Artifact.class,
+ dependency.getArtifact() );
transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
@@ -152,31 +148,6 @@
}
}
- public Set<Artifact> filter( Set<Artifact> artifacts )
- {
-
- Set<Artifact> result = new HashSet<Artifact>();
- for ( Artifact artifact : artifacts )
- {
- if ( artifactIsATransitiveDependency( artifact ) )
- {
- result.add( artifact );
- }
- }
- return result;
- }
-
- /**
- * Compares the artifact to the list of dependencies to see if it is directly included by this project
- *
- * @param artifact representing the item to compare.
- * @return true if artifact is a transitive dependency
- */
- public boolean artifactIsATransitiveDependency( Artifact artifact )
- {
- return transitiveArtifacts.contains( artifact.getDependencyConflictId() );
- }
-
/**
* @return true if the current Maven version is Maven 3.1.
*/
@@ -197,5 +168,30 @@
{
return false;
}
- }
+ }
+
+ public Set<Artifact> filter( Set<Artifact> artifacts )
+ {
+
+ Set<Artifact> result = new HashSet<Artifact>();
+ for ( Artifact artifact : artifacts )
+ {
+ if ( artifactIsATransitiveDependency( artifact ) )
+ {
+ result.add( artifact );
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Compares the artifact to the list of dependencies to see if it is directly included by this project
+ *
+ * @param artifact representing the item to compare.
+ * @return true if artifact is a transitive dependency
+ */
+ public boolean artifactIsATransitiveDependency( Artifact artifact )
+ {
+ return transitiveArtifacts.contains( artifact.getDependencyConflictId() );
+ }
}