add deprecated parameter feature

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163983 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-20 16:49:01 +00:00
parent c1cea8cbb8
commit ab2070d797
8 changed files with 74 additions and 19 deletions

View File

@ -657,6 +657,15 @@ public class DefaultPluginManager
else
{
expression = configuration.getChild( key, false ).getValue( null );
if ( expression != null && parameter.getDeprecated() != null )
{
if ( !expression.equals( goal.getConfiguration().getChild( key, false ).getValue( null ) ) )
{
getLogger().warn(
"DEPRECATED: " + parameter.getName() + " is deprecated.\n\t" + parameter.getDeprecated() );
}
}
}
Object value = expressionEvaluator.evaluate( expression );

View File

@ -59,6 +59,8 @@ public class MojoDescriptor
private List requirements;
private String deprecated;
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@ -66,7 +68,7 @@ public class MojoDescriptor
private String requiresDependencyResolution = null;
private boolean requiresProject = true;
private boolean requiresOnline = false;
private String language = DEFAULT_LANGUAGE;
@ -127,6 +129,16 @@ public class MojoDescriptor
this.id = id;
}
public String getDeprecated()
{
return deprecated;
}
public void setDeprecated( String deprecated )
{
this.deprecated = deprecated;
}
public List getParameters()
{
return parameters;

View File

@ -36,6 +36,8 @@ public class Parameter
private String defaultValue;
private String deprecated;
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@ -109,4 +111,14 @@ public class Parameter
{
this.defaultValue = defaultValue;
}
public String getDeprecated()
{
return deprecated;
}
public void setDeprecated( String deprecated )
{
this.deprecated = deprecated;
}
}

View File

@ -5,7 +5,9 @@ import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
@ -153,6 +155,8 @@ public class PluginDescriptorBuilder
// TODO: remove
parameter.setDefaultValue( d.getChild( "default" ).getValue() );
parameter.setDeprecated( d.getChild( "deprecated" ).getValue() );
parameters.add( parameter );
}
@ -194,7 +198,6 @@ public class PluginDescriptorBuilder
//
// ----------------------------------------------------------------------
// TODO: catches Exception
public PlexusConfiguration buildConfiguration( Reader configuration )
throws PlexusConfigurationException
{
@ -202,7 +205,11 @@ public class PluginDescriptorBuilder
{
return new XmlPlexusConfiguration( Xpp3DomBuilder.build( configuration ) );
}
catch ( Exception e )
catch ( IOException e )
{
throw new PlexusConfigurationException( "Error creating configuration", e );
}
catch ( XmlPullParserException e )
{
throw new PlexusConfigurationException( "Error creating configuration", e );
}

View File

@ -175,6 +175,11 @@ public class PluginDescriptorGenerator
element( w, "type", parameter.getType() );
if ( parameter.getDeprecated() != null )
{
element( w, "deprecated", parameter.getDeprecated() );
}
element( w, "validator", parameter.getValidator() );
String value = null;

View File

@ -216,6 +216,8 @@ public class JavaMojoDescriptorExtractor
pd.setDefaultValue( parameter.getNamedParameter( "default" ) );
pd.setDeprecated( parameter.getNamedParameter( "deprecated" ) );
parameters.add( pd );
}

View File

@ -28,6 +28,7 @@ import org.codehaus.marmalade.parsing.MarmaladeParsingContext;
import org.codehaus.marmalade.parsing.ScriptParser;
import org.codehaus.marmalade.runtime.DefaultContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.plexus.util.IOUtil;
import java.io.BufferedReader;
import java.io.File;
@ -50,7 +51,8 @@ public class MarmaladeMojoDescriptorExtractor
return ".mmld";
}
protected Set extractMojoDescriptors( Map sourceFilesKeyedByBasedir ) throws Exception
protected Set extractMojoDescriptors( Map sourceFilesKeyedByBasedir )
throws Exception
{
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try
@ -84,14 +86,15 @@ public class MarmaladeMojoDescriptorExtractor
contextMap = context.getExternalizedVariables();
MojoDescriptor descriptor = (MojoDescriptor) contextMap.get( MarmaladeMojoExecutionDirectives.METADATA_OUTVAR );
MojoDescriptor descriptor = (MojoDescriptor) contextMap.get(
MarmaladeMojoExecutionDirectives.METADATA_OUTVAR );
descriptors.add( descriptor );
}
else
{
System.out.println( "This script is not a mojo. Its root tag is {element: "
+ rootTag.getTagInfo().getElement() + ", class: " + rootTag.getClass().getName() + "}" );
System.out.println( "This script is not a mojo. Its root tag is {element: " +
rootTag.getTagInfo().getElement() + ", class: " + rootTag.getClass().getName() + "}" );
}
}
}
@ -104,7 +107,8 @@ public class MarmaladeMojoDescriptorExtractor
}
}
private MarmaladeScript parse( File scriptFile ) throws Exception
private MarmaladeScript parse( File scriptFile )
throws Exception
{
BufferedReader reader = null;
@ -127,16 +131,7 @@ public class MarmaladeMojoDescriptorExtractor
}
finally
{
if ( reader != null )
{
try
{
reader.close();
}
catch ( Exception e )
{
}
}
IOUtil.close( reader );
}
}

View File

@ -41,9 +41,12 @@ public class ParameterTag
private String defaultVal;
private String deprecated;
private boolean required = true;
protected void doExecute( MarmaladeExecutionContext context ) throws MarmaladeExecutionException
protected void doExecute( MarmaladeExecutionContext context )
throws MarmaladeExecutionException
{
processChildren( context );
@ -64,6 +67,7 @@ public class ParameterTag
param.setRequired( required );
param.setType( type );
param.setValidator( validator );
param.setDeprecated( deprecated );
return param;
}
@ -103,4 +107,13 @@ public class ParameterTag
this.required = required;
}
public String getDeprecated()
{
return deprecated;
}
public void setDeprecated( String deprecated )
{
this.deprecated = deprecated;
}
}