From 4b437bde668233f9e1ca8e7ca53817cbdedffd0e Mon Sep 17 00:00:00 2001 From: Matt Nelson Date: Thu, 11 May 2017 19:38:24 -0500 Subject: [PATCH] [MDEP-425] Add list-plugin-repositories goal --- maven-dependency-plugin/pom.xml | 3 + .../invoker.properties | 18 +++++ .../projects/list-plugin-repositories/pom.xml | 47 +++++++++++++ .../resolvers/ListPluginRepositoriesMojo.java | 67 +++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100644 maven-dependency-plugin/src/it/projects/list-plugin-repositories/invoker.properties create mode 100644 maven-dependency-plugin/src/it/projects/list-plugin-repositories/pom.xml create mode 100644 maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java diff --git a/maven-dependency-plugin/pom.xml b/maven-dependency-plugin/pom.xml index ca1f4fa97e..a9211a2570 100644 --- a/maven-dependency-plugin/pom.xml +++ b/maven-dependency-plugin/pom.xml @@ -78,6 +78,9 @@ under the License. Markus Karg + + Matt Nelson + diff --git a/maven-dependency-plugin/src/it/projects/list-plugin-repositories/invoker.properties b/maven-dependency-plugin/src/it/projects/list-plugin-repositories/invoker.properties new file mode 100644 index 0000000000..f88ba5bbb0 --- /dev/null +++ b/maven-dependency-plugin/src/it/projects/list-plugin-repositories/invoker.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:list-plugin-repositories diff --git a/maven-dependency-plugin/src/it/projects/list-plugin-repositories/pom.xml b/maven-dependency-plugin/src/it/projects/list-plugin-repositories/pom.xml new file mode 100644 index 0000000000..e871ea85a9 --- /dev/null +++ b/maven-dependency-plugin/src/it/projects/list-plugin-repositories/pom.xml @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:list-plugin-repositories + + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + + diff --git a/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java b/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java new file mode 100644 index 0000000000..248c2f3c69 --- /dev/null +++ b/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java @@ -0,0 +1,67 @@ +package org.apache.maven.plugins.dependency.resolvers; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; + +/** + * Goal that resolves all project plugins and then lists the plugin + * repositories used by the build and by the transitive plugins + * + * @since 3.1 + */ +@Mojo( name = "list-plugin-repositories", threadSafe = true ) +public class ListPluginRepositoriesMojo + extends AbstractResolveMojo +{ + + @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true ) + private List remotePluginRepositories; + + /** + * Displays a list of the plugin repositories used by this build. + * + * @throws MojoExecutionException with a message if an error occurs. + */ + @Override + protected void doExecute() + throws MojoExecutionException + { + this.getLog().info( "Plugin repositories used by this build:" ); + + for ( ArtifactRepository repo : remotePluginRepositories ) + { + this.getLog().info( repo.toString() ); + } + } + + @Override + protected ArtifactsFilter getMarkedArtifactFilter() + { + return null; + } +}