You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/05/20 15:20:26 UTC
svn commit: r1340709 - in /maven/plugin-tools/trunk:
maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/
maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/
maven-plugi...
Author: olamy
Date: Sun May 20 13:20:25 2012
New Revision: 1340709
URL: http://svn.apache.org/viewvc?rev=1340709&view=rev
Log:
@Component role attribute is now of type Class<?>
Modified:
maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Component.java
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java
maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java
Modified: maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Component.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Component.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Component.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Component.java Sun May 20 13:20:25 2012
@@ -42,7 +42,7 @@ public @interface Component
* role of the component to inject.
* @return the role
*/
- String role() default "";
+ Class<?> role() default Object.class;
/**
* role-hint of the component to inject.
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java Sun May 20 13:20:25 2012
@@ -27,6 +27,7 @@ import org.apache.maven.plugins.annotati
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.tools.plugin.annotations.FooMojo;
+import org.apache.maven.project.MavenProjectHelper;
/**
* Touches a test file.
@@ -46,7 +47,7 @@ public class FirstMojo
@Parameter( alias = "alias" )
private String aliasedParam;
- @Component( role = "org.apache.maven.project.MavenProjectHelper" )// , roleHint = "default"
+ @Component( role = MavenProjectHelper.class )// , roleHint = "default"
private Object projectHelper;
public void execute()
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java Sun May 20 13:20:25 2012
@@ -58,7 +58,7 @@ public abstract class AbstractFirstMojo
/**
*
*/
- @Component( role = "org.apache.maven.artifact.metadata.ArtifactMetadataSource", roleHint = "maven" )
+ @Component( role = ArtifactMetadataSource.class, roleHint = "maven" )
protected ArtifactMetadataSource artifactMetadataSource;
}
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java Sun May 20 13:20:25 2012
@@ -27,6 +27,7 @@ import org.apache.maven.plugins.annotati
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.AbstractFirstMojo;
+import org.apache.maven.project.MavenProjectHelper;
/**
* Touches a test file.
@@ -47,7 +48,7 @@ public class FirstMojo
@Parameter( alias = "alias" )
private String aliasedParam;
- @Component( role = "org.apache.maven.project.MavenProjectHelper" )
+ @Component( role = MavenProjectHelper.class )
private Object projectHelper;
public void execute()
@@ -69,6 +70,10 @@ public class FirstMojo
{
throw new MojoExecutionException( "compilerManager == null" );
}
+ if (! ( projectHelper instanceof MavenProjectHelper ))
+ {
+ throw new MojoExecutionException( "! projectHelper instanceof MavenProjectHelper" );
+ }
}
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java Sun May 20 13:20:25 2012
@@ -58,7 +58,7 @@ public abstract class AbstractFirstMojo
/**
*
*/
- @Component( role = "org.apache.maven.artifact.metadata.ArtifactMetadataSource", roleHint = "maven" )
+ @Component( role = ArtifactMetadataSource.class, roleHint = "maven" )
protected ArtifactMetadataSource artifactMetadataSource;
}
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java Sun May 20 13:20:25 2012
@@ -27,6 +27,7 @@ import org.apache.maven.plugins.annotati
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProjectHelper;
import java.util.Set;
@@ -50,7 +51,7 @@ public class FirstMojo
@Parameter( alias = "alias" )
private String aliasedParam;
- @Component( role = "org.apache.maven.project.MavenProjectHelper" )//, roleHint = "default"
+ @Component( role = MavenProjectHelper.class )//, roleHint = "default"
private Object projectHelper;
@Parameter( defaultValue = "${project.artifacts}", required = true, readonly = true )
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml Sun May 20 13:20:25 2012
@@ -45,10 +45,14 @@ under the License.
<version>2.0</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.1</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java Sun May 20 13:20:25 2012
@@ -27,6 +27,7 @@ import org.apache.maven.plugins.annotati
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProjectHelper;
import java.io.File;
@@ -59,7 +60,7 @@ public class FirstMojo
@Parameter( alias = "alias" )
private String aliasedParam;
- @Component( role = "org.apache.maven.project.MavenProjectHelper", roleHint = "test" )
+ @Component( role = MavenProjectHelper.class, roleHint = "test" )
private Object projectHelper;
public void execute()
Modified: maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java Sun May 20 13:20:25 2012
@@ -525,8 +525,9 @@ public class JavaAnnotationsMojoDescript
if ( StringUtils.contains( property, '$' ) || StringUtils.contains( property, '{' )
|| StringUtils.contains( property, '}' ) )
{
- throw new InvalidParameterException( "Invalid property for parameter '" + parameter.getName() + "', "
- + "forbidden characters ${}: " + property, null );
+ throw new InvalidParameterException(
+ "Invalid property for parameter '" + parameter.getName() + "', " + "forbidden characters ${}: "
+ + property, null );
}
parameter.setExpression( StringUtils.isEmpty( property ) ? "" : "${" + property + "}" );
parameter.setType( parameterAnnotationContent.getClassName() );
@@ -546,8 +547,8 @@ public class JavaAnnotationsMojoDescript
org.apache.maven.plugin.descriptor.Parameter parameter =
new org.apache.maven.plugin.descriptor.Parameter();
parameter.setName( componentAnnotationContent.getFieldName() );
- parameter.setRequirement(
- new Requirement( componentAnnotationContent.role(), componentAnnotationContent.roleHint() ) );
+ parameter.setRequirement( new Requirement( componentAnnotationContent.getRoleClassName(),
+ componentAnnotationContent.roleHint() ) );
parameter.setDeprecated( componentAnnotationContent.getDeprecated() );
parameter.setSince( componentAnnotationContent.getSince() );
@@ -671,8 +672,8 @@ public class JavaAnnotationsMojoDescript
{
return null;
}
- @SuppressWarnings( "unchecked" )
- Collection<MavenProject> mavenProjects = project.getProjectReferences().values();
+ @SuppressWarnings( "unchecked" ) Collection<MavenProject> mavenProjects =
+ project.getProjectReferences().values();
for ( MavenProject mavenProject : mavenProjects )
{
if ( StringUtils.equals( mavenProject.getId(), artifact.getId() ) )
Modified: maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ComponentAnnotationContent.java Sun May 20 13:20:25 2012
@@ -31,7 +31,7 @@ public class ComponentAnnotationContent
extends AnnotatedField
implements Component
{
- private String role;
+ private String roleClassName;
private String roleHint;
@@ -43,18 +43,24 @@ public class ComponentAnnotationContent
public ComponentAnnotationContent( String fieldName, String role, String roleHint )
{
this( fieldName );
- this.role = role;
+ this.roleClassName = role;
this.roleHint = roleHint;
}
- public String role()
+ public Class<?> role()
{
- return role == null ? "" : role;
+ // not used
+ return null;
+ }
+
+ public void setRoleClassName( String roleClassName )
+ {
+ this.roleClassName = roleClassName;
}
- public void role( String role )
+ public String getRoleClassName()
{
- this.role = role;
+ return roleClassName;
}
public String roleHint()
@@ -78,7 +84,7 @@ public class ComponentAnnotationContent
final StringBuilder sb = new StringBuilder();
sb.append( super.toString() );
sb.append( "ComponentAnnotationContent" );
- sb.append( "{role='" ).append( role ).append( '\'' );
+ sb.append( "{role='" ).append( roleClassName ).append( '\'' );
sb.append( ", roleHint='" ).append( roleHint ).append( '\'' );
sb.append( '}' );
return sb.toString();
Modified: maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java Sun May 20 13:20:25 2012
@@ -38,6 +38,7 @@ import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.reflection.Reflector;
import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.Type;
import java.io.BufferedInputStream;
import java.io.File;
@@ -302,12 +303,21 @@ public class DefaultMojoAnnotationsScann
{
for ( Map.Entry<String, Object> entry : mojoFieldVisitor.getMojoAnnotationVisitor().getAnnotationValues().entrySet() )
{
- reflector.invoke( componentAnnotationContent, entry.getKey(),
- new Object[]{ entry.getValue() } );
+ String methodName = entry.getKey();
+ if ( StringUtils.equals( "role", methodName ) )
+ {
+ Type type = (Type) entry.getValue();
+ componentAnnotationContent.setRoleClassName( type.getClassName() );
+ }
+ else
+ {
+ reflector.invoke( componentAnnotationContent, entry.getKey(),
+ new Object[]{ entry.getValue() } );
+ }
}
- if ( StringUtils.isEmpty( componentAnnotationContent.role() ) )
+ if ( StringUtils.isEmpty( componentAnnotationContent.getRoleClassName() ) )
{
- componentAnnotationContent.role( mojoFieldVisitor.getClassName() );
+ componentAnnotationContent.setRoleClassName( mojoFieldVisitor.getClassName() );
}
}
mojoClassVisitor.getMojoAnnotatedClass().getComponents().put( componentAnnotationContent.getFieldName(),
Modified: maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java?rev=1340709&r1=1340708&r2=1340709&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java Sun May 20 13:20:25 2012
@@ -61,7 +61,7 @@ public class FooMojo
/**
*
*/
- @Component( role = "org.apache.maven.artifact.metadata.ArtifactMetadataSource", roleHint = "maven" )
+ @Component( role = ArtifactMetadataSource.class, roleHint = "maven" )
protected ArtifactMetadataSource artifactMetadataSource;
public void execute()