You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/05/04 06:20:38 UTC
svn commit: r168070 -
/maven/components/trunk/maven-core-it/it0013/src/main/java/org/apache/maven/plugin/coreit
/maven/components/trunk/maven-core-it/it0015/src/main/scripts/org/apache/maven/it0015
/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin
/maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin
/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java
Author: jdcasey
Date: Tue May 3 21:20:36 2005
New Revision: 168070
URL: http://svn.apache.org/viewcvs?rev=168070&view=rev
Log:
Removed backward compat for plugin class-level parameter annotations and '#' expressions.
Modified:
maven/components/trunk/maven-core-it/it0013/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java
maven/components/trunk/maven-core-it/it0015/src/main/scripts/org/apache/maven/it0015/it0015.mmld
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
Modified: maven/components/trunk/maven-core-it/it0013/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0013/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java?rev=168070&r1=168069&r2=168070&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0013/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java (original)
+++ maven/components/trunk/maven-core-it/it0013/src/main/java/org/apache/maven/plugin/coreit/CoreIt0013Mojo.java Tue May 3 21:20:36 2005
@@ -17,40 +17,32 @@
*/
import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionRequest;
-import org.apache.maven.plugin.MojoExecutionResponse;
+import org.apache.maven.plugin.MojoExecutionException;
import java.io.File;
import java.io.FileWriter;
+import java.io.IOException;
/**
* @goal it0013
*
* @description touches a test file
*
- * @parameter
- * name="outputDirectory"
- * type="String"
- * required="true"
- * validator=""
- * expression="#project.build.directory"
- * description=""
*/
public class CoreIt0013Mojo
extends AbstractMojo
{
private static final int DELETE_RETRY_SLEEP_MILLIS = 10;
+
+ /**
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private String outputDirectory;
- public void execute( MojoExecutionRequest request, MojoExecutionResponse response )
- throws Exception
+ public void execute()
+ throws MojoExecutionException
{
- String outputDirectory = (String) request.getParameter( "outputDirectory" );
-
- if ( outputDirectory == null || outputDirectory.length() == 0 )
- {
- throw new Exception( "outputDirectory must be specified" );
- }
-
getLog().info( "outputDirectory = " + outputDirectory );
File f = new File( outputDirectory );
@@ -62,10 +54,17 @@
File touch = new File( f, "it0013-verify" );
- FileWriter w = new FileWriter( touch );
-
- w.write( "it0013-verify" );
-
- w.close();
+ try
+ {
+ FileWriter w = new FileWriter( touch );
+
+ w.write( "it0013-verify" );
+
+ w.close();
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error writing verification file.", e );
+ }
}
}
Modified: maven/components/trunk/maven-core-it/it0015/src/main/scripts/org/apache/maven/it0015/it0015.mmld
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0015/src/main/scripts/org/apache/maven/it0015/it0015.mmld?rev=168070&r1=168069&r2=168070&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0015/src/main/scripts/org/apache/maven/it0015/it0015.mmld (original)
+++ maven/components/trunk/maven-core-it/it0015/src/main/scripts/org/apache/maven/it0015/it0015.mmld Tue May 3 21:20:36 2005
@@ -6,7 +6,7 @@
<parameters>
<parameter>
<name>outDir</name>
- <expression>#project.build.directory</expression>
+ <expression>${project.build.directory}</expression>
<default>target</default>
<description>Output directory for files.</description>
</parameter>
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?rev=168070&r1=168069&r2=168070&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Tue May 3 21:20:36 2005
@@ -77,23 +77,7 @@
return expression;
}
- if ( expression.startsWith( "component" ) )
- {
- context.getLog().warn( "WARNING: plugin is using deprecated expression " + expression );
-
- // TODO: deprecated... and can remove the lookup method in context afterwards
- String role = expression.substring( 10 );
-
- try
- {
- value = context.lookup( role );
- }
- catch ( ComponentLookupException e )
- {
- throw new ExpressionEvaluationException( "Cannot lookup component: " + role + ".", e );
- }
- }
- else if (expression.equals( "reports" ) )
+ if (expression.equals( "reports" ) )
{
String role = PluginManager.ROLE;
try
@@ -132,11 +116,6 @@
{
value = context.getLocalRepository();
}
- else if ( expression.equals( "maven.final.name" ) )
- {
- // TODO: remove this alias
- value = context.getProject().getBuild().getFinalName();
- }
else if ( expression.equals( "project" ) )
{
value = context.getProject();
@@ -202,21 +181,18 @@
// TODO: without #, this could just be an evaluate call...
String val = (String) value;
- int sharpSeparator = val.indexOf( "#" );
- if ( sharpSeparator < 0 )
- {
- sharpSeparator = val.indexOf( "${" );
- }
+
+ int exprStartDelimiter = val.indexOf( "${" );
- if ( sharpSeparator >= 0 )
+ if ( exprStartDelimiter >= 0 )
{
- if ( sharpSeparator > 0 )
+ if ( exprStartDelimiter > 0 )
{
- value = val.substring( 0, sharpSeparator ) + evaluate( val.substring( sharpSeparator ) );
+ value = val.substring( 0, exprStartDelimiter ) + evaluate( val.substring( exprStartDelimiter ) );
}
else
{
- value = evaluate( val.substring( sharpSeparator ) );
+ value = evaluate( val.substring( exprStartDelimiter ) );
}
}
}
@@ -226,12 +202,7 @@
private String stripTokens( String expr )
{
- if ( expr.startsWith( "#" ) )
- {
- context.getLog().warn( "DEPRECATED: use ${} to delimit expressions instead of # for '" + expr + "'" );
- expr = expr.substring( 1 );
- }
- else if ( expr.startsWith( "${" ) && expr.indexOf( "}" ) == expr.length() - 1 )
+ if ( expr.startsWith( "${" ) && expr.indexOf( "}" ) == expr.length() - 1 )
{
expr = expr.substring( 2, expr.length() - 1 );
}
Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java?rev=168070&r1=168069&r2=168070&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java (original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java Tue May 3 21:20:36 2005
@@ -69,23 +69,6 @@
new DefaultLog( container.getLogger() ), Collections.EMPTY_LIST );
}
- public void testParameterThatIsAComponent()
- throws Exception
- {
-
- ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
- "legacy" );
-
- ArtifactRepository repo = new ArtifactRepository( "test", "http://www.test.com", repoLayout );
-
- PlexusContainer container = getContainer();
- MavenSession session = createSession( createDefaultProject(), container, repo );
-
- ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, null );
-
- assertNotNull( expressionEvaluator.evaluate( "${component.org.apache.maven.project.MavenProjectBuilder}" ) );
- }
-
public void testLocalRepositoryExtraction()
throws Exception
{
Modified: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java?rev=168070&r1=168069&r2=168070&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java (original)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java Tue May 3 21:20:36 2005
@@ -24,7 +24,6 @@
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
import org.codehaus.modello.StringUtils;
import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.logging.Logger;
import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.DocletTag;
@@ -233,33 +232,6 @@
Map rawParams = new TreeMap();
- // for backward compat, we'll toss on the params declared at the class level.
- DocletTag[] classLevelParams = javaClass.getTagsByName( PARAMETER );
- if ( classLevelParams != null )
- {
- for ( int i = 0; i < classLevelParams.length; i++ )
- {
- DocletTag tag = classLevelParams[i];
-
- String message = "DEPRECATED: Use field-level annotations "
- + "for parameters instead of class-level annotations. (parameter \'"
- + tag.getNamedParameter( "name" ) + "\'; class \'" + javaClass.getFullyQualifiedName() + ")";
-
- Logger logger = getLogger();
- if ( logger != null )
- {
- logger.warn( message );
- }
- else
- {
- // we're being used from pluggy, so this is okay...
- System.err.println( message );
- }
-
- rawParams.put( tag.getNamedParameter( "name" ), tag );
- }
- }
-
extractFieldParameterTags( javaClass, rawParams );
Set parameters = new HashSet();
@@ -269,58 +241,26 @@
Map.Entry entry = (Entry) it.next();
String paramName = (String) entry.getKey();
- Object val = entry.getValue();
-
- JavaField field = null;
- DocletTag parameter = null;
-
- // FIXME: ICK! This is only here for backward compatibility to the class-level annotations of params.
- if ( val instanceof JavaField )
- {
- field = (JavaField) val;
+ JavaField field = (JavaField) entry.getValue();
- parameter = field.getTagByName( PARAMETER );
- }
- else
- {
- parameter = (DocletTag) val;
- }
+ DocletTag parameter = field.getTagByName( PARAMETER );
Parameter pd = new Parameter();
- // if the field is null, then we're using a deprecated annotation pattern...
- // TODO: remove when backward compatibility is no longer an issue.
- if ( field == null )
- {
- pd.setName( paramName );
+ pd.setName( paramName );
- pd.setType( parameter.getNamedParameter( "type" ) );
+ pd.setType( field.getType().getValue() );
- pd.setDescription( parameter.getNamedParameter( "description" ) );
+ pd.setDescription( field.getComment() );
- pd.setRequired( parameter.getNamedParameter( REQUIRED ).equals( "true" ) ? true : false );
+ pd.setRequired( field.getTagByName( REQUIRED ) != null );
- pd.setDeprecated( parameter.getNamedParameter( DEPRECATED ) );
+ pd.setEditable( field.getTagByName( READONLY ) == null );
- pd.setDefaultValue( parameter.getNamedParameter( "default" ) );
- }
- else
+ DocletTag deprecationTag = field.getTagByName( DEPRECATED );
+ if ( deprecationTag != null )
{
- pd.setName( paramName );
-
- pd.setType( field.getType().getValue() );
-
- pd.setDescription( field.getComment() );
-
- pd.setRequired( field.getTagByName( REQUIRED ) != null );
-
- pd.setEditable( field.getTagByName( READONLY ) == null );
-
- DocletTag deprecationTag = field.getTagByName( DEPRECATED );
- if ( deprecationTag != null )
- {
- pd.setDeprecated( deprecationTag.getValue() );
- }
+ pd.setDeprecated( deprecationTag.getValue() );
}
String alias = parameter.getNamedParameter( "alias" );
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org