Author: olamy
Date: Mon May 28 08:15:25 2012
New Revision: 1343159
URL: http://svn.apache.org/viewvc?rev=1343159&view=rev
Log:
[MPLUGIN-206] Annotations in superclasses are not found if an intermediate
class is not annotated.
Modified:
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
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-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/scanner/DefaultMojoAnnotationsScanner.java
Modified:
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties?rev=1343159&r1=1343158&r2=1343159&view=diff
==============================================================================
---
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
(original)
+++
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
Mon May 28 08:15:25 2012
@@ -2,3 +2,4 @@ invoker.goals.1 = clean install -DskipTe
invoker.goals.2 =
org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:it0014
invoker.goals.3 =
org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:first
invoker.goals.4 =
org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:help
+invoker.goals.5 =
org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:third
\ No newline at end of file
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=1343159&r1=1343158&r2=1343159&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
Mon May 28 08:15:25 2012
@@ -32,7 +32,6 @@ import org.apache.maven.artifact.metadat
import java.io.File;
/**
- * Touches a test file.
*
*/
public abstract class AbstractFirstMojo
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=1343159&r1=1343158&r2=1343159&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
Mon May 28 08:15:25 2012
@@ -144,6 +144,12 @@ public class JavaAnnotationsMojoDescript
continue;
}
+ if ( !isMojoAnnnotatedClassCandidate( mojoAnnotatedClass ) )
+ {
+
+ continue;
+ }
+
MavenProject mavenProject =
getFromProjectReferences( mojoAnnotatedClass.getArtifact(),
request.getProject() );
@@ -184,6 +190,17 @@ public class JavaAnnotationsMojoDescript
return javaClassesMap;
}
+ private boolean isMojoAnnnotatedClassCandidate( MojoAnnotatedClass
mojoAnnotatedClass )
+ {
+ if ( mojoAnnotatedClass == null )
+ {
+ return false;
+ }
+ return ( !mojoAnnotatedClass.getComponents().isEmpty() ||
!mojoAnnotatedClass.getParameters().isEmpty()
+ || mojoAnnotatedClass.getExecute() != null ||
mojoAnnotatedClass.getMojo() != null );
+
+ }
+
protected Map<String, JavaClass> discoverClassesFromSourcesJar( Artifact
artifact, PluginToolsRequest request,
String
classifier )
throws ExtractionException
@@ -205,9 +222,8 @@ public class JavaAnnotationsMojoDescript
// extract sources to
target/maven-plugin-plugin-sources/${groupId}/${artifact}/sources
File extractDirectory = new File(
request.getProject().getBuild().getDirectory(),
"maven-plugin-plugin-sources/" +
sourcesArtifact.getGroupId() + "/"
- +
sourcesArtifact.getArtifactId() + "/"
- +
sourcesArtifact.getVersion() + "/"
- +
sourcesArtifact.getClassifier() );
+ +
sourcesArtifact.getArtifactId() + "/" + sourcesArtifact.getVersion()
+ + "/" +
sourcesArtifact.getClassifier() );
extractDirectory.mkdirs();
UnArchiver unArchiver = archiverManager.getUnArchiver( "jar" );
@@ -280,7 +296,7 @@ public class JavaAnnotationsMojoDescript
getParametersParentHierarchy( entry.getValue(), new
HashMap<String, ParameterAnnotationContent>(),
mojoAnnotatedClasses );
for ( Map.Entry<String, ParameterAnnotationContent> parameter :
new TreeMap<String, ParameterAnnotationContent>(
-
parameters ).entrySet() )
+ parameters ).entrySet() )
{
JavaField javaField = fieldsMap.get( parameter.getKey() );
if ( javaField == null )
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=1343159&r1=1343158&r2=1343159&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
Mon May 28 08:15:25 2012
@@ -143,7 +143,7 @@ public class DefaultMojoAnnotationsScann
{
mojoClassVisitor.getMojoAnnotatedClass().setMojo( null
);
}
- if ( isMojoAnnnotatedClassCandidate(
mojoClassVisitor.getMojoAnnotatedClass() ) != null )
+ if ( isStoreClass(
mojoClassVisitor.getMojoAnnotatedClass() ) != null )
{
getLogger().debug(
"found MojoAnnotatedClass:" +
mojoClassVisitor.getMojoAnnotatedClass().getClassName() + ":"
@@ -207,7 +207,7 @@ public class DefaultMojoAnnotationsScann
{
mojoClassVisitor.getMojoAnnotatedClass().setMojo( null
);
}
- if ( isMojoAnnnotatedClassCandidate(
mojoClassVisitor.getMojoAnnotatedClass() ) != null )
+ if ( isStoreClass(
mojoClassVisitor.getMojoAnnotatedClass() ) != null )
{
getLogger().debug(
"found MojoAnnotatedClass:" +
mojoClassVisitor.getMojoAnnotatedClass().getClassName() + ":"
@@ -228,20 +228,24 @@ public class DefaultMojoAnnotationsScann
return mojoAnnotatedClasses;
}
- private MojoAnnotatedClass isMojoAnnnotatedClassCandidate(
MojoAnnotatedClass mojoAnnotatedClass )
+ private MojoAnnotatedClass isStoreClass( MojoAnnotatedClass
mojoAnnotatedClass )
{
if ( mojoAnnotatedClass == null )
{
return null;
}
- if ( !mojoAnnotatedClass.getComponents().isEmpty() ||
!mojoAnnotatedClass.getParameters().isEmpty()
- || mojoAnnotatedClass.getExecute() != null ||
mojoAnnotatedClass.getMojo() != null )
- {
- return mojoAnnotatedClass;
- }
- return null;
+ return mojoAnnotatedClass;
+ /**
+ if ( !mojoAnnotatedClass.getComponents().isEmpty() ||
!mojoAnnotatedClass.getParameters().isEmpty()
+ || mojoAnnotatedClass.getExecute() != null ||
mojoAnnotatedClass.getMojo() != null )
+ {
+ return mojoAnnotatedClass;
+ }
+ return null;
+ **/
}
+
protected void analyzeVisitors( MojoClassVisitor mojoClassVisitor )
throws ExtractionException
{