[maven-release-plugin] copy for tag maven-plugin-tools-3.2

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/tags/maven-plugin-tools-3.2@1406562 13f79535-47bb-0310-9956-ffa450edef68
Kristian Rosenvold 2012-11-07 11:31:59 +00:00
commit eef0a7817c
19 changed files with 148 additions and 92 deletions

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>maven-plugin-tools</artifactId>
<groupId>org.apache.maven.plugin-tools</groupId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-annotations</artifactId>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>maven-plugin-tools</artifactId>
<groupId>org.apache.maven.plugin-tools</groupId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -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.
@ -61,19 +62,29 @@ public class DescriptorGeneratorMojo
@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
{

View File

@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-annotations</artifactId>

View File

@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-ant</artifactId>

View File

@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-api</artifactId>

View File

@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-beanshell</artifactId>

View File

@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-generators</artifactId>

View File

@ -19,20 +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.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;
@ -45,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 <a href="/ref/current/maven-plugin-api/plugin.html">Maven Plugin Descriptor XML file</a> and
@ -59,6 +59,13 @@ public class PluginDescriptorGenerator
implements Generator
{
private final Logger log;
public PluginDescriptorGenerator( Logger log )
{
this.log = log;
}
/**
* {@inheritDoc}
*/
@ -66,7 +73,7 @@ public class PluginDescriptorGenerator
throws GeneratorException
{
// eventually rewrite help mojo class to match actual package name
PluginHelpGenerator.rewriteHelpMojo( request );
PluginHelpGenerator.rewriteHelpMojo( request, log );
try
{
@ -77,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 );

View File

@ -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,23 @@ 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." );
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 );
}
else
{
destinationDirectory = new File( destDir );
}
String helpMojoImplementation = rewriteHelpClassToMojoPackage( request, destinationDirectory, log );
if ( helpMojoImplementation != null )
{
@ -314,7 +329,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,6 +348,13 @@ public class PluginHelpGenerator
// rewrite help mojo source
File helpSourceFile = new File( destinationDirectory, HELP_MOJO_CLASS_NAME + ".java" );
if ( !helpSourceFile.exists() )
{
log.warn( "HelpMojo.java not found in default location: " + helpSourceFile.getAbsolutePath() );
log.warn( "Help goal source won't be moved to package: " + destinationPackage );
}
else
{
File helpSourceFileNew = new File( destinationDirectory, packageAsDirectory + '/' + HELP_MOJO_CLASS_NAME + ".java" );
if ( !helpSourceFileNew.getParentFile().exists() )
{
@ -361,6 +383,7 @@ public class PluginHelpGenerator
}
helpSourceFileNew.setLastModified( helpSourceFile.lastModified() );
helpSourceFile.delete();
}
// rewrite help mojo .class
File rewriteHelpClassFile =

View File

@ -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 <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @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 );
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 )
{

View File

@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-java</artifactId>

View File

@ -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,7 +79,8 @@ 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()
{
@ -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 );
@ -138,8 +139,8 @@ 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<Parameter> parameters = mojoDescriptor.getParameters();
@SuppressWarnings( "unchecked" ) List<Parameter> parameters = mojoDescriptor.getParameters();
assertEquals( 1, parameters.size() );

View File

@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-javadoc</artifactId>

View File

@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-model</artifactId>

View File

@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-script</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-script-ant</artifactId>

View File

@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-script</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-script-beanshell</artifactId>

View File

@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
</parent>
<artifactId>maven-script</artifactId>

13
pom.xml
View File

@ -29,7 +29,7 @@
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>3.2</version>
<version>3.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maven Plugin Tools</name>
@ -142,9 +142,9 @@
</modules>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugin-tools/tags/maven-plugin-tools-3.2</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugin-tools/tags/maven-plugin-tools-3.2</developerConnection>
<url>http://svn.apache.org/viewvc/maven/plugin-tools/tags/maven-plugin-tools-3.2</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugin-tools/trunk</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugin-tools/trunk</developerConnection>
<url>http://svn.apache.org/viewvc/maven/plugin-tools/trunk</url>
</scm>
<issueManagement>
<system>jira</system>
@ -375,6 +375,11 @@
<id>reporting</id>
<reporting>
<plugins>
<plugin><!-- TODO remove when upgrading parent to version 23 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>