You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/05/12 12:27:53 UTC
svn commit: r1337500 [2/3] - in /maven/plugin-tools/trunk: ./
maven-plugin-annotations/ maven-plugin-plugin/ maven-plugin-plugin/src/it/
maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/
maven-plugin-plugin/src/it/annotation-with-inheri...
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java Sat May 12 10:27:50 2012
@@ -19,11 +19,12 @@ package org.apache.maven.tools.plugin.ge
* 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.tools.plugin.DefaultPluginToolsRequest;
+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;
@@ -31,63 +32,130 @@ 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 org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.commons.RemappingClassAdapter;
+import org.objectweb.asm.commons.SimpleRemapper;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
/**
+ * @version $Id$
* @todo add example usage tag that can be shown in the doco
* @todo need to add validation directives so that systems embedding maven2 can
* get validation directives to help users in IDEs.
- *
- * @version $Id$
*/
public class PluginDescriptorGenerator
implements Generator
{
- /** {@inheritDoc} */
- public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
- throws IOException
+
+ /**
+ * {@inheritDoc}
+ */
+ public void execute( File destinationDirectory, PluginToolsRequest request )
+ throws GeneratorException
{
- execute( destinationDirectory, new DefaultPluginToolsRequest( null, pluginDescriptor ) );
+
+ File tmpPropertiesFile =
+ new File( request.getProject().getBuild().getDirectory(), "maven-plugin-help.properties" );
+
+ if ( tmpPropertiesFile.exists() )
+ {
+ Properties properties = new Properties();
+ try
+ {
+ properties.load( new FileInputStream( tmpPropertiesFile ) );
+ }
+ catch ( IOException e )
+ {
+ throw new GeneratorException( e.getMessage(), e );
+ }
+ String helpPackageName = properties.getProperty( "helpPackageName" );
+ // if helpPackageName property is empty we have to rewrite the class with a better package name than empty
+ if ( StringUtils.isEmpty( helpPackageName ) )
+ {
+ String helpMojoImplementation = rewriteHelpClassToMojoPackage( request );
+ if ( helpMojoImplementation != null )
+ {
+ // rewrite plugin descriptor with new HelpMojo implementation class
+ rewriteDescriptor( request.getPluginDescriptor(), helpMojoImplementation );
+ }
+
+ }
+ }
+
+ try
+ {
+ File f = new File( destinationDirectory, "plugin.xml" );
+ writeDescriptor( f, request, false );
+ MavenProject mavenProject = request.getProject();
+ String pluginDescriptionFilePath =
+ "META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId()
+ + "/plugin-description.xml";
+ f = new File( request.getProject().getBuild().getOutputDirectory(), pluginDescriptionFilePath );
+ writeDescriptor( f, request, true );
+ }
+ catch ( IOException e )
+ {
+ throw new GeneratorException( e.getMessage(), e );
+ }
+ catch ( DuplicateMojoDescriptorException e )
+ {
+ throw new GeneratorException( e.getMessage(), e );
+ }
}
-
- /** {@inheritDoc} */
- public void execute( File destinationDirectory, PluginToolsRequest request )
- throws IOException
+
+ public void writeDescriptor( File destinationFile, PluginToolsRequest request, boolean cleanDescription )
+ throws IOException, DuplicateMojoDescriptorException
{
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
-
- String encoding = "UTF-8";
- File f = new File( destinationDirectory, "plugin.xml" );
-
- if ( !f.getParentFile().exists() )
+ if ( destinationFile.exists() )
{
- f.getParentFile().mkdirs();
+ destinationFile.delete();
+ }
+ else
+ {
+ if ( !destinationFile.getParentFile().exists() )
+ {
+ destinationFile.getParentFile().mkdirs();
+ }
}
+ String encoding = "UTF-8";
+
Writer writer = null;
try
{
- writer = new OutputStreamWriter( new FileOutputStream( f ), encoding );
+ writer = new OutputStreamWriter( new FileOutputStream( destinationFile ), encoding );
XMLWriter w = new PrettyPrintXMLWriter( writer, encoding, null );
w.startElement( "plugin" );
PluginUtils.element( w, "name", pluginDescriptor.getName() );
-
- PluginUtils.element( w, "description", pluginDescriptor.getDescription() );
+ if ( cleanDescription )
+ {
+ PluginUtils.element( w, "description", PluginUtils.toText( pluginDescriptor.getDescription() ) );
+ }
+ else
+ {
+ PluginUtils.element( w, "description", pluginDescriptor.getDescription() );
+ }
PluginUtils.element( w, "groupId", pluginDescriptor.getGroupId() );
@@ -105,11 +173,11 @@ public class PluginDescriptorGenerator
if ( pluginDescriptor.getMojos() != null )
{
- for ( @SuppressWarnings( "unchecked" )
- Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
+ for ( @SuppressWarnings( "unchecked" ) Iterator<MojoDescriptor> it =
+ pluginDescriptor.getMojos().iterator(); it.hasNext(); )
{
MojoDescriptor descriptor = it.next();
- processMojoDescriptor( descriptor, w );
+ processMojoDescriptor( descriptor, w, cleanDescription );
}
}
@@ -120,6 +188,7 @@ public class PluginDescriptorGenerator
w.endElement();
writer.flush();
+
}
finally
{
@@ -128,11 +197,143 @@ public class PluginDescriptorGenerator
}
/**
- * @param mojoDescriptor not null
- * @param w not null
+ * Creates a minimalistic mojo descriptor for the generated help goal.
+ *
+ * @param pluginDescriptor The descriptor of the plugin for which to generate a help goal, must not be
+ * <code>null</code>.
+ * @return The mojo descriptor for the generated help goal, never <code>null</code>.
*/
+ private MojoDescriptor makeHelpDescriptor( PluginDescriptor pluginDescriptor, String packageName )
+ {
+ MojoDescriptor descriptor = new MojoDescriptor();
+
+ descriptor.setPluginDescriptor( pluginDescriptor );
+
+ descriptor.setLanguage( "java" );
+
+ descriptor.setGoal( "help" );
+
+ if ( StringUtils.isEmpty( packageName ) )
+ {
+ packageName = discoverPackageName( pluginDescriptor );
+ }
+ if ( StringUtils.isNotEmpty( packageName ) )
+ {
+ descriptor.setImplementation( packageName + '.' + "HelpMojo" );
+ }
+ else
+ {
+ descriptor.setImplementation( "HelpMojo" );
+ }
+
+ descriptor.setDescription(
+ "Display help information on " + pluginDescriptor.getArtifactId() + ".<br/> Call <pre> mvn "
+ + descriptor.getFullGoalName()
+ + " -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details." );
+
+ try
+ {
+ Parameter param = new Parameter();
+ param.setName( "detail" );
+ param.setType( "boolean" );
+ param.setDescription( "If <code>true</code>, display all settable properties for each goal." );
+ param.setDefaultValue( "false" );
+ param.setExpression( "${detail}" );
+ descriptor.addParameter( param );
+
+ param = new Parameter();
+ param.setName( "goal" );
+ param.setType( "java.lang.String" );
+ param.setDescription(
+ "The name of the goal for which to show help." + " If unspecified, all goals will be displayed." );
+ param.setExpression( "${goal}" );
+ descriptor.addParameter( param );
+
+ param = new Parameter();
+ param.setName( "lineLength" );
+ param.setType( "int" );
+ param.setDescription( "The maximum length of a display line, should be positive." );
+ param.setDefaultValue( "80" );
+ param.setExpression( "${lineLength}" );
+ descriptor.addParameter( param );
+
+ param = new Parameter();
+ param.setName( "indentSize" );
+ param.setType( "int" );
+ param.setDescription( "The number of spaces per indentation level, should be positive." );
+ param.setDefaultValue( "2" );
+ param.setExpression( "${indentSize}" );
+ descriptor.addParameter( param );
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( "Failed to setup parameters for help goal", e );
+ }
+
+ return descriptor;
+ }
+
+ /**
+ * Find the best package name, based on the number of hits of actual Mojo classes.
+ *
+ * @param pluginDescriptor not null
+ * @return the best name of the package for the generated mojo
+ */
+ private static String discoverPackageName( PluginDescriptor pluginDescriptor )
+ {
+ Map packageNames = new HashMap();
+ for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
+ {
+ MojoDescriptor descriptor = (MojoDescriptor) it.next();
+
+ String impl = descriptor.getImplementation();
+ if ( impl.lastIndexOf( '.' ) != -1 )
+ {
+ String name = impl.substring( 0, impl.lastIndexOf( '.' ) );
+ if ( packageNames.get( name ) != null )
+ {
+ int next = ( (Integer) packageNames.get( name ) ).intValue() + 1;
+ packageNames.put( name, new Integer( next ) );
+ }
+ else
+ {
+ packageNames.put( name, new Integer( 1 ) );
+ }
+ }
+ else
+ {
+ packageNames.put( "", new Integer( 1 ) );
+ }
+ }
+
+ String packageName = "";
+ int max = 0;
+ for ( Iterator it = packageNames.keySet().iterator(); it.hasNext(); )
+ {
+ String key = it.next().toString();
+ int value = ( (Integer) packageNames.get( key ) ).intValue();
+ if ( value > max )
+ {
+ max = value;
+ packageName = key;
+ }
+ }
+
+ return packageName;
+ }
+
protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w )
{
+ processMojoDescriptor( mojoDescriptor, w, false );
+ }
+
+ /**
+ * @param mojoDescriptor not null
+ * @param w not null
+ * @param cleanDescription will clean html content from description fields
+ */
+ protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, boolean cleanDescription )
+ {
w.startElement( "mojo" );
// ----------------------------------------------------------------------
@@ -152,7 +353,14 @@ public class PluginDescriptorGenerator
if ( description != null )
{
w.startElement( "description" );
- w.writeText( mojoDescriptor.getDescription() );
+ if ( cleanDescription )
+ {
+ w.writeText( PluginUtils.toText( mojoDescriptor.getDescription() ) );
+ }
+ else
+ {
+ w.writeText( mojoDescriptor.getDescription() );
+ }
w.endElement();
}
@@ -323,8 +531,7 @@ public class PluginDescriptorGenerator
// Parameters
// ----------------------------------------------------------------------
- @SuppressWarnings( "unchecked" )
- List<Parameter> parameters = mojoDescriptor.getParameters();
+ @SuppressWarnings( "unchecked" ) List<Parameter> parameters = mojoDescriptor.getParameters();
w.startElement( "parameters" );
@@ -397,11 +604,17 @@ public class PluginDescriptorGenerator
PluginUtils.element( w, "required", Boolean.toString( parameter.isRequired() ) );
PluginUtils.element( w, "editable", Boolean.toString( parameter.isEditable() ) );
+ if ( cleanDescription )
+ {
+ PluginUtils.element( w, "description", PluginUtils.toText( parameter.getDescription() ) );
+ }
+ else
+ {
+ PluginUtils.element( w, "description", parameter.getDescription() );
+ }
- PluginUtils.element( w, "description", parameter.getDescription() );
-
- if ( StringUtils.isNotEmpty( parameter.getDefaultValue() )
- || StringUtils.isNotEmpty( parameter.getExpression() ) )
+ if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) || StringUtils.isNotEmpty(
+ parameter.getExpression() ) )
{
configuration.add( parameter );
}
@@ -480,4 +693,80 @@ public class PluginDescriptorGenerator
w.endElement();
}
+
+ protected String rewriteHelpClassToMojoPackage( PluginToolsRequest request )
+ throws GeneratorException
+ {
+ String destinationPackage = PluginHelpGenerator.discoverPackageName( request.getPluginDescriptor() );
+ if ( StringUtils.isEmpty( destinationPackage ) )
+ {
+ return null;
+ }
+ File helpClassFile = new File( request.getProject().getBuild().getOutputDirectory(), "HelpMojo.class" );
+ if ( !helpClassFile.exists() )
+ {
+ return null;
+ }
+ File rewriteHelpClassFile = new File(
+ request.getProject().getBuild().getOutputDirectory() + "/" + StringUtils.replace( destinationPackage, ".",
+ "/" ), "HelpMojo.class" );
+ if ( !rewriteHelpClassFile.getParentFile().exists() )
+ {
+ rewriteHelpClassFile.getParentFile().mkdirs();
+ }
+
+ ClassReader cr = null;
+ try
+ {
+ cr = new ClassReader( new FileInputStream( helpClassFile ) );
+ }
+ catch ( IOException e )
+ {
+ throw new GeneratorException( e.getMessage(), e );
+ }
+
+ ClassWriter cw = new ClassWriter( 0 );
+
+ ClassVisitor cv = new RemappingClassAdapter( cw, new SimpleRemapper( "HelpMojo",
+ StringUtils.replace( destinationPackage,
+ ".", "/" )
+ + "/HelpMojo" ) );
+
+ try
+ {
+ cr.accept( cv, ClassReader.EXPAND_FRAMES );
+ }
+ catch ( Throwable e )
+ {
+ throw new GeneratorException( "ASM issue processing classFile " + helpClassFile.getPath(), e );
+ }
+
+ byte[] renamedClass = cw.toByteArray();
+ FileOutputStream fos = null;
+ try
+ {
+ fos = new FileOutputStream( rewriteHelpClassFile );
+ fos.write( renamedClass );
+ }
+ catch ( IOException e )
+ {
+ throw new GeneratorException( "Error rewriting help class: " + e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtil.close( fos );
+ }
+ helpClassFile.delete();
+ return destinationPackage + ".HelpMojo";
+ }
+
+
+ private void rewriteDescriptor( PluginDescriptor pluginDescriptor, String helpMojoImplementation )
+ {
+ MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( "help" );
+ if ( mojoDescriptor != null )
+ {
+ mojoDescriptor.setImplementation( helpMojoImplementation );
+ }
+ }
}
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java Sat May 12 10:27:50 2012
@@ -19,32 +19,33 @@ package org.apache.maven.tools.plugin.ge
* under the License.
*/
+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.project.MavenProject;
+import org.apache.maven.tools.plugin.PluginToolsRequest;
+import org.apache.velocity.VelocityContext;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.io.StringWriter;
import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-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.tools.plugin.DefaultPluginToolsRequest;
-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.logging.Logger;
-import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-
/**
* Generates an <code>HelpMojo</code> class.
*
@@ -56,20 +57,30 @@ public class PluginHelpGenerator
extends AbstractLogEnabled
implements Generator
{
- /** Line separator */
+ /**
+ * Line separator
+ */
private static final String LS = System.getProperty( "line.separator" );
- /** Default generated class name */
+ /**
+ * Default generated class name
+ */
private static final String HELP_MOJO_CLASS_NAME = "HelpMojo";
- /** Default goal */
+ /**
+ * Default goal
+ */
private static final String HELP_GOAL = "help";
private String helpPackageName;
-
- /** Flag to indicate if the generated help mojo should use Java 5 features */
+
+ /**
+ * Flag to indicate if the generated help mojo should use Java 5 features
+ */
private boolean useJava5;
+ private VelocityComponent velocityComponent;
+
/**
* Default constructor
*/
@@ -82,47 +93,68 @@ public class PluginHelpGenerator
// Public methods
// ----------------------------------------------------------------------
- /** {@inheritDoc} */
- public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
- throws IOException
- {
- execute( destinationDirectory, new DefaultPluginToolsRequest( null, pluginDescriptor ) );
- }
-
- /** {@inheritDoc} */
+
+ /**
+ * {@inheritDoc}
+ */
public void execute( File destinationDirectory, PluginToolsRequest request )
- throws IOException
+ throws GeneratorException
{
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
-
- if ( pluginDescriptor.getMojos() == null || pluginDescriptor.getMojos().size() < 1 )
- {
- return;
- }
MojoDescriptor helpDescriptor = makeHelpDescriptor( pluginDescriptor );
- // Verify that no help goal already exists
- for ( @SuppressWarnings( "unchecked" )
- Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
- {
- MojoDescriptor descriptor = it.next();
+ List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
- if ( descriptor.getGoal().equals( helpDescriptor.getGoal() )
- && !descriptor.getImplementation().equals( helpDescriptor.getImplementation() ) )
+ if ( mojoDescriptors != null )
+ {
+ // 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;
}
+ }
+ }
+ Properties properties = new Properties();
+ properties.put( "helpPackageName", helpPackageName == null ? "" : helpPackageName );
+
+ MavenProject mavenProject = request.getProject();
- return;
+ String propertiesFilePath = "META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId();
+
+ File tmpPropertiesFile =
+ new File( request.getProject().getBuild().getDirectory(), "maven-plugin-help.properties" );
+ if ( tmpPropertiesFile.exists() )
+ {
+ tmpPropertiesFile.delete();
+ }
+ else
+ {
+ if ( !tmpPropertiesFile.getParentFile().exists() )
+ {
+ tmpPropertiesFile.getParentFile().mkdirs();
}
}
+ try
+ {
+ properties.store( new FileOutputStream( tmpPropertiesFile ), "maven plugin help generation informations" );
+ }
+ catch ( IOException e )
+ {
+ throw new GeneratorException( e.getMessage(), e );
+ }
+
String sourcePath = helpDescriptor.getImplementation().replace( '.', File.separatorChar ) + ".java";
File helpClass = new File( destinationDirectory, sourcePath );
helpClass.getParentFile().mkdirs();
@@ -131,13 +163,19 @@ public class PluginHelpGenerator
try
{
writer = new OutputStreamWriter( new FileOutputStream( helpClass ), request.getEncoding() );
- writeClass( writer, pluginDescriptor, helpDescriptor, useJava5 );
+ writer.write( getHelpClassSources( propertiesFilePath ) );
writer.flush();
}
+ catch ( IOException e )
+ {
+ throw new GeneratorException( e.getMessage(), e );
+ }
finally
{
IOUtil.close( writer );
}
+
+
}
public PluginHelpGenerator setHelpPackageName( String helpPackageName )
@@ -152,15 +190,52 @@ public class PluginHelpGenerator
return this;
}
+ public VelocityComponent getVelocityComponent()
+ {
+ return velocityComponent;
+ }
+
+ public PluginHelpGenerator setVelocityComponent( VelocityComponent velocityComponent )
+ {
+ this.velocityComponent = velocityComponent;
+ return this;
+ }
+
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
+ protected String getHelpClassSources( String propertiesFilePath )
+ {
+ Properties properties = new Properties();
+ VelocityContext context = new VelocityContext( properties );
+ if ( this.helpPackageName != null )
+ {
+ properties.put( "helpPackageName", this.helpPackageName );
+ }
+ else
+ {
+ properties.put( "helpPackageName", "" );
+ }
+ properties.put( "propertiesFilePath", propertiesFilePath + "/plugin-description.xml" );
+ // FIXME encoding !
+
+ StringWriter stringWriter = new StringWriter();
+
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "help-class-source.vm" );
+ InputStreamReader isReader = new InputStreamReader( is );
+ velocityComponent.getEngine().evaluate( context, stringWriter, "", isReader );
+
+ return stringWriter.toString();
+
+ }
+
+
/**
* Creates a minimalistic mojo descriptor for the generated help goal.
*
* @param pluginDescriptor The descriptor of the plugin for which to generate a help goal, must not be
- * <code>null</code>.
+ * <code>null</code>.
* @return The mojo descriptor for the generated help goal, never <code>null</code>.
*/
private MojoDescriptor makeHelpDescriptor( PluginDescriptor pluginDescriptor )
@@ -187,9 +262,10 @@ public class PluginHelpGenerator
descriptor.setImplementation( HELP_MOJO_CLASS_NAME );
}
- descriptor.setDescription( "Display help information on " + pluginDescriptor.getArtifactId()
- + ".<br/> Call <pre> mvn " + descriptor.getFullGoalName()
- + " -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details." );
+ descriptor.setDescription(
+ "Display help information on " + pluginDescriptor.getArtifactId() + ".<br/> Call <pre> mvn "
+ + descriptor.getFullGoalName()
+ + " -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details." );
try
{
@@ -204,8 +280,8 @@ public class PluginHelpGenerator
param = new Parameter();
param.setName( "goal" );
param.setType( "java.lang.String" );
- param.setDescription( "The name of the goal for which to show help."
- + " If unspecified, all goals will be displayed." );
+ param.setDescription(
+ "The name of the goal for which to show help." + " If unspecified, all goals will be displayed." );
param.setExpression( "${goal}" );
descriptor.addParameter( param );
@@ -239,597 +315,55 @@ public class PluginHelpGenerator
* @param pluginDescriptor not null
* @return the best name of the package for the generated mojo
*/
- private static String discoverPackageName( PluginDescriptor pluginDescriptor )
+ protected static String discoverPackageName( PluginDescriptor pluginDescriptor )
{
Map<String, Integer> packageNames = new HashMap<String, Integer>();
- for ( @SuppressWarnings( "unchecked" )
- Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
+ List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
+ if ( mojoDescriptors == null )
+ {
+ return "";
+ }
+ for ( MojoDescriptor descriptor : mojoDescriptors )
{
- MojoDescriptor descriptor = it.next();
-
- String name = "";
- int next = 1;
String impl = descriptor.getImplementation();
+ if ( StringUtils.equals( descriptor.getGoal(), "help" ) && StringUtils.equals( "HelpMojo", impl ) )
+ {
+ continue;
+ }
if ( impl.lastIndexOf( '.' ) != -1 )
{
- name = impl.substring( 0, impl.lastIndexOf( '.' ) );
- Integer count = packageNames.get( name );
-
- if ( count != null )
+ String name = impl.substring( 0, impl.lastIndexOf( '.' ) );
+ if ( packageNames.get( name ) != null )
{
- next = count.intValue() + 1;
+ int next = ( packageNames.get( name ) ).intValue() + 1;
+ packageNames.put( name, new Integer( next ) );
+ }
+ else
+ {
+ packageNames.put( name, new Integer( 1 ) );
}
}
-
- packageNames.put( name, next );
+ else
+ {
+ packageNames.put( "", new Integer( 1 ) );
+ }
}
String packageName = "";
int max = 0;
- for ( Map.Entry<String, Integer> entry : packageNames.entrySet() )
+ for ( Iterator it = packageNames.keySet().iterator(); it.hasNext(); )
{
- int value = entry.getValue().intValue();
+ String key = it.next().toString();
+ int value = ( packageNames.get( key ) ).intValue();
if ( value > max )
{
max = value;
- packageName = entry.getKey();
+ packageName = key;
}
}
return packageName;
}
- /**
- * Generates the <code>HelpMojo</code> class.
- *
- * @param writer not null
- * @param pluginDescriptor not null
- * @param helpDescriptor not null
- * @param useJava5 If the generated code should use Java5 features
- * @throws IOException if any
- */
- private static void writeClass( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor,
- boolean useJava5 )
- throws IOException
- {
- String packageName = "";
- String simpleName = helpDescriptor.getImplementation();
- int dot = simpleName.lastIndexOf( '.' );
- if ( dot >= 0 )
- {
- packageName = simpleName.substring( 0, dot );
- simpleName = simpleName.substring( dot + 1 );
- }
-
- if ( packageName.length() > 0 )
- {
- writer.write( "package " + packageName + ";" + LS );
- writer.write( LS );
- }
-
- writeImports( writer );
- writer.write( LS );
-
- writeMojoJavadoc( writer, pluginDescriptor, helpDescriptor );
-
- if ( useJava5 )
- {
- writer.write( "@SuppressWarnings( \"all\" )" + LS );
- }
-
- writer.write( "public class " + simpleName + LS );
- writer.write( " extends AbstractMojo" + LS );
- writer.write( "{" + LS );
-
- writeVariables( writer, helpDescriptor );
-
- writer.write( LS );
-
- writeExecute( writer, pluginDescriptor, helpDescriptor );
-
- writer.write( LS );
- writeUtilities( writer, useJava5 );
- writer.write( "}" + LS );
- }
-
- /**
- * @param writer not null
- * @throws IOException if any
- */
- private static void writeImports( Writer writer )
- throws IOException
- {
- writer.write( "import java.util.ArrayList;" + LS );
- writer.write( "import java.util.Iterator;" + LS );
- writer.write( "import java.util.List;" + LS );
- writer.write( LS );
- writer.write( "import org.apache.maven.plugin.AbstractMojo;" + LS );
- writer.write( "import org.apache.maven.plugin.MojoExecutionException;" + LS );
- }
-
- /**
- * @param writer not null
- * @param pluginDescriptor not null
- * @param helpDescriptor not null
- * @throws IOException if any
- */
- private static void writeMojoJavadoc( Writer writer, PluginDescriptor pluginDescriptor,
- MojoDescriptor helpDescriptor )
- throws IOException
- {
- StringBuffer author = new StringBuffer();
- author.append( PluginHelpGenerator.class.getName() );
-
- String resource = "META-INF/maven/org.apache.maven.plugin-tools/maven-plugin-tools-api/pom.properties";
- InputStream resourceAsStream = PluginHelpGenerator.class.getClassLoader().getResourceAsStream( resource );
-
- if ( resourceAsStream != null )
- {
- try
- {
- Properties properties = new Properties();
- properties.load( resourceAsStream );
-
- author.append( " (version " ).append( properties.getProperty( "version", "unknown" ) ).append( ")" );
- }
- catch ( IOException e )
- {
- // nope
- }
- finally
- {
- IOUtil.close( resourceAsStream );
- }
- }
-
- writer.write( "/**" + LS );
- writer.write( " * " + helpDescriptor.getDescription() + LS );
- writer.write( " *" + LS );
- writer.write( " * @version generated on " + new Date() + LS );
- writer.write( " * @author " + author.toString() + LS );
- writer.write( " * @goal " + helpDescriptor.getGoal() + LS );
- writer.write( " * @requiresProject false" + LS );
- writer.write( " * @threadSafe" + LS );
- writer.write( " */" + LS );
- }
-
- /**
- * @param writer not null
- * @param helpDescriptor not null
- * @throws IOException if any
- */
- private static void writeVariables( Writer writer, MojoDescriptor helpDescriptor )
- throws IOException
- {
- for ( @SuppressWarnings( "unchecked" )
- Iterator<Parameter> it = helpDescriptor.getParameters().iterator(); it.hasNext(); )
- {
- Parameter param = it.next();
- writer.write( " /**" + LS );
- writer.write( " * " + StringUtils.escape( param.getDescription() ) + LS );
- writer.write( " * " + LS );
- writer.write( " * @parameter" );
- if ( StringUtils.isNotEmpty( param.getExpression() ) )
- {
- writer.write( " expression=\"" );
- writer.write( StringUtils.escape( param.getExpression() ) );
- writer.write( "\"" );
- }
- if ( StringUtils.isNotEmpty( param.getDefaultValue() ) )
- {
- writer.write( " default-value=\"" );
- writer.write( StringUtils.escape( param.getDefaultValue() ) );
- writer.write( "\"" );
- }
- writer.write( LS );
- writer.write( " */" + LS );
- writer.write( " private " + param.getType() + " " + param.getName() + ";" + LS );
- writer.write( LS );
- }
- }
-
- /**
- * @param writer not null
- * @param pluginDescriptor not null
- * @param helpDescriptor not null
- * @throws IOException if any
- */
- private static void writeExecute( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor )
- throws IOException
- {
- List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>();
-
- mojoDescriptors.add( helpDescriptor );
- for ( @SuppressWarnings( "unchecked" )
- Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
- {
- MojoDescriptor mojoDescriptor = it.next();
-
- if ( !helpDescriptor.getGoal().equals( mojoDescriptor.getGoal() ) )
- {
- mojoDescriptors.add( mojoDescriptor );
- }
- }
-
- PluginUtils.sortMojos( mojoDescriptors );
-
- writer.write( " /** {@inheritDoc} */" + LS );
- writer.write( " public void execute()" + LS );
- writer.write( " throws MojoExecutionException" + LS );
- writer.write( " {" + LS );
-
- writer.write( " if ( lineLength <= 0 )" + LS );
- writer.write( " {" + LS );
- writer.write( " getLog().warn( \"The parameter 'lineLength' should be positive, using '80' as "
- + "default.\" );" + LS );
- writer.write( " lineLength = 80;" + LS );
- writer.write( " }" + LS );
- writer.write( " if ( indentSize <= 0 )" + LS );
- writer.write( " {" + LS );
- writer.write( " getLog().warn( \"The parameter 'indentSize' should be positive, using '2' as "
- + "default.\" );" + LS );
- writer.write( " indentSize = 2;" + LS );
- writer.write( " }" + LS );
- writer.write( LS );
-
- writer.write( " StringBuffer sb = new StringBuffer();" + LS );
- writer.write( LS );
-
- writer.write( " append( sb, \"" + StringUtils.escape( pluginDescriptor.getId() ) + "\", 0 );" + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
- writer.write( LS );
-
- if ( StringUtils.isNotEmpty( pluginDescriptor.getName() )
- && ( pluginDescriptor.getName().indexOf( pluginDescriptor.getId() ) != -1 ) )
- {
- writer.write( " append( sb, \""
- + StringUtils.escape( pluginDescriptor.getName() + " " + pluginDescriptor.getVersion() )
- + "\", 0 );" + LS );
- }
- else
- {
- if ( StringUtils.isNotEmpty( pluginDescriptor.getName() ) )
- {
- writer.write( " append( sb, \"" + StringUtils.escape( pluginDescriptor.getName() )
- + "\", 0 );" + LS );
- }
- else
- {
- writer.write( " append( sb, \"" + StringUtils.escape( pluginDescriptor.getId() )
- + "\", 0 );" + LS );
- }
- }
- writer.write( " append( sb, \"" + toDescription( pluginDescriptor.getDescription() ) + "\", 1 );"
- + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
- writer.write( LS );
-
- writer.write( " if ( goal == null || goal.length() <= 0 )" + LS );
- writer.write( " {" + LS );
- writer.write( " append( sb, \"This plugin has " + mojoDescriptors.size() + " "
- + ( mojoDescriptors.size() > 1 ? "goals" : "goal" ) + ":\", 0 );" + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
- writer.write( " }" + LS );
-
- writer.write( LS );
-
- for ( MojoDescriptor descriptor : mojoDescriptors )
- {
- writeGoal( writer, descriptor );
- }
-
- writer.write( " if ( getLog().isInfoEnabled() )" + LS );
- writer.write( " {" + LS );
- writer.write( " getLog().info( sb.toString() );" + LS );
- writer.write( " }" + LS );
- writer.write( " }" + LS );
- }
-
- /**
- * @param writer not null
- * @param descriptor not null
- * @throws IOException if any
- */
- private static void writeGoal( Writer writer, MojoDescriptor descriptor )
- throws IOException
- {
- String goalDescription = toDescription( descriptor.getDescription() );
-
- writer.write( " if ( goal == null || goal.length() <= 0 || \""
- + StringUtils.escape( descriptor.getGoal() ) + "\".equals( goal ) )" + LS );
- writer.write( " {" + LS );
- writer.write( " append( sb, \"" + StringUtils.escape( descriptor.getFullGoalName() ) + "\", 0 );"
- + LS );
- if ( StringUtils.isNotEmpty( descriptor.getDeprecated() ) )
- {
- writer.write( " append( sb, \"Deprecated. " + toDescription( descriptor.getDeprecated() )
- + "\", 1 );" + LS );
- writer.write( " if ( detail )" + LS );
- writer.write( " {" + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
- writer.write( " append( sb, \"" + goalDescription + "\", 1 );" + LS );
- writer.write( " }" + LS );
- }
- else
- {
- writer.write( " append( sb, \"" + goalDescription + "\", 1 );" + LS );
- }
- writer.write( " append( sb, \"\", 0 );" + LS );
-
- if ( descriptor.getParameters() != null && descriptor.getParameters().size() > 0 )
- {
- @SuppressWarnings( "unchecked" )
- List<Parameter> params = descriptor.getParameters();
-
- PluginUtils.sortMojoParameters( params );
-
- writer.write( " if ( detail )" + LS );
- writer.write( " {" + LS );
-
- writer.write( " append( sb, \"Available parameters:\", 1 );" + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
-
- for ( Parameter parameter : params )
- {
- if ( parameter.isEditable() )
- {
- writer.write( LS );
- writeParameter( writer, parameter );
- }
- }
-
- writer.write( " }" + LS );
- }
-
- writer.write( " }" + LS );
- writer.write( LS );
- }
-
- /**
- * @param writer not null
- * @param parameter not null
- * @throws IOException if any
- */
- private static void writeParameter( Writer writer, Parameter parameter )
- throws IOException
- {
- String expression = parameter.getExpression();
-
- if ( expression == null || !expression.startsWith( "${component." ) )
- {
- String parameterName = StringUtils.escape( parameter.getName() );
- String parameterDescription = toDescription( parameter.getDescription() );
- String parameterDefaultValue = "";
- if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) )
- {
- parameterDefaultValue = " (Default: " + StringUtils.escape( parameter.getDefaultValue() ) + ")";
- }
- writer.write( " append( sb, \"" + parameterName + parameterDefaultValue + "\", 2 );" + LS );
- if ( StringUtils.isNotEmpty( parameter.getDeprecated() ) )
- {
- writer.write( " append( sb, \"Deprecated. " + toDescription( parameter.getDeprecated() )
- + "\", 3 );" + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
- }
- writer.write( " append( sb, \"" + parameterDescription + "\", 3 );" + LS );
- if ( parameter.isRequired() )
- {
- writer.write( " append( sb, \"Required: Yes\", 3 );" + LS );
- }
- if ( StringUtils.isNotEmpty( parameter.getExpression() ) )
- {
- writer.write( " append( sb, \"Expression: "
- + StringUtils.escape( parameter.getExpression() ) + "\", 3 );" + LS );
- }
- writer.write( " append( sb, \"\", 0 );" + LS );
- }
- }
-
- /**
- * @param writer not null
- * @param useJava5 If the generated code should use Java5 features
- * @throws IOException if any
- */
- private static void writeUtilities( Writer writer, boolean useJava5 )
- throws IOException
- {
- writer.write( " /**" + LS );
- writer.write( " * <p>Repeat a String <code>n</code> times to form a new string.</p>" + LS );
- writer.write( " *" + LS );
- writer.write( " * @param str String to repeat" + LS );
- writer.write( " * @param repeat number of times to repeat str" + LS );
- writer.write( " * @return String with repeated String" + LS );
- writer.write( " * @throws NegativeArraySizeException if <code>repeat < 0</code>" + LS );
- writer.write( " * @throws NullPointerException if str is <code>null</code>" + LS );
- writer.write( " */" + LS );
- writer.write( " private static String repeat( String str, int repeat )" + LS );
- writer.write( " {" + LS );
- writer.write( " StringBuffer buffer = new StringBuffer( repeat * str.length() );" + LS );
- writer.write( LS );
- writer.write( " for ( int i = 0; i < repeat; i++ )" + LS );
- writer.write( " {" + LS );
- writer.write( " buffer.append( str );" + LS );
- writer.write( " }" + LS );
- writer.write( LS );
- writer.write( " return buffer.toString();" + LS );
- writer.write( " }" + LS );
-
- writer.write( LS );
- writer.write( " /** " + LS );
- writer.write( " * Append a description to the buffer by respecting the indentSize and lineLength "
- + "parameters." + LS );
- writer.write( " * <b>Note</b>: The last character is always a new line." + LS );
- writer.write( " * " + LS );
- writer.write( " * @param sb The buffer to append the description, not <code>null</code>." + LS );
- writer.write( " * @param description The description, not <code>null</code>." + LS );
- writer.write( " * @param indent The base indentation level of each line, must not be negative." + LS );
- writer.write( " */" + LS );
- writer.write( " private void append( StringBuffer sb, String description, int indent )" + LS );
- writer.write( " {" + LS );
- writer.write( " for ( Iterator it = toLines( description, indent, indentSize, lineLength )"
- + ".iterator(); it.hasNext(); )" + LS );
- writer.write( " {" + LS );
- writer.write( " sb.append( it.next().toString() ).append( '\\n' );" + LS );
- writer.write( " }" + LS );
- writer.write( " }" + LS );
-
- writer.write( LS );
- writer.write( " /** " + LS );
- writer.write( " * Splits the specified text into lines of convenient display length." + LS );
- writer.write( " * " + LS );
- writer.write( " * @param text The text to split into lines, must not be <code>null</code>." + LS );
- writer.write( " * @param indent The base indentation level of each line, must not be negative." + LS );
- writer.write( " * @param indentSize The size of each indentation, must not be negative." + LS );
- writer.write( " * @param lineLength The length of the line, must not be negative." + LS );
- writer.write( " * @return The sequence of display lines, never <code>null</code>." + LS );
- writer.write( " * @throws NegativeArraySizeException if <code>indent < 0</code>" + LS );
- writer.write( " */" + LS );
- writer.write( " private static List toLines( String text, int indent, int indentSize, int lineLength )"
- + LS );
- writer.write( " {" + LS );
- if ( useJava5 )
- {
- writer.write( " List<String> lines = new ArrayList<String>();" + LS );
- }
- else
- {
- writer.write( " List lines = new ArrayList();" + LS );
- }
- writer.write( LS );
- writer.write( " String ind = repeat( \"\\t\", indent );" + LS );
- writer.write( " String[] plainLines = text.split( \"(\\r\\n)|(\\r)|(\\n)\" );" + LS );
- writer.write( " for ( int i = 0; i < plainLines.length; i++ )" + LS );
- writer.write( " {" + LS );
- writer.write( " toLines( lines, ind + plainLines[i], indentSize, lineLength );" + LS );
- writer.write( " }" + LS );
- writer.write( LS );
- writer.write( " return lines;" + LS );
- writer.write( " }" + LS );
-
- writer.write( LS );
- writer.write( " /** " + LS );
- writer.write( " * Adds the specified line to the output sequence, performing line wrapping if necessary."
- + LS );
- writer.write( " * " + LS );
- writer.write( " * @param lines The sequence of display lines, must not be <code>null</code>." + LS );
- writer.write( " * @param line The line to add, must not be <code>null</code>." + LS );
- writer.write( " * @param indentSize The size of each indentation, must not be negative." + LS );
- writer.write( " * @param lineLength The length of the line, must not be negative." + LS );
- writer.write( " */" + LS );
- if ( useJava5 )
- {
- writer.write( " private static void toLines( List<String> lines, String line, int indentSize, int lineLength )"
- + LS );
- }
- else
- {
- writer.write( " private static void toLines( List lines, String line, int indentSize, int lineLength )"
- + LS );
- }
- writer.write( " {" + LS );
- writer.write( " int lineIndent = getIndentLevel( line );" + LS );
- writer.write( " StringBuffer buf = new StringBuffer( 256 );" + LS );
- writer.write( " String[] tokens = line.split( \" +\" );" + LS );
- writer.write( " for ( int i = 0; i < tokens.length; i++ )" + LS );
- writer.write( " {" + LS );
- writer.write( " String token = tokens[i];" + LS );
- writer.write( " if ( i > 0 )" + LS );
- writer.write( " {" + LS );
- writer.write( " if ( buf.length() + token.length() >= lineLength )" + LS );
- writer.write( " {" + LS );
- writer.write( " lines.add( buf.toString() );" + LS );
- writer.write( " buf.setLength( 0 );" + LS );
- writer.write( " buf.append( repeat( \" \", lineIndent * indentSize ) );" + LS );
- writer.write( " }" + LS );
- writer.write( " else" + LS );
- writer.write( " {" + LS );
- writer.write( " buf.append( ' ' );" + LS );
- writer.write( " }" + LS );
- writer.write( " }" + LS );
- writer.write( " for ( int j = 0; j < token.length(); j++ )" + LS );
- writer.write( " {" + LS );
- writer.write( " char c = token.charAt( j );" + LS );
- writer.write( " if ( c == '\\t' )" + LS );
- writer.write( " {" + LS );
- writer.write( " buf.append( repeat( \" \", indentSize - buf.length() % indentSize ) );"
- + LS );
- writer.write( " }" + LS );
- writer.write( " else if ( c == '\\u00A0' )" + LS );
- writer.write( " {" + LS );
- writer.write( " buf.append( ' ' );" + LS );
- writer.write( " }" + LS );
- writer.write( " else" + LS );
- writer.write( " {" + LS );
- writer.write( " buf.append( c );" + LS );
- writer.write( " }" + LS );
- writer.write( " }" + LS );
- writer.write( " }" + LS );
- writer.write( " lines.add( buf.toString() );" + LS );
- writer.write( " }" + LS );
-
- writer.write( LS );
- writer.write( " /** " + LS );
- writer.write( " * Gets the indentation level of the specified line." + LS );
- writer.write( " * " + LS );
- writer.write( " * @param line The line whose indentation level should be retrieved, must not be "
- + "<code>null</code>." + LS );
- writer.write( " * @return The indentation level of the line." + LS );
- writer.write( " */" + LS );
- writer.write( " private static int getIndentLevel( String line )" + LS );
- writer.write( " {" + LS );
- writer.write( " int level = 0;" + LS );
- writer.write( " for ( int i = 0; i < line.length() && line.charAt( i ) == '\\t'; i++ )" + LS );
- writer.write( " {" + LS );
- writer.write( " level++;" + LS );
- writer.write( " }" + LS );
- writer.write( " for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )" + LS );
- writer.write( " {" + LS );
- writer.write( " if ( line.charAt( i ) == '\\t' )" + LS );
- writer.write( " {" + LS );
- writer.write( " level++;" + LS );
- writer.write( " break;" + LS );
- writer.write( " }" + LS );
- writer.write( " }" + LS );
- writer.write( " return level;" + LS );
- writer.write( " }" + LS );
- }
-
- /**
- * Gets the effective string to use for the plugin/mojo/parameter description.
- *
- * @param description The description of the element, may be <code>null</code>.
- * @return The effective description string, never <code>null</code>.
- */
- private static String toDescription( String description )
- {
- if ( StringUtils.isNotEmpty( description ) )
- {
- return StringUtils.escape( PluginUtils.toText( description ) );
- }
-
- return "(no description available)";
- }
-
- /**
- * Converts a HTML fragment as extracted from a javadoc comment to a plain text string. This method tries to retain
- * as much of the text formatting as possible by means of the following transformations:
- * <ul>
- * <li>List items are converted to leading tabs (U+0009), followed by the item number/bullet, another tab and
- * finally the item contents. Each tab denotes an increase of indentation.</li>
- * <li>Flow breaking elements as well as literal line terminators in preformatted text are converted to a newline
- * (U+000A) to denote a mandatory line break.</li>
- * <li>Consecutive spaces and line terminators from character data outside of preformatted text will be normalized
- * to a single space. The resulting space denotes a possible point for line wrapping.</li>
- * <li>Each space in preformatted text will be converted to a non-breaking space (U+00A0).</li>
- * </ul>
- *
- * @param html The HTML fragment to convert to plain text, may be <code>null</code>.
- * @return A string with HTML tags converted into pure text, never <code>null</code>.
- * @deprecated since 2.4.3, using {@link PluginUtils#toText(String)} instead of.
- */
- protected static String toText( String html )
- {
- return PluginUtils.toText( html );
- }
}
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java Sat May 12 10:27:50 2012
@@ -19,6 +19,17 @@ package org.apache.maven.tools.plugin.ge
* under the License.
*/
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+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;
@@ -32,30 +43,21 @@ import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-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.project.MavenProject;
-import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
-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;
-
/**
- * @todo add example usage tag that can be shown in the doco
* @version $Id$
+ * @todo add example usage tag that can be shown in the doco
*/
public class PluginXdocGenerator
implements Generator
{
- /** locale */
+ /**
+ * locale
+ */
private final Locale locale;
- /** project */
+ /**
+ * project
+ */
private final MavenProject project;
/**
@@ -81,7 +83,7 @@ public class PluginXdocGenerator
/**
* @param project not null.
- * @param locale not null wanted locale.
+ * @param locale not null wanted locale.
*/
public PluginXdocGenerator( MavenProject project, Locale locale )
{
@@ -96,31 +98,35 @@ public class PluginXdocGenerator
}
}
- /** {@inheritDoc} */
- public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
- throws IOException
- {
- execute( destinationDirectory, new DefaultPluginToolsRequest( project, pluginDescriptor ) );
- }
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void execute( File destinationDirectory, PluginToolsRequest request )
- throws IOException
+ throws GeneratorException
{
- if ( request.getPluginDescriptor().getMojos() != null )
+ try
{
- for ( @SuppressWarnings( "unchecked" )
- Iterator<MojoDescriptor> it = request.getPluginDescriptor().getMojos().iterator(); it.hasNext(); )
+ if ( request.getPluginDescriptor().getMojos() != null )
{
- MojoDescriptor descriptor = it.next();
+ for ( @SuppressWarnings( "unchecked" ) Iterator<MojoDescriptor> it =
+ request.getPluginDescriptor().getMojos().iterator(); it.hasNext(); )
+ {
+ MojoDescriptor descriptor = it.next();
- processMojoDescriptor( descriptor, destinationDirectory );
+ processMojoDescriptor( descriptor, destinationDirectory );
+ }
}
}
+ catch ( IOException e )
+ {
+ throw new GeneratorException( e.getMessage(), e );
+ }
+
}
/**
- * @param mojoDescriptor not null
+ * @param mojoDescriptor not null
* @param destinationDirectory not null
* @throws IOException if any
*/
@@ -147,7 +153,7 @@ public class PluginXdocGenerator
/**
* @param mojo not null
- * @param ext not null
+ * @param ext not null
* @return the output file name
*/
private String getMojoFilename( MojoDescriptor mojo, String ext )
@@ -157,7 +163,7 @@ public class PluginXdocGenerator
/**
* @param mojoDescriptor not null
- * @param w not null
+ * @param w not null
*/
private void writeBody( MojoDescriptor mojoDescriptor, XMLWriter w )
{
@@ -196,8 +202,8 @@ public class PluginXdocGenerator
w.endElement(); //p
w.startElement( "p" );
w.writeMarkup( mojoDescriptor.getPluginDescriptor().getGroupId() + ":"
- + mojoDescriptor.getPluginDescriptor().getArtifactId() + ":"
- + mojoDescriptor.getPluginDescriptor().getVersion() + ":" + mojoDescriptor.getGoal() );
+ + mojoDescriptor.getPluginDescriptor().getArtifactId() + ":"
+ + mojoDescriptor.getPluginDescriptor().getVersion() + ":" + mojoDescriptor.getGoal() );
w.endElement(); //p
if ( StringUtils.isNotEmpty( mojoDescriptor.getDeprecated() ) )
@@ -237,7 +243,7 @@ public class PluginXdocGenerator
/**
* @param mojoDescriptor not null
- * @param w not null
+ * @param w not null
*/
private void writeReportNotice( MojoDescriptor mojoDescriptor, XMLWriter w )
{
@@ -252,7 +258,7 @@ public class PluginXdocGenerator
/**
* @param mojoDescriptor not null
- * @param w not null
+ * @param w not null
*/
private void writeGoalAttributes( MojoDescriptor mojoDescriptor, XMLWriter w )
{
@@ -273,12 +279,12 @@ public class PluginXdocGenerator
w.writeMarkup( getString( "pluginxdoc.mojodescriptor.projectRequired" ) );
w.endElement(); //li
}
-
+
if ( mojoDescriptor.isRequiresReports() )
{
if ( !addedUl )
{
- w.startElement( "ul" );
+ w.startElement( "ul" );
addedUl = true;
}
w.startElement( "li" );
@@ -451,12 +457,11 @@ public class PluginXdocGenerator
/**
* @param mojoDescriptor not null
- * @param w not null
+ * @param w not null
*/
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
{
- @SuppressWarnings( "unchecked" )
- List<Parameter> parameterList = mojoDescriptor.getParameters();
+ @SuppressWarnings( "unchecked" ) List<Parameter> parameterList = mojoDescriptor.getParameters();
//remove components and read-only parameters
List<Parameter> list = filterParameters( parameterList );
@@ -490,7 +495,7 @@ public class PluginXdocGenerator
if ( parameterList != null )
{
- for ( Parameter parameter : parameterList )
+ for ( Parameter parameter : parameterList )
{
if ( parameter.isEditable() )
{
@@ -509,8 +514,8 @@ public class PluginXdocGenerator
/**
* @param mojoDescriptor not null
- * @param parameterList not null
- * @param w not null
+ * @param parameterList not null
+ * @param w not null
*/
private void writeParameterDetails( MojoDescriptor mojoDescriptor, List<Parameter> parameterList, XMLWriter w )
{
@@ -570,8 +575,8 @@ public class PluginXdocGenerator
w.startElement( "ul" );
addedUl = true;
}
- writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.since" ),
- mojoDescriptor.getSince(), w );
+ writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.since" ), mojoDescriptor.getSince(),
+ w );
}
}
@@ -582,8 +587,8 @@ public class PluginXdocGenerator
w.startElement( "ul" );
addedUl = true;
}
- writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ),
- getString( "pluginxdoc.yes" ), w );
+ writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ), getString( "pluginxdoc.yes" ),
+ w );
}
else
{
@@ -592,8 +597,8 @@ public class PluginXdocGenerator
w.startElement( "ul" );
addedUl = true;
}
- writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ),
- getString( "pluginxdoc.no" ), w );
+ writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ), getString( "pluginxdoc.no" ),
+ w );
}
if ( !addedUl && StringUtils.isNotEmpty( parameter.getExpression() ) )
@@ -628,7 +633,7 @@ public class PluginXdocGenerator
/**
* @param param not null
* @param value could be null
- * @param w not null
+ * @param w not null
*/
private void writeDetail( String param, String value, XMLWriter w )
{
@@ -642,8 +647,8 @@ public class PluginXdocGenerator
/**
* @param mojoDescriptor not null
- * @param parameterList not null
- * @param w not null
+ * @param parameterList not null
+ * @param w not null
*/
private void writeParameterSummary( MojoDescriptor mojoDescriptor, List<Parameter> parameterList, XMLWriter w )
{
@@ -664,11 +669,12 @@ public class PluginXdocGenerator
/**
* @param mojoDescriptor not null
- * @param title not null
- * @param parameterList not null
- * @param w not null
+ * @param title not null
+ * @param parameterList not null
+ * @param w not null
*/
- private void writeParameterList( MojoDescriptor mojoDescriptor, String title, List<Parameter> parameterList, XMLWriter w )
+ private void writeParameterList( MojoDescriptor mojoDescriptor, String title, List<Parameter> parameterList,
+ XMLWriter w )
{
w.startElement( "subsection" );
w.addAttribute( "name", title );
@@ -722,9 +728,8 @@ public class PluginXdocGenerator
String description;
if ( StringUtils.isNotEmpty( parameter.getDeprecated() ) )
{
- description =
- format( "pluginxdoc.mojodescriptor.parameter.deprecated",
- PluginUtils.makeHtmlValid( parameter.getDeprecated() ) );
+ description = format( "pluginxdoc.mojodescriptor.parameter.deprecated",
+ PluginUtils.makeHtmlValid( parameter.getDeprecated() ) );
}
else if ( StringUtils.isNotEmpty( parameter.getDescription() ) )
{
@@ -750,7 +755,7 @@ public class PluginXdocGenerator
}
/**
- * @param required <code>true</code> for required parameters, <code>false</code> otherwise.
+ * @param required <code>true</code> for required parameters, <code>false</code> otherwise.
* @param parameterList not null
* @return list of parameters depending the value of <code>required</code>
*/
@@ -792,21 +797,21 @@ public class PluginXdocGenerator
/**
* Convenience method.
*
- * @param key not null
+ * @param key not null
* @param arg1 not null
* @return Localized, formatted text identified by <code>key</code>.
* @see #format(String, Object[])
*/
private String format( String key, Object arg1 )
{
- return format( key, new Object[] { arg1 } );
+ return format( key, new Object[]{ arg1 } );
}
/**
* Looks up the value for <code>key</code> in the <code>ResourceBundle</code>,
* then formats that value for the specified <code>Locale</code> using <code>args</code>.
*
- * @param key not null
+ * @param key not null
* @param args not null
* @return Localized, formatted text identified by <code>key</code>.
*/
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java Sat May 12 10:27:50 2012
@@ -19,11 +19,6 @@ package org.apache.maven.tools.plugin.sc
* under the License.
*/
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
@@ -36,6 +31,11 @@ import org.codehaus.plexus.logging.Abstr
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* @author jdcasey
*/
@@ -71,14 +71,18 @@ public class DefaultMojoScanner
// nop
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void populatePluginDescriptor( MavenProject project, PluginDescriptor pluginDescriptor )
throws ExtractionException, InvalidPluginDescriptorException
{
populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
}
-
- /** {@inheritDoc} */
+
+ /**
+ * {@inheritDoc}
+ */
public void populatePluginDescriptor( PluginToolsRequest request )
throws ExtractionException, InvalidPluginDescriptorException
{
@@ -103,7 +107,7 @@ public class DefaultMojoScanner
List<MojoDescriptor> extractorDescriptors = extractor.execute( request );
logger.info( "Mojo extractor for language: " + language + " found " + extractorDescriptors.size()
- + " mojo descriptors." );
+ + " mojo descriptors." );
numMojoDescriptors += extractorDescriptors.size();
for ( MojoDescriptor descriptor : extractorDescriptors )
@@ -116,10 +120,11 @@ public class DefaultMojoScanner
}
}
- if ( numMojoDescriptors == 0 )
+ if ( numMojoDescriptors == 0 && !request.isSkipErrorNoDescriptorsFound() )
{
- throw new InvalidPluginDescriptorException( "No mojo definitions were found for plugin: "
- + request.getPluginDescriptor().getPluginLookupKey() + "." );
+ throw new InvalidPluginDescriptorException(
+ "No mojo definitions were found for plugin: " + request.getPluginDescriptor().getPluginLookupKey()
+ + "." );
}
}
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java Sat May 12 10:27:50 2012
@@ -715,7 +715,7 @@ public final class PluginUtils
String text;
if ( preformatted > 0 )
{
- text = data.replace( ' ', '\u00A0' );
+ text = data;
}
else
{
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java Sat May 12 10:27:50 2012
@@ -19,11 +19,13 @@ package org.apache.maven.tools.plugin.ge
* under the License.
*/
-import junit.framework.TestCase;
+import org.apache.maven.model.Build;
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.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.util.FileUtils;
@@ -38,7 +40,7 @@ import java.util.List;
* jdcasey Exp $
*/
public abstract class AbstractGeneratorTestCase
- extends TestCase
+ extends PlexusTestCase
{
protected Generator generator;
@@ -47,6 +49,7 @@ public abstract class AbstractGeneratorT
protected void setUp()
throws Exception
{
+ super.setUp();
basedir = System.getProperty( "basedir" );
}
@@ -93,7 +96,25 @@ public abstract class AbstractGeneratorT
FileUtils.deleteDirectory( destinationDirectory );
destinationDirectory.mkdir();
- generator.execute( destinationDirectory, new DefaultPluginToolsRequest( null, pluginDescriptor ) );
+ MavenProject mavenProject = new MavenProject();
+ mavenProject.setGroupId( "foo" );
+ mavenProject.setArtifactId( "bar" );
+ mavenProject.setBuild( new Build()
+ {
+ @Override
+ public String getDirectory()
+ {
+ return basedir + "/target";
+ }
+
+ @Override
+ public String getOutputDirectory()
+ {
+ return basedir + "/target";
+ }
+ } );
+
+ generator.execute( destinationDirectory, new DefaultPluginToolsRequest( mavenProject, pluginDescriptor ) );
validate( destinationDirectory );
@@ -120,8 +141,8 @@ public abstract class AbstractGeneratorT
catch ( Exception e )
{
throw new Exception( "Cannot find " + generatorClassName +
- "! Make sure your test case is named in the form ${generatorClassName}Test " +
- "or override the setupPlugin() method to instantiate the mojo yourself." );
+ "! Make sure your test case is named in the form ${generatorClassName}Test " +
+ "or override the setupPlugin() method to instantiate the mojo yourself." );
}
}
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java Sat May 12 10:27:50 2012
@@ -19,6 +19,8 @@ package org.apache.maven.tools.plugin.ge
* under the License.
*/
+import org.codehaus.plexus.velocity.VelocityComponent;
+
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
@@ -27,4 +29,12 @@ public class PluginHelpGeneratorTest
extends AbstractGeneratorTestCase
{
// inherits tests from base class
+ protected void setupGenerator()
+ throws Exception
+ {
+
+ generator =
+ new PluginHelpGenerator().setVelocityComponent( (VelocityComponent) lookup( VelocityComponent.ROLE ) );
+
+ }
}
Modified: maven/plugin-tools/trunk/maven-plugin-tools-beanshell/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-beanshell/pom.xml?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-beanshell/pom.xml (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-beanshell/pom.xml Sat May 12 10:27:50 2012
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>2.10-SNAPSHOT</version>
+ <version>3.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-beanshell</artifactId>
Modified: maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-java/pom.xml Sat May 12 10:27:50 2012
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>2.10-SNAPSHOT</version>
+ <version>3.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-java</artifactId>
@@ -66,7 +66,6 @@
<dependency>
<groupId>com.thoughtworks.qdox</groupId>
<artifactId>qdox</artifactId>
- <version>1.11</version>
</dependency>
<dependency>
@@ -77,4 +76,18 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <filePath>${project.build.directory}</filePath>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
Modified: maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractorTest.java Sat May 12 10:27:50 2012
@@ -20,6 +20,7 @@ package org.apache.maven.tools.plugin.ex
*/
import junit.framework.TestCase;
+import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
@@ -77,6 +78,13 @@ public class JavaMojoDescriptorExtractor
model.setArtifactId( "maven-unitTesting-plugin" );
MavenProject project = new MavenProject( model );
+ 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() );
Modified: maven/plugin-tools/trunk/maven-plugin-tools-javadoc/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-javadoc/pom.xml?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-javadoc/pom.xml (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-javadoc/pom.xml Sat May 12 10:27:50 2012
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>2.10-SNAPSHOT</version>
+ <version>3.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-javadoc</artifactId>
Modified: maven/plugin-tools/trunk/maven-plugin-tools-model/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-model/pom.xml?rev=1337500&r1=1337499&r2=1337500&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-model/pom.xml (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-model/pom.xml Sat May 12 10:27:50 2012
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>2.10-SNAPSHOT</version>
+ <version>3.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-model</artifactId>