From 8054076ef540257dc07dad20d43d5247337300e8 Mon Sep 17 00:00:00 2001 From: Matt Nelson Date: Fri, 17 Aug 2018 13:59:30 -0500 Subject: [PATCH] [MDEP-425] Add list-plugin-repositories goal --- .../invoker.properties | 18 +++++ .../projects/list-plugin-repositories/pom.xml | 47 +++++++++++++ .../resolvers/ListPluginRepositoriesMojo.java | 66 +++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 src/it/projects/list-plugin-repositories/invoker.properties create mode 100644 src/it/projects/list-plugin-repositories/pom.xml create mode 100644 src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java diff --git a/src/it/projects/list-plugin-repositories/invoker.properties b/src/it/projects/list-plugin-repositories/invoker.properties new file mode 100644 index 000000000..f88ba5bbb --- /dev/null +++ b/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/src/it/projects/list-plugin-repositories/pom.xml b/src/it/projects/list-plugin-repositories/pom.xml new file mode 100644 index 000000000..e871ea85a --- /dev/null +++ b/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/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java new file mode 100644 index 000000000..b4e16e8ba --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java @@ -0,0 +1,66 @@ +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.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.2 + */ +@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; + } +}