From a5647ce2c81499718e7a8b48b693530701b97c3c Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Tue, 6 Nov 2012 16:57:58 +0000 Subject: [PATCH 1/5] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1406221 13f79535-47bb-0310-9956-ffa450edef68 --- maven-plugin-annotations/pom.xml | 2 +- maven-plugin-plugin/pom.xml | 2 +- maven-plugin-tools-annotations/pom.xml | 2 +- maven-plugin-tools-ant/pom.xml | 2 +- maven-plugin-tools-api/pom.xml | 2 +- maven-plugin-tools-beanshell/pom.xml | 2 +- maven-plugin-tools-generators/pom.xml | 2 +- maven-plugin-tools-java/pom.xml | 2 +- maven-plugin-tools-javadoc/pom.xml | 2 +- maven-plugin-tools-model/pom.xml | 2 +- maven-script/maven-script-ant/pom.xml | 2 +- maven-script/maven-script-beanshell/pom.xml | 2 +- maven-script/pom.xml | 2 +- pom.xml | 8 ++++---- 14 files changed, 17 insertions(+), 17 deletions(-) diff --git a/maven-plugin-annotations/pom.xml b/maven-plugin-annotations/pom.xml index 5878e4f..4c21242 100644 --- a/maven-plugin-annotations/pom.xml +++ b/maven-plugin-annotations/pom.xml @@ -23,7 +23,7 @@ maven-plugin-tools org.apache.maven.plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-annotations diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml index 2b97064..f1ae250 100644 --- a/maven-plugin-plugin/pom.xml +++ b/maven-plugin-plugin/pom.xml @@ -23,7 +23,7 @@ maven-plugin-tools org.apache.maven.plugin-tools - 3.2 + 3.3-SNAPSHOT org.apache.maven.plugins diff --git a/maven-plugin-tools-annotations/pom.xml b/maven-plugin-tools-annotations/pom.xml index cda2118..7ea96a5 100644 --- a/maven-plugin-tools-annotations/pom.xml +++ b/maven-plugin-tools-annotations/pom.xml @@ -22,7 +22,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-tools-annotations diff --git a/maven-plugin-tools-ant/pom.xml b/maven-plugin-tools-ant/pom.xml index a6dfbfa..0469773 100644 --- a/maven-plugin-tools-ant/pom.xml +++ b/maven-plugin-tools-ant/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-tools-ant diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml index 49be752..a1f9f80 100644 --- a/maven-plugin-tools-api/pom.xml +++ b/maven-plugin-tools-api/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-tools-api diff --git a/maven-plugin-tools-beanshell/pom.xml b/maven-plugin-tools-beanshell/pom.xml index af34aae..e9c50e8 100644 --- a/maven-plugin-tools-beanshell/pom.xml +++ b/maven-plugin-tools-beanshell/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-tools-beanshell diff --git a/maven-plugin-tools-generators/pom.xml b/maven-plugin-tools-generators/pom.xml index a183b47..55570c0 100644 --- a/maven-plugin-tools-generators/pom.xml +++ b/maven-plugin-tools-generators/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-tools-generators diff --git a/maven-plugin-tools-java/pom.xml b/maven-plugin-tools-java/pom.xml index 985ba39..cbb9276 100644 --- a/maven-plugin-tools-java/pom.xml +++ b/maven-plugin-tools-java/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-tools-java diff --git a/maven-plugin-tools-javadoc/pom.xml b/maven-plugin-tools-javadoc/pom.xml index 5aea09f..aed6d58 100644 --- a/maven-plugin-tools-javadoc/pom.xml +++ b/maven-plugin-tools-javadoc/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-tools-javadoc diff --git a/maven-plugin-tools-model/pom.xml b/maven-plugin-tools-model/pom.xml index bac73de..5d8b3f6 100644 --- a/maven-plugin-tools-model/pom.xml +++ b/maven-plugin-tools-model/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-plugin-tools-model diff --git a/maven-script/maven-script-ant/pom.xml b/maven-script/maven-script-ant/pom.xml index bb44da7..930eb9c 100644 --- a/maven-script/maven-script-ant/pom.xml +++ b/maven-script/maven-script-ant/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugin-tools maven-script - 3.2 + 3.3-SNAPSHOT maven-script-ant diff --git a/maven-script/maven-script-beanshell/pom.xml b/maven-script/maven-script-beanshell/pom.xml index ee75c40..2b870e3 100644 --- a/maven-script/maven-script-beanshell/pom.xml +++ b/maven-script/maven-script-beanshell/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugin-tools maven-script - 3.2 + 3.3-SNAPSHOT maven-script-beanshell diff --git a/maven-script/pom.xml b/maven-script/pom.xml index 7e86dbb..c38414d 100644 --- a/maven-script/pom.xml +++ b/maven-script/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT maven-script diff --git a/pom.xml b/pom.xml index 221930a..8f263ba 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.plugin-tools maven-plugin-tools - 3.2 + 3.3-SNAPSHOT pom Maven Plugin Tools @@ -142,9 +142,9 @@ - scm:svn:http://svn.apache.org/repos/asf/maven/plugin-tools/tags/maven-plugin-tools-3.2 - scm:svn:https://svn.apache.org/repos/asf/maven/plugin-tools/tags/maven-plugin-tools-3.2 - http://svn.apache.org/viewvc/maven/plugin-tools/tags/maven-plugin-tools-3.2 + scm:svn:http://svn.apache.org/repos/asf/maven/plugin-tools/trunk + scm:svn:https://svn.apache.org/repos/asf/maven/plugin-tools/trunk + http://svn.apache.org/viewvc/maven/plugin-tools/trunk jira From 5d366fc36f7a2e59c0447c343e57c982d83063a3 Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Wed, 7 Nov 2012 06:30:21 +0000 Subject: [PATCH 2/5] upgraded mpir to 2.6 to avoid MPIR-255 git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1406474 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 8f263ba..09cdb05 100644 --- a/pom.xml +++ b/pom.xml @@ -375,6 +375,11 @@ reporting + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.6 + org.apache.maven.plugins maven-javadoc-plugin From 805e0f84a7700740458015444559496ad2304f65 Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Wed, 7 Nov 2012 07:20:12 +0000 Subject: [PATCH 3/5] [MPLUGIN-227] o avoid NPE but get (intended-)explicit warning when unexpected situation happens (probably caused by using different plugin version between source generation and XML descriptor generation phases) o try guessing the directory in such situation, using default location o but don't fail in any case: git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1406480 13f79535-47bb-0310-9956-ffa450edef68 --- .../generator/PluginDescriptorGenerator.java | 4 +- .../plugin/generator/PluginHelpGenerator.java | 78 ++++++++++++------- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java index c6985d1..f49fa13 100644 --- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java +++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java @@ -28,6 +28,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.tools.plugin.ExtendedMojoDescriptor; import org.apache.maven.tools.plugin.PluginToolsRequest; import org.apache.maven.tools.plugin.util.PluginUtils; +import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; @@ -56,6 +57,7 @@ import java.util.Set; * get validation directives to help users in IDEs. */ public class PluginDescriptorGenerator + extends AbstractLogEnabled implements Generator { @@ -66,7 +68,7 @@ public class PluginDescriptorGenerator throws GeneratorException { // eventually rewrite help mojo class to match actual package name - PluginHelpGenerator.rewriteHelpMojo( request ); + PluginHelpGenerator.rewriteHelpMojo( request, getLogger() ); try { diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java index 1a564e1..6fc53b0 100644 --- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java +++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java @@ -285,7 +285,7 @@ public class PluginHelpGenerator * @param request * @throws GeneratorException */ - static void rewriteHelpMojo( PluginToolsRequest request ) + static void rewriteHelpMojo( PluginToolsRequest request, Logger log ) throws GeneratorException { File tmpPropertiesFile = @@ -303,8 +303,22 @@ public class PluginHelpGenerator // if helpPackageName property is empty, we have to rewrite the class with a better package name than empty if ( StringUtils.isEmpty( helpPackageName ) ) { - File destinationDirectory = new File( properties.getProperty( "destinationDirectory" ) ); - String helpMojoImplementation = rewriteHelpClassToMojoPackage( request, destinationDirectory ); + String destDir = properties.getProperty( "destinationDirectory" ); + File destinationDirectory; + if ( StringUtils.isEmpty( destDir ) ) + { + // writeHelpPropertiesFile() creates 2 properties: find one without the other should not be possible + log.warn( "\n\nUnexpected situation: destinationDirectory not defined in " + HELP_PROPERTIES_FILENAME + + " during help mojo source generation but expected during XML descriptor generation." ); + log.warn( "Please check helpmojo goal version used in previous build phase." ); + destinationDirectory = new File( "target/generated-sources/plugin" ); + log.warn( "Trying default location: " + destinationDirectory ); + } + else + { + destinationDirectory = new File( destDir ); + } + String helpMojoImplementation = rewriteHelpClassToMojoPackage( request, destinationDirectory, log ); if ( helpMojoImplementation != null ) { @@ -314,7 +328,7 @@ public class PluginHelpGenerator } } - private static String rewriteHelpClassToMojoPackage( PluginToolsRequest request, File destinationDirectory ) + private static String rewriteHelpClassToMojoPackage( PluginToolsRequest request, File destinationDirectory, Logger log ) throws GeneratorException { String destinationPackage = GeneratorUtils.discoverPackageName( request.getPluginDescriptor() ); @@ -333,34 +347,42 @@ public class PluginHelpGenerator // rewrite help mojo source File helpSourceFile = new File( destinationDirectory, HELP_MOJO_CLASS_NAME + ".java" ); - File helpSourceFileNew = new File( destinationDirectory, packageAsDirectory + '/' + HELP_MOJO_CLASS_NAME + ".java" ); - if ( !helpSourceFileNew.getParentFile().exists() ) + if ( !helpSourceFile.exists() ) { - helpSourceFileNew.getParentFile().mkdirs(); + log.warn( "HelpMojo.java not found in default location: " + helpSourceFile.getAbsolutePath() ); + log.warn( "Help goal source won't be moved to package: " + destinationPackage ); } - Reader sourceReader = null; - PrintWriter sourceWriter = null; - try + else { - sourceReader = new InputStreamReader( new FileInputStream( helpSourceFile ), request.getEncoding() ); - sourceWriter = - new PrintWriter( new OutputStreamWriter( new FileOutputStream( helpSourceFileNew ), - request.getEncoding() ) ); - - sourceWriter.println( "package " + destinationPackage + ";" ); - IOUtil.copy( sourceReader, sourceWriter ); + File helpSourceFileNew = new File( destinationDirectory, packageAsDirectory + '/' + HELP_MOJO_CLASS_NAME + ".java" ); + if ( !helpSourceFileNew.getParentFile().exists() ) + { + helpSourceFileNew.getParentFile().mkdirs(); + } + Reader sourceReader = null; + PrintWriter sourceWriter = null; + try + { + sourceReader = new InputStreamReader( new FileInputStream( helpSourceFile ), request.getEncoding() ); + sourceWriter = + new PrintWriter( new OutputStreamWriter( new FileOutputStream( helpSourceFileNew ), + request.getEncoding() ) ); + + sourceWriter.println( "package " + destinationPackage + ";" ); + IOUtil.copy( sourceReader, sourceWriter ); + } + catch ( IOException e ) + { + throw new GeneratorException( e.getMessage(), e ); + } + finally + { + IOUtil.close( sourceReader ); + IOUtil.close( sourceWriter ); + } + helpSourceFileNew.setLastModified( helpSourceFile.lastModified() ); + helpSourceFile.delete(); } - catch ( IOException e ) - { - throw new GeneratorException( e.getMessage(), e ); - } - finally - { - IOUtil.close( sourceReader ); - IOUtil.close( sourceWriter ); - } - helpSourceFileNew.setLastModified( helpSourceFile.lastModified() ); - helpSourceFile.delete(); // rewrite help mojo .class File rewriteHelpClassFile = From b66095855db6d0dfbcbb7c262f7c28ee3f5df61c Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Wed, 7 Nov 2012 10:49:01 +0000 Subject: [PATCH 4/5] o Logging works even better when the logger is not null git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1406538 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugin/DescriptorGeneratorMojo.java | 27 ++++++++---- .../generator/PluginDescriptorGenerator.java | 42 ++++++++++--------- .../generator/AbstractGeneratorTestCase.java | 23 +++++++--- .../java/JavaMojoDescriptorExtractorTest.java | 32 +++++++------- 4 files changed, 75 insertions(+), 49 deletions(-) diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java index 71d5b62..9bd738d 100644 --- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java +++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java @@ -19,15 +19,16 @@ package org.apache.maven.plugin.plugin; * under the License. */ +import java.io.File; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.tools.plugin.generator.Generator; import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator; - -import java.io.File; +import org.codehaus.plexus.logging.Logger; /** * Generate a plugin descriptor. @@ -43,7 +44,7 @@ import java.io.File; * @since 2.0 */ @Mojo( name = "descriptor", defaultPhase = LifecyclePhase.PROCESS_CLASSES, - requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) + requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) public class DescriptorGeneratorMojo extends AbstractGeneratorMojo { @@ -55,25 +56,35 @@ public class DescriptorGeneratorMojo /** * A flag to disable generation of the plugin.xml in favor of a hand authored plugin descriptor. - * + * * @since 2.6 */ @Parameter( defaultValue = "false" ) private boolean skipDescriptor; - /** {@inheritDoc} */ + @Component + protected Logger logger; + + + /** + * {@inheritDoc} + */ protected File getOutputDirectory() { return outputDirectory; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ protected Generator createGenerator() { - return new PluginDescriptorGenerator(); + return new PluginDescriptorGenerator( logger ); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ public void execute() throws MojoExecutionException { diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java index f49fa13..0fc7f34 100644 --- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java +++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java @@ -19,21 +19,6 @@ package org.apache.maven.tools.plugin.generator; * under the License. */ -import org.apache.maven.plugin.descriptor.DuplicateMojoDescriptorException; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.Parameter; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugin.descriptor.Requirement; -import org.apache.maven.project.MavenProject; -import org.apache.maven.tools.plugin.ExtendedMojoDescriptor; -import org.apache.maven.tools.plugin.PluginToolsRequest; -import org.apache.maven.tools.plugin.util.PluginUtils; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; -import org.codehaus.plexus.util.xml.XMLWriter; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -46,6 +31,20 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.maven.plugin.descriptor.DuplicateMojoDescriptorException; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.plugin.descriptor.Requirement; +import org.apache.maven.project.MavenProject; +import org.apache.maven.tools.plugin.ExtendedMojoDescriptor; +import org.apache.maven.tools.plugin.PluginToolsRequest; +import org.apache.maven.tools.plugin.util.PluginUtils; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; +import org.codehaus.plexus.util.xml.XMLWriter; /** * Generate a Maven Plugin Descriptor XML file and @@ -57,10 +56,16 @@ import java.util.Set; * get validation directives to help users in IDEs. */ public class PluginDescriptorGenerator - extends AbstractLogEnabled implements Generator { + private final Logger log; + + public PluginDescriptorGenerator( Logger log ) + { + this.log = log; + } + /** * {@inheritDoc} */ @@ -68,7 +73,7 @@ public class PluginDescriptorGenerator throws GeneratorException { // eventually rewrite help mojo class to match actual package name - PluginHelpGenerator.rewriteHelpMojo( request, getLogger() ); + PluginHelpGenerator.rewriteHelpMojo( request, log ); try { @@ -79,8 +84,7 @@ public class PluginDescriptorGenerator // write plugin-help.xml help-descriptor MavenProject mavenProject = request.getProject(); - f = - new File( mavenProject.getBuild().getOutputDirectory(), + f = new File( mavenProject.getBuild().getOutputDirectory(), PluginHelpGenerator.getPluginHelpPath( mavenProject ) ); writeDescriptor( f, request, true ); diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java index 7a0ae75..a9dd77b 100644 --- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java +++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java @@ -19,6 +19,11 @@ package org.apache.maven.tools.plugin.generator; * under the License. */ +import java.io.File; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import org.apache.maven.model.Build; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; @@ -27,13 +32,9 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.tools.plugin.DefaultPluginToolsRequest; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.repository.ComponentDependency; +import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - /** * @author Jason van Zyl * @version $Id: AbstractGeneratorTestCase.java,v 1.1 2005/02/20 16:25:21 @@ -136,7 +137,17 @@ public abstract class AbstractGeneratorTestCase { Class generatorClass = Thread.currentThread().getContextClassLoader().loadClass( generatorClassName ); - generator = (Generator) generatorClass.newInstance(); + Logger logger = getContainer().getLogger(); + try + { + Constructor constructor = generatorClass.getConstructor( Logger.class ); + generator = (Generator) constructor.newInstance( logger ); + } + catch ( NoSuchMethodException ignore ) + { + generator = (Generator) generatorClass.newInstance(); + + } } catch ( Exception e ) { diff --git a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java index a30b1e7..96b2b25 100644 --- a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java +++ b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java @@ -19,7 +19,10 @@ package org.apache.maven.tools.plugin.extractor.java; * under the License. */ -import junit.framework.TestCase; +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.plugin.descriptor.MojoDescriptor; @@ -36,15 +39,12 @@ import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.FileUtils; + +import junit.framework.TestCase; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; import org.w3c.dom.Document; -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - /** * @author jdcasey */ @@ -79,13 +79,14 @@ public class JavaMojoDescriptorExtractorTest model.setArtifactId( "maven-unitTesting-plugin" ); MavenProject project = new MavenProject( model ); - project.setBuild( new Build(){ + project.setBuild( new Build() + { @Override public String getOutputDirectory() { return System.getProperty( "filePath" ); } - }); + } ); project.setFile( new File( root, "pom.xml" ) ); project.addCompileSourceRoot( new File( root, directory ).getPath() ); @@ -120,7 +121,7 @@ public class JavaMojoDescriptorExtractorTest request.getPluginDescriptor().addMojo( mojoDescriptor ); } - Generator descriptorGenerator = new PluginDescriptorGenerator(); + Generator descriptorGenerator = new PluginDescriptorGenerator( new ConsoleLogger( 0, "A" ) ); descriptorGenerator.execute( new File( root, directory ), request ); @@ -137,9 +138,9 @@ public class JavaMojoDescriptorExtractorTest XMLUnit.setIgnoreWhitespace( true ); XMLUnit.setIgnoreComments( true ); - - Document expected = - XMLUnit.buildControlDocument( FileUtils.fileRead( new File( testDirectory, "plugin-expected.xml" ), "UTF-8" ) ); + + Document expected = XMLUnit.buildControlDocument( + FileUtils.fileRead( new File( testDirectory, "plugin-expected.xml" ), "UTF-8" ) ); Document actual = XMLUnit.buildTestDocument( FileUtils.fileRead( new File( testDirectory, "plugin.xml" ), "UTF-8" ) ); @@ -182,8 +183,7 @@ public class JavaMojoDescriptorExtractorTest MojoDescriptor mojoDescriptor = results.get( 0 ); - @SuppressWarnings( "unchecked" ) - List parameters = mojoDescriptor.getParameters(); + @SuppressWarnings( "unchecked" ) List parameters = mojoDescriptor.getParameters(); assertEquals( 1, parameters.size() ); @@ -206,7 +206,7 @@ public class JavaMojoDescriptorExtractorTest /** * Check that the mojo descriptor extractor will ignore any annotations that are found. - * + * * @throws Exception */ public void testAnnotationInPlugin() @@ -216,7 +216,7 @@ public class JavaMojoDescriptorExtractorTest assertNull( results ); } - + /** * Check that the mojo descriptor extractor will successfully parse sources with Java 1.5 language features like * generics. From 43755711de396a5705da429a778587bc80554be9 Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Wed, 7 Nov 2012 11:17:02 +0000 Subject: [PATCH 5/5] o Added additional message with underlying cause git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1406554 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/tools/plugin/generator/PluginHelpGenerator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java index 6fc53b0..1180a46 100644 --- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java +++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java @@ -311,6 +311,7 @@ public class PluginHelpGenerator log.warn( "\n\nUnexpected situation: destinationDirectory not defined in " + HELP_PROPERTIES_FILENAME + " during help mojo source generation but expected during XML descriptor generation." ); log.warn( "Please check helpmojo goal version used in previous build phase." ); + log.warn("If you just upgraded to plugin-tools >= 3.2 you must run a clean build at least once"); destinationDirectory = new File( "target/generated-sources/plugin" ); log.warn( "Trying default location: " + destinationDirectory ); }