[MENFORCER-117] RequirePluginVersions doesn't handle new lifecycles properly
git-svn-id: https://svn.apache.org/repos/asf/maven/enforcer/trunk@1357143 13f79535-47bb-0310-9956-ffa450edef68
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 863e847..15c2b08 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
@@ -686,6 +686,8 @@
throws PluginNotFoundException, LifecycleExecutionException
{
+ log.debug( "RequirePluginVersions.getAllPlugins:" );
+
Set<Plugin> plugins = new HashSet<Plugin>();
// first, bind those associated with the packaging
Map mappings = findMappingsForLifecycle( project, lifecycle );
@@ -694,13 +696,25 @@
while ( iter.hasNext() )
{
Entry entry = (Entry) iter.next();
- String value = (String) entry.getValue();
- String tokens[] = value.split( ":" );
+ log.debug( " lifecycleMapping = " + entry.getKey() );
+ String pluginsForLifecycle = (String) entry.getValue();
+ log.debug( " plugins = " + pluginsForLifecycle );
+ if ( StringUtils.isNotEmpty( pluginsForLifecycle ) )
+ {
+ String pluginList[] = pluginsForLifecycle.split( "," );
+ for ( String plugin : pluginList )
+ {
+ plugin = StringUtils.strip( plugin );
+ log.debug( " plugin = " + plugin );
+ String tokens[] = plugin.split( ":" );
+ log.debug( " GAV = " + Arrays.asList( tokens ) );
- Plugin plugin = new Plugin();
- plugin.setGroupId( tokens[0] );
- plugin.setArtifactId( tokens[1] );
- plugins.add( plugin );
+ Plugin p = new Plugin();
+ p.setGroupId( tokens[0] );
+ p.setArtifactId( tokens[1] );
+ plugins.add( p );
+ }
+ }
}
List<String> mojos = findOptionalMojosForLifecycle( project, lifecycle );
diff --git a/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-extensions/pom.xml b/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-extensions/pom.xml
new file mode 100644
index 0000000..42e81de
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-extensions/pom.xml
@@ -0,0 +1,74 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.its.enforcer</groupId>
+ <artifactId>pluginWithExtensions</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>zip</packaging>
+
+ <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>
+ <plugin>
+ <!-- For http://jira.codehaus.org/browse/MENFORCER-11 This plugin
+ attaches additional lifecycles "generate-sources" which were failed to be
+ handled correctly. -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>pde-maven-plugin</artifactId>
+ <version>1.0-alpha-1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <buildProperties>
+ <pdeProductFilename>example.product</pdeProductFilename>
+ </buildProperties>
+ </configuration>
+ <!-- Also bind to mvn clean -->
+ <executions>
+ <execution>
+ <id>clean-pde</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.5</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-integration-test-lifecycle/META-INF/MANIFEST.MF b/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-integration-test-lifecycle/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..40fd337
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-integration-test-lifecycle/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Bundle-SymbolicName: pluginWithIntegrationTestLifecycle
+Bundle-Version: 1.0.0.qualifier
\ No newline at end of file
diff --git a/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-integration-test-lifecycle/pom.xml b/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-integration-test-lifecycle/pom.xml
new file mode 100644
index 0000000..1ad6b33
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/require-plugin-versions-plugin-with-integration-test-lifecycle/pom.xml
@@ -0,0 +1,74 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.its.enforcer</groupId>
+ <artifactId>pluginWithIntegrationTestLifecycle</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <properties>
+ <tycho-version>0.15.0</tycho-version>
+ </properties>
+ <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>
+ <plugin>
+ <!-- For http://jira.codehaus.org/browse/MENFORCER-11 This plugin
+ attaches additional lifecycles "integration-test" which were failed to be
+ handled correctly. -->
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <!-- recommended: use p2-based target platform resolver -->
+ <resolver>p2</resolver>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-compiler-plugin</artifactId>
+ <version>${tycho-version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <version>${tycho-version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-plugin</artifactId>
+ <version>${tycho-version}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.4.3</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file