diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index b4d5bcab2..d7a3ba61d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -79,12 +79,6 @@ public class CopyMojo extends AbstractFromConfigurationMojo { @Parameter(property = "artifact") private String artifact; - /** - * not used in this goal - */ - @Parameter - protected boolean ignorePermissions; - /** * Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to * copyArtifact. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index d92f5674f..97956ec72 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -97,12 +97,6 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { @Parameter(property = "mdep.addParentPoms", defaultValue = "false") protected boolean addParentPoms; - /** - * not used in this goal - */ - @Parameter - protected boolean ignorePermissions; - /** * Main entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index 9ed8d961a..a452968ee 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -19,28 +19,15 @@ package org.apache.maven.plugins.dependency.resolvers; import java.io.File; -import java.util.LinkedHashSet; -import java.util.Set; -import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; -import org.apache.maven.plugins.dependency.utils.DependencyUtil; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; -import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; -import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; -import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; -import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; -import org.apache.maven.shared.artifact.filter.collection.TypeFilter; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; -import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; /** * @author Brian Fox */ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { + /** * If specified, this parameter causes the dependencies to be written to the path specified instead of * the console. @@ -65,67 +52,4 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { */ @Parameter(property = "excludeReactor", defaultValue = "true") protected boolean excludeReactor; - - /** - * not used in this goal - */ - @Parameter - protected boolean ignorePermissions; - - /** - * @return {@link FilterArtifacts} - */ - protected FilterArtifacts getArtifactsFilter() { - final FilterArtifacts filter = new FilterArtifacts(); - - if (excludeReactor) { - - filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); - } - - filter.addFilter(new ScopeFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeScope), - DependencyUtil.cleanToBeTokenizedString(this.excludeScope))); - - filter.addFilter(new TypeFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeTypes), - DependencyUtil.cleanToBeTokenizedString(this.excludeTypes))); - - filter.addFilter(new ClassifierFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), - DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers))); - - filter.addFilter(new GroupIdFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), - DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds))); - - filter.addFilter(new ArtifactIdFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), - DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds))); - - return filter; - } - - /** - * This method resolves all transitive dependencies of an artifact. - * - * @param artifact the artifact used to retrieve dependencies - * @return resolved set of dependencies - * @throws DependencyResolverException in case of error while resolving artifacts. - */ - protected Set resolveArtifactDependencies(final DependableCoordinate artifact) - throws DependencyResolverException { - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); - - Iterable artifactResults = - getDependencyResolver().resolveDependencies(buildingRequest, artifact, null); - - Set artifacts = new LinkedHashSet<>(); - - for (final ArtifactResult artifactResult : artifactResults) { - artifacts.add(artifactResult.getArtifact()); - } - - return artifacts; - } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index 69994d962..cae06b224 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -31,10 +31,17 @@ import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; +import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; +import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; +import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; +import org.apache.maven.shared.artifact.filter.collection.TypeFilter; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; +import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; +import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; /** @@ -137,6 +144,63 @@ protected void doExecute() throws MojoExecutionException { } } + /** + * This method resolves all transitive dependencies of an artifact. + * + * @param artifact the artifact used to retrieve dependencies + * @return resolved set of dependencies + * @throws DependencyResolverException in case of error while resolving artifacts. + */ + private Set resolveArtifactDependencies(final DependableCoordinate artifact) + throws DependencyResolverException { + ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); + + Iterable artifactResults = + getDependencyResolver().resolveDependencies(buildingRequest, artifact, null); + + Set artifacts = new LinkedHashSet<>(); + + for (final ArtifactResult artifactResult : artifactResults) { + artifacts.add(artifactResult.getArtifact()); + } + + return artifacts; + } + + /** + * @return {@link FilterArtifacts} + */ + private FilterArtifacts getArtifactsFilter() { + final FilterArtifacts filter = new FilterArtifacts(); + + if (excludeReactor) { + + filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); + } + + filter.addFilter(new ScopeFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeScope), + DependencyUtil.cleanToBeTokenizedString(this.excludeScope))); + + filter.addFilter(new TypeFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeTypes), + DependencyUtil.cleanToBeTokenizedString(this.excludeTypes))); + + filter.addFilter(new ClassifierFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), + DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers))); + + filter.addFilter(new GroupIdFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), + DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds))); + + filter.addFilter(new ArtifactIdFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), + DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds))); + + return filter; + } + /** * This method resolves the plugin artifacts from the project. * @@ -144,7 +208,7 @@ protected void doExecute() throws MojoExecutionException { * @throws ArtifactFilterException in case of an error * @throws ArtifactResolverException in case of an error */ - protected Set resolvePluginArtifacts() throws ArtifactFilterException, ArtifactResolverException { + private Set resolvePluginArtifacts() throws ArtifactFilterException, ArtifactResolverException { final Set plugins = getProject().getPluginArtifacts(); final Set reports = getProject().getReportArtifacts();