remove more deprecated stuff, improve plugin xdoc generation

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@169734 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-05-12 00:06:54 +00:00
parent e15ca2b246
commit 640ee60806
17 changed files with 136 additions and 180 deletions

View File

@ -32,14 +32,10 @@ public class Parameter
private boolean editable = true;
private String validator;
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;

View File

@ -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() );

View File

@ -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();

View File

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

View File

@ -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() ) );

View File

@ -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( " <i>(Optional)</i>");
}
w.endElement();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.startElement( "code" );
w.writeText( parameter.getType() );
w.endElement();
w.endElement();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.startElement( "code" );
if ( StringUtils.isNotEmpty( parameter.getExpression() ) )
{
w.writeText( parameter.getExpression() );
}
else
{
w.writeText( "-" );
}
w.endElement();
w.endElement();
@ -250,32 +231,23 @@ 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.endElement();
w.writeMarkup( "<br/><b>Deprecated:</b> ");
w.writeMarkup( deprecationWarning );
if ( deprecationWarning.length() == 0 )
{
w.writeText( "No reason given." );
}
w.endElement();
@ -285,4 +257,7 @@ public class PluginXdocGenerator
w.endElement();
}
w.endElement();
}
}

View File

@ -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;

View File

@ -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 );
}

View File

@ -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 );
}
}

View File

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

View File

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

View File

@ -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.
* <p/>
@ -36,9 +38,9 @@ public class DescriptorGeneratorMojo
* @parameter expression="${project.build.outputDirectory}/META-INF/maven"
* @required
*/
protected String outputDirectory;
protected File outputDirectory;
protected String getOutputDirectory()
protected File getOutputDirectory()
{
return outputDirectory;
}

View File

@ -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.jelly.JellyHarnessGenerator;
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
@ -31,9 +33,9 @@ public class JellyGeneratorMojo
* @parameter expression="${project.build.directory}/generated-sources"
* @required
*/
protected String outputDirectory;
protected File outputDirectory;
protected String getOutputDirectory()
protected File getOutputDirectory()
{
return outputDirectory;
}

View File

@ -0,0 +1,47 @@
package org.apache.maven.plugin.plugin;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.tools.plugin.generator.Generator;
import org.apache.maven.tools.plugin.generator.PluginXdocGenerator;
import java.io.File;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
* @goal xdoc
*/
public class XdocGeneratorMojo
extends AbstractGeneratorMojo
{
/**
* @parameter expression="${project.build.directory}/generated-xdocs"
* @required
*/
protected File outputDirectory;
protected File getOutputDirectory()
{
return outputDirectory;
}
protected Generator createGenerator()
{
return new PluginXdocGenerator();
}
}

View File

@ -43,7 +43,6 @@ public class MojoDefinitionTagLibrary
registerTag( "expression", ParamExpressionTag.class );
registerTag( "type", ParamTypeTag.class );
registerTag( "default", ParamDefaultTag.class );
registerTag( "validator", ParamValidatorTag.class );
registerTag( "required", ParamRequiredTag.class );
}

View File

@ -1,34 +0,0 @@
package org.apache.maven.script.marmalade.tags;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
/**
* @author jdcasey
*/
public class ParamValidatorTag
extends AbstractStringValuedBodyTag
{
protected void setValue( String value ) throws MarmaladeExecutionException
{
ParameterTag parent = (ParameterTag) requireParent( ParameterTag.class );
parent.setValidator( value );
}
}

View File

@ -37,10 +37,6 @@ public class ParameterTag
private String expression;
private String validator;
private String defaultVal;
private String deprecated;
private boolean required = true;
@ -61,12 +57,10 @@ public class ParameterTag
Parameter param = new Parameter();
param.setName( name );
param.setDefaultValue( defaultVal );
param.setDescription( description );
param.setExpression( expression );
param.setRequired( required );
param.setType( type );
param.setValidator( validator );
param.setDeprecated( deprecated );
return param;
@ -92,14 +86,8 @@ public class ParameterTag
this.expression = expression;
}
public void setValidator( String validator )
{
this.validator = validator;
}
public void setDefault( String defaultVal )
{
this.defaultVal = defaultVal;
}
public void setRequired( boolean required )