jvanzyl 2004/05/09 09:13:03
Modified: maven-pluggy/src/main/java/org/apache/maven/pluggy
Pluggy.java
maven-pluggy/src/test/resources/source IdeaPlugin.java
Log:
o added xdoc generating which spits out the details of plugin/goal usage.
- need to augment the format for example usage but we're almost there.
Revision Changes Path
1.3 +199 -3
maven-components/maven-pluggy/src/main/java/org/apache/maven/pluggy/Pluggy.java
Index: Pluggy.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-pluggy/src/main/java/org/apache/maven/pluggy/Pluggy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Pluggy.java 9 May 2004 15:22:11 -0000 1.2
+++ Pluggy.java 9 May 2004 16:13:03 -0000 1.3
@@ -15,6 +15,11 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * @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 Pluggy
{
public void execute( String sourceDirectory, String destinationDirectory )
@@ -34,10 +39,190 @@
File pluginDescriptorFile = new File( destinationDirectory,
"plugin.xml" );
- writePluginDescriptor( pluginDescriptor, pluginDescriptorFile );
+ writePluginDescriptor( pluginDescriptor, pluginDescriptorFile );
+
+ File pluginXdoc = new File( destinationDirectory, "plugin-doco.xml" );
+
+ writePluginXdoc( pluginDescriptor, pluginXdoc );
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Write plugin xdoc
+ // ----------------------------------------------------------------------
+
+ private void writePluginXdoc( PluginDescriptor pluginDescriptor, File
destination )
+ throws Exception
+ {
+ FileWriter writer = new FileWriter( destination );
+
+ XMLWriter w = new DefaultXMLWriter( writer );
+
+ w.startElement( "document" );
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ w.startElement( "properties" );
+
+ w.startElement( "title" );
+
+ w.writeText( "Documentation for the " + pluginDescriptor.getId() + "
plugin." );
+
+ w.endElement();
+
+ w.startElement( "author" );
+
+ w.addAttribute( "email", "[EMAIL PROTECTED]" );
+
+ w.writeText( "Maven developement team." );
+
+ w.endElement();
+
+ w.endElement();
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ w.startElement( "section" );
+
+ w.addAttribute( "name", "Goals" );
+
+ w.startElement( "p" );
+
+ w.writeText( "The goals for the " + pluginDescriptor.getId() + " are as
follows:" );
+
+ w.endElement();
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ List goals = pluginDescriptor.getGoals();
+
+ for ( int i = 0; i < goals.size(); i++ )
+ {
+ GoalDescriptor goal = (GoalDescriptor) goals.get( i );
+
+ w.startElement( "subsection" );
+
+ w.addAttribute( "name", goal.getName() );
+
+ w.startElement( "p" );
+
+ w.writeText( goal.getDescription() );
+
+ w.endElement();
+
+ w.startElement( "p" );
+
+ w.writeText( "These parameters for this goal: " );
+
+ w.endElement();
+
+ writeGoalParameterTable( goal, w );
+
+ w.endElement();
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ w.endElement();
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ w.endElement();
+
+ writer.flush();
+
+ writer.close();
+ }
+
+ private void writeGoalParameterTable( GoalDescriptor goal, XMLWriter w )
+ throws Exception
+ {
+ w.startElement( "p" );
+
+ w.startElement( "table" );
+
+ w.startElement( "tr" );
+
+ w.startElement( "th" );
+
+ w.writeText( "Parameter" );
+
+ w.endElement();
+
+ w.startElement( "th" );
+
+ w.writeText( "Expression" );
+
+ w.endElement();
+
+ w.startElement( "th" );
+
+ w.writeText( "Description" );
+
+ w.endElement();
+
+ w.endElement();
+
+ List parameters = goal.getParameters();
+
+ for ( int i = 0; i < parameters.size(); i++ )
+ {
+ ParameterDescriptor parameter = (ParameterDescriptor) parameters.get( i
);
+
+ w.startElement( "tr" );
+
+ //
----------------------------------------------------------------------
+ //
+ //
----------------------------------------------------------------------
+
+ w.startElement( "td" );
+
+ w.writeText( parameter.getName() );
+
+ w.endElement();
+
+ //
----------------------------------------------------------------------
+ //
+ //
----------------------------------------------------------------------
+
+ w.startElement( "td" );
+
+ w.writeText( parameter.getExpression() );
+
+ w.endElement();
+
+ //
----------------------------------------------------------------------
+ //
+ //
----------------------------------------------------------------------
+
+ w.startElement( "td" );
+
+ w.writeText( parameter.getDescription() );
+
+ w.endElement();
+
+ w.endElement();
}
+
+ w.endElement();
+
+ w.endElement();
}
+ // ----------------------------------------------------------------------
+ // Write plugin descriptor
+ // ----------------------------------------------------------------------
+
private void writePluginDescriptor( PluginDescriptor pluginDescriptor, File
destination )
throws Exception
{
@@ -227,6 +412,18 @@
pd.setExpression( goalParameter.getParameters()[1] );
+ int length = goalParameter.getParameters().length;
+
+ StringBuffer parameterDescription = new StringBuffer();
+
+ for ( int k = 2; k < length; k++ )
+ {
+ // Collect all the parameters which make up the parameter
description.
+ parameterDescription.append( goalParameter.getParameters()[k]
).append( " " );
+ }
+
+ pd.setDescription( parameterDescription.toString() );
+
parameters.add( pd );
}
@@ -244,5 +441,4 @@
{
return javaSource.getClasses()[0];
}
-}
-
+}
\ No newline at end of file
1.3 +1 -1
maven-components/maven-pluggy/src/test/resources/source/IdeaPlugin.java
Index: IdeaPlugin.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-pluggy/src/test/resources/source/IdeaPlugin.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IdeaPlugin.java 9 May 2004 15:22:11 -0000 1.2
+++ IdeaPlugin.java 9 May 2004 16:13:03 -0000 1.3
@@ -13,7 +13,7 @@
*
* @goal.name idea
* @goal.idea.description Goal to create IDEA files from a POM
- * @goal.idea.parameter project #project
+ * @goal.idea.parameter project #project Maven project for which the IDEA files
will be generated for
*/
public class IdeaPlugin
extends AbstractPlugin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]