diff --git a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
index d74193d377..57156b085d 100644
--- a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
+++ b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
@@ -23,23 +23,19 @@ package org.apache.maven.plugin.descriptor;
public class Parameter
{
private String alias;
-
+
private String name;
private String type;
private boolean required;
-
- private boolean editable = true;
- private String validator;
+ private boolean editable = true;
private String description;
private String expression;
- private String defaultValue;
-
private String deprecated;
// ----------------------------------------------------------------------
@@ -76,16 +72,6 @@ public class Parameter
this.required = required;
}
- public String getValidator()
- {
- return validator;
- }
-
- public void setValidator( String validator )
- {
- this.validator = validator;
- }
-
public String getDescription()
{
return description;
@@ -106,16 +92,6 @@ public class Parameter
this.expression = expression;
}
- public String getDefaultValue()
- {
- return defaultValue;
- }
-
- public void setDefaultValue( String defaultValue )
- {
- this.defaultValue = defaultValue;
- }
-
public String getDeprecated()
{
return deprecated;
@@ -131,9 +107,9 @@ public class Parameter
return name.hashCode();
}
- public boolean equals(Object other)
+ public boolean equals( Object other )
{
- return (other instanceof Parameter) && getName().equals(((Parameter)other).getName());
+ return ( other instanceof Parameter ) && getName().equals( ( (Parameter) other ).getName() );
}
public String getAlias()
@@ -155,7 +131,7 @@ public class Parameter
{
this.editable = editable;
}
-
+
public String toString()
{
return "Mojo parameter [name: \'" + getName() + "\'; alias: \'" + getAlias() + "\']";
diff --git a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
index dd5cfd5ba3..ba76c6914a 100755
--- a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
+++ b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
@@ -187,8 +187,6 @@ public class PluginDescriptorBuilder
parameter.setEditable( editable == null || Boolean.valueOf( editable ).booleanValue() );
}
- parameter.setValidator( d.getChild( "validator" ).getValue() );
-
parameter.setDescription( d.getChild( "description" ).getValue() );
parameter.setExpression( d.getChild( "expression" ).getValue() );
diff --git a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/BeanGenerator.java b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/BeanGenerator.java
index fc97be170b..d310bdc67a 100644
--- a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/BeanGenerator.java
+++ b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/BeanGenerator.java
@@ -43,7 +43,7 @@ import java.util.List;
public class BeanGenerator
implements Generator
{
- public void execute( String destinationDirectory, PluginDescriptor pluginDescriptor )
+ public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
throws IOException
{
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
@@ -53,7 +53,7 @@ public class BeanGenerator
}
}
- protected void processPluginDescriptor( MojoDescriptor descriptor, String destinationDirectory )
+ protected void processPluginDescriptor( MojoDescriptor descriptor, File destinationDirectory )
throws IOException
{
String implementation = descriptor.getImplementation();
diff --git a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java
index 5f0c6d450c..c1d97207b9 100644
--- a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java
+++ b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java
@@ -19,6 +19,7 @@ package org.apache.maven.tools.plugin.generator;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import java.io.IOException;
+import java.io.File;
/**
* @author Jason van Zyl
@@ -26,6 +27,6 @@ import java.io.IOException;
*/
public interface Generator
{
- void execute( String destinationDirectory, PluginDescriptor pluginDescriptor )
+ void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
throws IOException;
}
\ No newline at end of file
diff --git a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
index 5e2724c1c8..9b2cd45da3 100644
--- a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
+++ b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
@@ -43,7 +43,7 @@ import java.util.Map;
public class PluginDescriptorGenerator
implements Generator
{
- public void execute( String destinationDirectory, PluginDescriptor pluginDescriptor )
+ public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
throws IOException
{
File f = new File( destinationDirectory, "plugin.xml" );
@@ -257,9 +257,6 @@ public class PluginDescriptorGenerator
element( w, "deprecated", parameter.getDeprecated() );
}
- // TODO: do we still need this?
- element( w, "validator", parameter.getValidator() );
-
element( w, "required", Boolean.toString( parameter.isRequired() ) );
element( w, "editable", Boolean.toString( parameter.isEditable() ) );
diff --git a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
index 28881ccb97..0aaedcba6c 100644
--- a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
+++ b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
@@ -33,23 +33,23 @@ import java.util.Map;
/**
* @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.
*/
public class PluginXdocGenerator
implements Generator
{
- public void execute( String destinationDirectory, PluginDescriptor pluginDescriptor )
+ public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
throws IOException
{
+ // TODO: write an overview page
+
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
{
MojoDescriptor descriptor = (MojoDescriptor) it.next();
- processPluginDescriptor( descriptor, destinationDirectory );
+ processMojoDescriptor( descriptor, destinationDirectory );
}
}
- protected void processPluginDescriptor( MojoDescriptor mojoDescriptor, String destinationDirectory )
+ protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, File destinationDirectory )
throws IOException
{
String id = mojoDescriptor.getGoal();
@@ -57,7 +57,7 @@ public class PluginXdocGenerator
FileWriter writer = null;
try
{
- writer = new FileWriter( new File( destinationDirectory, id + "-plugin.xml" ) );
+ writer = new FileWriter( new File( destinationDirectory, id + "-mojo.xml" ) );
writeBody( writer, id, mojoDescriptor );
@@ -83,15 +83,8 @@ public class PluginXdocGenerator
w.startElement( "title" );
- w.writeText( "Documentation for the " + id + " plugin." );
-
- w.endElement();
-
- w.startElement( "author" );
-
- w.addAttribute( "email", "dev@maven.apache.org" );
-
- w.writeText( "Maven development team." );
+ // TODO: need a friendly name for a plugin
+ w.writeText( mojoDescriptor.getPluginDescriptor().getArtifactId() + " - " + mojoDescriptor.getFullGoalName() );
w.endElement();
@@ -103,34 +96,24 @@ public class PluginXdocGenerator
w.startElement( "section" );
- w.addAttribute( "name", "Goals" );
+ w.addAttribute( "name", mojoDescriptor.getFullGoalName() );
w.startElement( "p" );
- w.writeText( "The goals for the " + id + " are as follows:" );
-
- w.endElement();
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- w.startElement( "subsection" );
-
- w.addAttribute( "name", mojoDescriptor.getGoal() );
-
if ( mojoDescriptor.getDescription() != null )
{
- w.startElement( "p" );
-
- w.writeText( mojoDescriptor.getDescription() );
-
- w.endElement();
+ w.writeMarkup( mojoDescriptor.getDescription() );
}
+ else
+ {
+ w.writeText( "No description." );
+ }
+
+ w.endElement();
w.startElement( "p" );
- w.writeText( "These parameters for this goal: " );
+ w.writeText( "Parameters for the goal: " );
w.endElement();
@@ -138,23 +121,11 @@ public class PluginXdocGenerator
w.endElement();
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- w.endElement();
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
w.endElement();
}
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
{
- w.startElement( "p" );
-
w.startElement( "table" );
w.startElement( "tr" );
@@ -183,24 +154,10 @@ public class PluginXdocGenerator
w.endElement();
- w.startElement( "th" );
-
- w.writeText( "Required?" );
-
- w.endElement();
-
- w.startElement( "th" );
-
- w.writeText( "Deprecated?" );
-
- w.endElement();
-
w.endElement();
List parameters = mojoDescriptor.getParameters();
- Map parameterMap = mojoDescriptor.getParameterMap();
-
for ( int i = 0; i < parameters.size(); i++ )
{
Parameter parameter = (Parameter) parameters.get( i );
@@ -220,27 +177,51 @@ public class PluginXdocGenerator
paramName = parameter.getName();
}
+ w.startElement( "code" );
+
w.writeText( paramName );
w.endElement();
+ if ( !parameter.isRequired() )
+ {
+ w.writeMarkup( " (Optional)");
+ }
+
+ w.endElement();
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
+ w.startElement( "code" );
+
w.writeText( parameter.getType() );
w.endElement();
+ w.endElement();
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
- w.writeText( parameter.getExpression() );
+ w.startElement( "code" );
+
+ if ( StringUtils.isNotEmpty( parameter.getExpression() ) )
+ {
+ w.writeText( parameter.getExpression() );
+ }
+ else
+ {
+ w.writeText( "-" );
+ }
+
+ w.endElement();
w.endElement();
@@ -250,38 +231,32 @@ public class PluginXdocGenerator
w.startElement( "td" );
- w.writeText( parameter.getDescription() );
-
- w.endElement();
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- w.startElement( "td" );
-
- w.writeText( Boolean.toString( parameter.isRequired() ) );
-
- w.endElement();
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
+ if ( StringUtils.isNotEmpty( parameter.getDescription() ) )
+ {
+ w.writeMarkup( parameter.getDescription() );
+ }
+ else
+ {
+ w.writeText( "No description." );
+ }
String deprecationWarning = parameter.getDeprecated();
- if ( StringUtils.isNotEmpty( deprecationWarning ) )
+ if ( deprecationWarning != null )
{
- w.startElement( "td" );
-
- w.writeText( deprecationWarning );
+ w.writeMarkup( "
Deprecated: ");
+ w.writeMarkup( deprecationWarning );
+ if ( deprecationWarning.length() == 0 )
+ {
+ w.writeText( "No reason given." );
+ }
w.endElement();
}
w.endElement();
- }
- w.endElement();
+ w.endElement();
+ }
w.endElement();
}
diff --git a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly/JellyHarnessGenerator.java b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly/JellyHarnessGenerator.java
index 16f570caba..38b3a7d9f4 100644
--- a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly/JellyHarnessGenerator.java
+++ b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly/JellyHarnessGenerator.java
@@ -48,7 +48,7 @@ public class JellyHarnessGenerator
return pluginDescriptor.getImplementation() + "Bean";
}
- public void execute( String destinationDirectory, PluginDescriptor pluginDescriptor )
+ public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
throws IOException
{
FileWriter writer = null;
diff --git a/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java b/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
index 9ee3dfd48d..9921ac5eab 100644
--- a/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
+++ b/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
@@ -58,7 +58,6 @@ public abstract class AbstractGeneratorTestCase
List params = new ArrayList();
Parameter param = new Parameter();
- param.setDefaultValue( "value" );
param.setExpression( "${project.build.directory}" );
param.setName( "dir" );
param.setRequired( true );
@@ -70,6 +69,7 @@ public abstract class AbstractGeneratorTestCase
mojoDescriptor.setParameters( params );
PluginDescriptor pluginDescriptor = new PluginDescriptor();
+ mojoDescriptor.setPluginDescriptor( pluginDescriptor );
pluginDescriptor.addMojo( mojoDescriptor );
@@ -86,7 +86,7 @@ public abstract class AbstractGeneratorTestCase
File tempFile = File.createTempFile( "testGenerator-outDir", ".marker.txt" ).getAbsoluteFile();
File destinationDirectory = tempFile.getParentFile();
- generator.execute( destinationDirectory.getAbsolutePath(), pluginDescriptor );
+ generator.execute( destinationDirectory, pluginDescriptor );
validate( destinationDirectory );
}
diff --git a/maven-plugin-tools/maven-plugin-tools-pluggy/src/main/java/org/apache/maven/tools/plugin/pluggy/Main.java b/maven-plugin-tools/maven-plugin-tools-pluggy/src/main/java/org/apache/maven/tools/plugin/pluggy/Main.java
index 976881cad9..f078c76b58 100644
--- a/maven-plugin-tools/maven-plugin-tools-pluggy/src/main/java/org/apache/maven/tools/plugin/pluggy/Main.java
+++ b/maven-plugin-tools/maven-plugin-tools-pluggy/src/main/java/org/apache/maven/tools/plugin/pluggy/Main.java
@@ -123,6 +123,6 @@ public class Main
// Use the generator to process the discovered descriptors and produce
// something with them.
- generator.execute( outputDirectory, pluginDescriptor );
+ generator.execute( new File( outputDirectory ), pluginDescriptor );
}
}
diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
index 192eac4c01..0214b3edff 100644
--- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
+++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
@@ -27,6 +27,7 @@ import org.apache.maven.tools.plugin.scanner.MojoScanner;
import org.apache.maven.tools.plugin.util.PluginUtils;
import java.io.IOException;
+import java.io.File;
/**
* @author Jason van Zyl
@@ -52,7 +53,7 @@ public abstract class AbstractGeneratorMojo
*/
protected String goalPrefix;
- protected abstract String getOutputDirectory();
+ protected abstract File getOutputDirectory();
protected abstract Generator createGenerator();
@@ -86,6 +87,8 @@ public abstract class AbstractGeneratorMojo
mojoScanner.populatePluginDescriptor( project, pluginDescriptor );
+ getOutputDirectory().mkdirs();
+
createGenerator().execute( getOutputDirectory(), pluginDescriptor );
}
catch ( IOException e )
diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/BeanGeneratorMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/BeanGeneratorMojo.java
index 6231f07816..c81894b9a1 100644
--- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/BeanGeneratorMojo.java
+++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/BeanGeneratorMojo.java
@@ -19,6 +19,8 @@ package org.apache.maven.plugin.plugin;
import org.apache.maven.tools.plugin.generator.BeanGenerator;
import org.apache.maven.tools.plugin.generator.Generator;
+import java.io.File;
+
/**
* @author Jason van Zyl
* @version $Id$
@@ -31,9 +33,9 @@ public class BeanGeneratorMojo
* @parameter expression="${project.build.directory}/generated-sources"
* @required
*/
- protected String outputDirectory;
+ protected File outputDirectory;
- protected String getOutputDirectory()
+ protected File getOutputDirectory()
{
return outputDirectory;
}
diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
index 21bbed742c..d873afdc47 100644
--- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
+++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
@@ -19,6 +19,8 @@ package org.apache.maven.plugin.plugin;
import org.apache.maven.tools.plugin.generator.Generator;
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
+import java.io.File;
+
/**
* Generate a plugin descriptor.
*