This is an automated email from the ASF dual-hosted git repository. khmarbaise pushed a commit to branch MENFORCER-299 in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git
commit e9d05f0f5908a5e28e0d524c1a401764044cdea0 Author: Karl Heinz Marbaise <khmarba...@apache.org> AuthorDate: Wed May 9 22:20:24 2018 +0200 [MENFORCER-299] - WIP - Added IT's --- .../plugins/enforcer/RequirePluginVersions.java | 49 +++++++++--------- .../require-plugin-versions-cifriendly/pom.xml | 60 ++++++++++++++++++++++ .../invoker.properties | 3 +- 3 files changed, 86 insertions(+), 26 deletions(-) diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java index 9e840da..d41dc50 100644 --- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java +++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java @@ -80,7 +80,7 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; public class RequirePluginVersions extends AbstractNonCacheableEnforcerRule { - + private EnforcerRuleHelper helper; /** @@ -212,7 +212,8 @@ public class RequirePluginVersions else // Using Maven 2 { - lifecycles = (Collection) ReflectionUtils.getValueIncludingSuperclasses( "lifecycles", life ); + log.error( "We don't support Maven 2 anymore." ); + throw new EnforcerRuleException( "We don't support Maven 2 anymore." ); } session = (MavenSession) helper.evaluate( "${session}" ); @@ -392,7 +393,8 @@ public class RequirePluginVersions * @return List of unchecked plugins. */ // CHECKSTYLE_OFF: LineLength - public Collection<String> combineUncheckedPlugins( Collection<String> uncheckedPlugins, String uncheckedPluginsList ) + public Collection<String> combineUncheckedPlugins( Collection<String> uncheckedPlugins, + String uncheckedPluginsList ) // CHECKSTYLE_ON: LineLength { // if the comma list is empty, then there's nothing to do here. @@ -546,9 +548,8 @@ public class RequirePluginVersions { List<ArtifactRepository> pluginRepositories = project.getPluginArtifactRepositories(); - Artifact artifact = - factory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), - VersionRange.createFromVersion( "LATEST" ) ); + Artifact artifact = factory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), + VersionRange.createFromVersion( "LATEST" ) ); try { @@ -557,11 +558,11 @@ public class RequirePluginVersions } catch ( ArtifactResolutionException e ) { - //What does this mean? + // What does this mean? } catch ( ArtifactNotFoundException e ) { - //What does this mean? + // What does this mean? } return plugin; @@ -835,9 +836,8 @@ public class RequirePluginVersions String packaging = project.getPackaging(); Map<String, String> mappings = null; - LifecycleMapping m = - (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session.getSettings(), - session.getLocalRepository() ); + LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, + session.getSettings(), session.getLocalRepository() ); if ( m != null ) { mappings = m.getPhases( lifecycle.getId() ); @@ -856,8 +856,8 @@ public class RequirePluginVersions { if ( defaultMappings == null ) { - throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" - + packaging + "\'.", e ); + throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging + + "\'.", e ); } } } @@ -893,9 +893,8 @@ public class RequirePluginVersions String packaging = project.getPackaging(); List<String> optionalMojos = null; - LifecycleMapping m = - (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session.getSettings(), - session.getLocalRepository() ); + LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, + session.getSettings(), session.getLocalRepository() ); if ( m != null ) { @@ -912,7 +911,7 @@ public class RequirePluginVersions catch ( ComponentLookupException e ) { log.debug( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " - + lifecycle.getId() + ". Error: " + e.getMessage(), e ); + + lifecycle.getId() + ". Error: " + e.getMessage(), e ); } } @@ -1046,13 +1045,13 @@ public class RequirePluginVersions // get all the pom models List<Model> models = new ArrayList<Model>(); - + List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects(); for ( MavenProject mavenProject : sortedProjects ) { models.add( mavenProject.getOriginalModel() ); } - + // now find all the plugin entries, either in // build.plugins or build.pluginManagement.plugins, profiles.plugins and reporting for ( Model model : models ) @@ -1060,8 +1059,8 @@ public class RequirePluginVersions try { List<Plugin> modelPlugins = model.getBuild().getPlugins(); - plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() - + ".build.plugins" ) ); + plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), + model.getId() + ".build.plugins" ) ); } catch ( NullPointerException e ) { @@ -1072,8 +1071,8 @@ public class RequirePluginVersions { List<ReportPlugin> modelReportPlugins = model.getReporting().getPlugins(); // add the reporting plugins - plugins.addAll( PluginWrapper.addAll( utils.resolveReportPlugins( modelReportPlugins ), model.getId() - + ".reporting" ) ); + plugins.addAll( PluginWrapper.addAll( utils.resolveReportPlugins( modelReportPlugins ), + model.getId() + ".reporting" ) ); } catch ( NullPointerException e ) { @@ -1083,8 +1082,8 @@ public class RequirePluginVersions try { List<Plugin> modelPlugins = model.getBuild().getPluginManagement().getPlugins(); - plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), model.getId() - + ".build.pluginManagement.plugins" ) ); + plugins.addAll( PluginWrapper.addAll( utils.resolvePlugins( modelPlugins ), + model.getId() + ".build.pluginManagement.plugins" ) ); } catch ( NullPointerException e ) { diff --git a/maven-enforcer-plugin/src/it/projects/require-plugin-versions-cifriendly/pom.xml b/maven-enforcer-plugin/src/it/projects/require-plugin-versions-cifriendly/pom.xml new file mode 100644 index 0000000..7bd7043 --- /dev/null +++ b/maven-enforcer-plugin/src/it/projects/require-plugin-versions-cifriendly/pom.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.its.enforcer</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + <packaging>pom</packaging> + + <description> + </description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <version>@project.version@</version> + <executions> + <execution> + <id>test</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <requirePluginVersions> + <banSnapshots>false</banSnapshots> + <unCheckedPluginList> + org.apache.maven.plugins:maven-clean-plugin,org.apache.maven.plugins:maven-install-plugin,org.apache.maven.plugins:maven-deploy-plugin,org.apache.maven.plugins:maven-site-plugin + </unCheckedPluginList> + </requirePluginVersions> + </rules> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/invoker.properties b/maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/invoker.properties index 1b78093..7710efd 100644 --- a/maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/invoker.properties +++ b/maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/invoker.properties @@ -15,4 +15,5 @@ # specific language governing permissions and limitations # under the License. invoker.maven.version = 3.5.0+ -invoker.goals = install -Drevision=0.10.0-SNAPSHOT \ No newline at end of file +invoker.goals = install -Drevision=0.10.0-SNAPSHOT + -- To stop receiving notification emails like this one, please contact khmarba...@apache.org.