Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/it/projects/resolve-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.10.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
27 changes: 27 additions & 0 deletions src/it/projects/resolve-plugins/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.
*/

def resolvedPlugins = new File(basedir, "target/resolved.txt").text

assert resolvedPlugins.contains(" org.apache.maven.plugins:maven-assembly-plugin:jar:") : "Expected plugin not found in resolved plugins"
assert resolvedPlugins.contains(" org.apache.maven.plugins:maven-dependency-plugin:jar:") : "Expected plugin not found in resolved plugins"
assert resolvedPlugins.contains(" org.apache.maven.plugins:maven-surefire-plugin:jar:") : "Expected plugin not found in resolved plugins"
assert resolvedPlugins.contains(" org.apache.maven.plugins:maven-project-info-reports-plugin:jar:") : "Expected plugin not found in resolved plugins"
assert resolvedPlugins.contains(" org.apache.maven.plugins:maven-failsafe-plugin:jar:") : "Expected plugin not found in resolved plugins"
assert resolvedPlugins.contains(" org.apache.maven.plugins:maven-surefire-report-plugin:jar:") : "Expected plugin not found in resolved plugins"
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.maven.model.ModelBase;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginContainer;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Reporting;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -342,7 +343,7 @@ private ArtifactType getArtifactType(String packaging) {
}

/**
* Retrieve all plugins used in project either in build or reporting section.
* Retrieve all plugins used in a project either in the build, plugin management, or reporting section.
*
* @param project a maven project
* @return a collection of plugins
Expand All @@ -358,9 +359,14 @@ public Collection<Plugin> getProjectPlugins(MavenProject project) {

List<Plugin> projectPlugins = project.getBuild().getPlugins();

List<Plugin> managementPlugins = Optional.ofNullable(project.getPluginManagement())
.map(PluginManagement::getPlugins)
.orElse(Collections.emptyList());

LinkedHashSet<Plugin> result = new LinkedHashSet<>(reportPlugins.size() + projectPlugins.size());
result.addAll(reportPlugins);
result.addAll(projectPlugins);
result.addAll(managementPlugins);
return result;
}

Expand Down