From 69afeb1a56c183ac9514528e8b3bc8e78e53a537 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 11 May 2012 20:02:08 +0000 Subject: [PATCH] fix mvn 2 compatibility git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/branches/MPLUGIN-189@1337351 13f79535-47bb-0310-9956-ffa450edef68 --- .../pom.xml | 9 +++++ .../apache/maven/plugin/coreit/FirstMojo.java | 2 +- .../verify.groovy | 2 +- .../apache/maven/plugin/coreit/FirstMojo.java | 2 +- .../pom.xml | 12 ++++++ .../verify.groovy | 2 +- .../it/annotation-with-inheritance/pom.xml | 9 +++++ .../apache/maven/plugin/coreit/FirstMojo.java | 2 +- .../annotation-with-inheritance/verify.groovy | 2 +- maven-plugin-plugin/src/it/help-basic/pom.xml | 9 +++++ .../src/it/help-package/pom.xml | 9 +++++ .../src/it/java-basic-annotations/pom.xml | 9 +++++ .../resources/META-INF/plexus/components.xml | 4 -- .../plugin/generator/PluginHelpGenerator.java | 38 +++++++++++-------- 14 files changed, 85 insertions(+), 26 deletions(-) diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml index 370c4c6..1e71de2 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml @@ -87,6 +87,15 @@ under the License. + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + + org.apache.maven.plugins diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java index 167f30e..70ecea5 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java @@ -45,7 +45,7 @@ public class FirstMojo @Parameter( alias = "alias" ) private String aliasedParam; - @Component( role = "org.apache.maven.project.MavenProjectHelper", roleHint = "default" ) + @Component( role = "org.apache.maven.project.MavenProjectHelper" )// , roleHint = "default" private Object projectHelper; public void execute() diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy index 213081a..6aefc31 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy @@ -43,7 +43,7 @@ assert mojo.requirements.requirement[1].'role-hint'.text() == '' assert mojo.requirements.requirement[1].'field-name'.text() == 'compilerManager' assert mojo.requirements.requirement[2].role.text() == 'org.apache.maven.project.MavenProjectHelper' -assert mojo.requirements.requirement[2].'role-hint'.text() == 'default' +//assert mojo.requirements.requirement[2].'role-hint'.text() == 'default' assert mojo.requirements.requirement[2].'field-name'.text() == 'projectHelper' assert mojo.parameters.parameter.size() == 3 diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java index c56fcb8..a70cc1f 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java @@ -46,7 +46,7 @@ public class FirstMojo @Parameter( alias = "alias" ) private String aliasedParam; - @Component( role = "org.apache.maven.project.MavenProjectHelper", roleHint = "default" ) + @Component( role = "org.apache.maven.project.MavenProjectHelper") private Object projectHelper; public void execute() diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml index 1a8ac83..838ea70 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml @@ -85,4 +85,16 @@ under the License. + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + + + + diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy index 6348f09..7659c5d 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy @@ -37,7 +37,7 @@ assert mojo.configuration.touchFile[0].'@default-value' == '${project.build.dire assert mojo.requirements.requirement.size() == 3 assert mojo.requirements.requirement[2].role.text() == 'org.apache.maven.project.MavenProjectHelper' -assert mojo.requirements.requirement[2].'role-hint'.text() == 'default' +//assert mojo.requirements.requirement[2].'role-hint'.text() == 'default' assert mojo.requirements.requirement[2].'field-name'.text() == 'projectHelper' assert mojo.parameters.parameter.size() == 3 diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml b/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml index 6799f43..945aaad 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml @@ -81,6 +81,15 @@ under the License. + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + + org.apache.maven.plugins diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java index e8358f7..adcb5e3 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java @@ -45,7 +45,7 @@ public class FirstMojo @Parameter( alias = "alias" ) private String aliasedParam; - @Component( role = "org.apache.maven.project.MavenProjectHelper", roleHint = "default" ) + @Component( role = "org.apache.maven.project.MavenProjectHelper" )//, roleHint = "default" private Object projectHelper; public void execute() diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy b/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy index 2052a1f..8554b25 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy @@ -41,7 +41,7 @@ assert mojo.configuration.touchFile[0].'@default-value' == '${project.build.dire assert mojo.requirements.requirement.size() == 3 assert mojo.requirements.requirement[2].role.text() == 'org.apache.maven.project.MavenProjectHelper' -assert mojo.requirements.requirement[2].'role-hint'.text() == 'default' +//assert mojo.requirements.requirement[2].'role-hint'.text() == 'default' assert mojo.requirements.requirement[2].'field-name'.text() == 'projectHelper' assert mojo.parameters.parameter.size() == 3 diff --git a/maven-plugin-plugin/src/it/help-basic/pom.xml b/maven-plugin-plugin/src/it/help-basic/pom.xml index df81e40..c970246 100644 --- a/maven-plugin-plugin/src/it/help-basic/pom.xml +++ b/maven-plugin-plugin/src/it/help-basic/pom.xml @@ -50,6 +50,15 @@ under the License. + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + + org.apache.maven.plugins diff --git a/maven-plugin-plugin/src/it/help-package/pom.xml b/maven-plugin-plugin/src/it/help-package/pom.xml index 20b74fd..1ae3c32 100644 --- a/maven-plugin-plugin/src/it/help-package/pom.xml +++ b/maven-plugin-plugin/src/it/help-package/pom.xml @@ -50,6 +50,15 @@ under the License. + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + + org.apache.maven.plugins diff --git a/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml b/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml index 3eb1e16..bec1a1f 100644 --- a/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml +++ b/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml @@ -58,6 +58,15 @@ under the License. + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + + org.apache.maven.plugins diff --git a/maven-plugin-tools-annotations/src/main/resources/META-INF/plexus/components.xml b/maven-plugin-tools-annotations/src/main/resources/META-INF/plexus/components.xml index 18fb315..9d6aa87 100644 --- a/maven-plugin-tools-annotations/src/main/resources/META-INF/plexus/components.xml +++ b/maven-plugin-tools-annotations/src/main/resources/META-INF/plexus/components.xml @@ -33,19 +33,15 @@ org.apache.maven.tools.plugin.annotations.scanner.MojoAnnotationsScanner - default org.apache.maven.artifact.resolver.ArtifactResolver - default org.apache.maven.artifact.factory.ArtifactFactory - default org.codehaus.plexus.archiver.manager.ArchiverManager - default diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java index 9a1d1a2..8f48f64 100644 --- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java +++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java @@ -42,6 +42,7 @@ import java.io.StringWriter; import java.io.Writer; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -103,26 +104,27 @@ public class PluginHelpGenerator MojoDescriptor helpDescriptor = makeHelpDescriptor( pluginDescriptor ); - // Verify that no help goal already exists - for ( @SuppressWarnings( "unchecked" ) Iterator it = pluginDescriptor.getMojos().iterator(); - it.hasNext(); ) + List mojoDescriptors = pluginDescriptor.getMojos(); + + if ( mojoDescriptors != null ) { - MojoDescriptor descriptor = it.next(); - - if ( descriptor.getGoal().equals( helpDescriptor.getGoal() ) && !descriptor.getImplementation().equals( - helpDescriptor.getImplementation() ) ) + // Verify that no help goal already exists + for ( MojoDescriptor descriptor : mojoDescriptors ) { - if ( getLogger().isWarnEnabled() ) + if ( descriptor.getGoal().equals( helpDescriptor.getGoal() ) && !descriptor.getImplementation().equals( + helpDescriptor.getImplementation() ) ) { - getLogger().warn( "\n\nA help goal (" + descriptor.getImplementation() - + ") already exists in this plugin. SKIPPED THE " - + helpDescriptor.getImplementation() + " GENERATION.\n" ); - } + if ( getLogger().isWarnEnabled() ) + { + getLogger().warn( "\n\nA help goal (" + descriptor.getImplementation() + + ") already exists in this plugin. SKIPPED THE " + + helpDescriptor.getImplementation() + " GENERATION.\n" ); + } - return; + return; + } } } - Properties properties = new Properties(); properties.put( "helpPackageName", helpPackageName == null ? "" : helpPackageName ); @@ -316,9 +318,13 @@ public class PluginHelpGenerator protected static String discoverPackageName( PluginDescriptor pluginDescriptor ) { Map packageNames = new HashMap(); - for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); ) + List mojoDescriptors = pluginDescriptor.getMojos(); + if ( mojoDescriptors == null ) + { + return ""; + } + for ( MojoDescriptor descriptor : mojoDescriptors ) { - MojoDescriptor descriptor = (MojoDescriptor) it.next(); String impl = descriptor.getImplementation(); if ( StringUtils.equals( descriptor.getGoal(), "help" ) && StringUtils.equals( "HelpMojo", impl ) )