Author: olamy
Date: Tue May 8 21:01:10 2012
New Revision: 1335765
URL: http://svn.apache.org/viewvc?rev=1335765&view=rev
Log:
store the origin artifact of the annotation for later use
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/AnnotatedContent.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotationsScannerRequest.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy?rev=1335765&r1=1335764&r2=1335765&view=diff
==============================================================================
---
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy
(original)
+++
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy
Tue May 8 21:01:10 2012
@@ -6,6 +6,8 @@ assert descriptorFile.isFile()
def pluginDescriptor = new XmlParser().parse( descriptorFile );
+assert pluginDescriptor.mojos.mojo.size() == 3
+
def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first"}[0]
assert mojo.goal.text() == 'first'
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java?rev=1335765&r1=1335764&r2=1335765&view=diff
==============================================================================
---
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
(original)
+++
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
Tue May 8 21:01:10 2012
@@ -82,6 +82,8 @@ public class JavaAnnotationsMojoDescript
mojoAnnotationsScannerRequest.setDependencies(
request.getDependencies() );
+ mojoAnnotationsScannerRequest.setProject( request.getProject() );
+
Map<String, MojoAnnotatedClass> mojoAnnotatedClasses =
mojoAnnotationsScanner.scan( mojoAnnotationsScannerRequest );
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/AnnotatedContent.java
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/AnnotatedContent.java?rev=1335765&r1=1335764&r2=1335765&view=diff
==============================================================================
---
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/AnnotatedContent.java
(original)
+++
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/AnnotatedContent.java
Tue May 8 21:01:10 2012
@@ -18,12 +18,15 @@ package org.apache.maven.tools.plugin.an
* under the License.
*/
+import org.apache.maven.artifact.Artifact;
+
/**
* @author Olivier Lamy
* @since 3.0
*/
public class AnnotatedContent
{
+
private String description;
private String since;
@@ -59,4 +62,5 @@ public class AnnotatedContent
{
this.deprecated = deprecated;
}
+
}
Modified:
maven/plugin-tools/branches/MPLUGIN-189/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/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java?rev=1335765&r1=1335764&r2=1335765&view=diff
==============================================================================
---
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
(original)
+++
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
Tue May 8 21:01:10 2012
@@ -74,11 +74,13 @@ public class DefaultMojoAnnotationsScann
{
if ( dependencyFile.isDirectory() )
{
- mojoAnnotatedClasses.putAll( scanDirectory(
dependencyFile, request.getIncludePatterns() ) );
+ mojoAnnotatedClasses.putAll(
+ scanDirectory( dependencyFile,
request.getIncludePatterns(), dependency ) );
}
else
{
- mojoAnnotatedClasses.putAll( scanFile( dependencyFile,
request.getIncludePatterns() ) );
+ mojoAnnotatedClasses.putAll(
+ scanFile( dependencyFile,
request.getIncludePatterns(), dependency ) );
}
}
}
@@ -87,7 +89,8 @@ public class DefaultMojoAnnotationsScann
{
if ( classDirectory.exists() && classDirectory.isDirectory() )
{
- mojoAnnotatedClasses.putAll( scanDirectory(
classDirectory, request.getIncludePatterns() ) );
+ mojoAnnotatedClasses.putAll( scanDirectory(
classDirectory, request.getIncludePatterns(),
+
request.getProject().getArtifact() ) );
}
}
@@ -99,7 +102,8 @@ public class DefaultMojoAnnotationsScann
}
}
- protected Map<String, MojoAnnotatedClass> scanFile( File archiveFile,
List<String> includePatterns )
+ protected Map<String, MojoAnnotatedClass> scanFile( File archiveFile,
List<String> includePatterns,
+ Artifact artifact )
throws IOException, ExtractionException
{
if ( !archiveFile.exists() )
@@ -127,6 +131,7 @@ public class DefaultMojoAnnotationsScann
getLogger().debug(
"found MojoAnnotatedClass:" +
mojoClassVisitor.getMojoAnnotatedClass().getClassName() + ":"
+ mojoClassVisitor.getMojoAnnotatedClass() );
+ mojoClassVisitor.getMojoAnnotatedClass().setArtifact(
artifact );
mojoAnnotatedClasses.put(
mojoClassVisitor.getMojoAnnotatedClass().getClassName(),
mojoClassVisitor.getMojoAnnotatedClass() );
}
@@ -140,7 +145,8 @@ public class DefaultMojoAnnotationsScann
return mojoAnnotatedClasses;
}
- protected Map<String, MojoAnnotatedClass> scanDirectory( File
classDirectory, List<String> includePatterns )
+ protected Map<String, MojoAnnotatedClass> scanDirectory( File
classDirectory, List<String> includePatterns,
+ Artifact artifact
)
throws IOException, ExtractionException
{
if ( !classDirectory.exists() )
@@ -176,6 +182,7 @@ public class DefaultMojoAnnotationsScann
getLogger().debug(
"found MojoAnnotatedClass:" +
mojoClassVisitor.getMojoAnnotatedClass().getClassName() + ":"
+ mojoClassVisitor.getMojoAnnotatedClass() );
+ mojoClassVisitor.getMojoAnnotatedClass().setArtifact(
artifact );
mojoAnnotatedClasses.put(
mojoClassVisitor.getMojoAnnotatedClass().getClassName(),
mojoClassVisitor.getMojoAnnotatedClass() );
}
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java?rev=1335765&r1=1335764&r2=1335765&view=diff
==============================================================================
---
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java
(original)
+++
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java
Tue May 8 21:01:10 2012
@@ -18,6 +18,7 @@ package org.apache.maven.tools.plugin.an
* under the License.
*/
+import org.apache.maven.artifact.Artifact;
import
org.apache.maven.tools.plugin.annotations.datamodel.ComponentAnnotationContent;
import
org.apache.maven.tools.plugin.annotations.datamodel.ExecuteAnnotationContent;
import
org.apache.maven.tools.plugin.annotations.datamodel.MojoAnnotationContent;
@@ -50,6 +51,11 @@ public class MojoAnnotatedClass
*/
private Map<String, ComponentAnnotationContent> components;
+ /**
+ * artifact which contains this annotation
+ */
+ private Artifact artifact;
+
public MojoAnnotatedClass()
{
// no op
@@ -129,6 +135,15 @@ public class MojoAnnotatedClass
return this;
}
+ public Artifact getArtifact()
+ {
+ return artifact;
+ }
+
+ public void setArtifact( Artifact artifact )
+ {
+ this.artifact = artifact;
+ }
@Override
public String toString()
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotationsScannerRequest.java
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotationsScannerRequest.java?rev=1335765&r1=1335764&r2=1335765&view=diff
==============================================================================
---
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotationsScannerRequest.java
(original)
+++
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotationsScannerRequest.java
Tue May 8 21:01:10 2012
@@ -19,6 +19,8 @@ package org.apache.maven.tools.plugin.an
*/
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import java.io.File;
import java.util.ArrayList;
@@ -41,6 +43,8 @@ public class MojoAnnotationsScannerReque
private List<File> sourceDirectories = new ArrayList<File>();
+ private MavenProject project;
+
public MojoAnnotationsScannerRequest()
{
// no o
@@ -85,4 +89,14 @@ public class MojoAnnotationsScannerReque
{
this.sourceDirectories = sourceDirectories;
}
+
+ public MavenProject getProject()
+ {
+ return project;
+ }
+
+ public void setProject( MavenProject project )
+ {
+ this.project = project;
+ }
}
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java
URL:
http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java?rev=1335765&r1=1335764&r2=1335765&view=diff
==============================================================================
---
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java
(original)
+++
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java
Tue May 8 21:01:10 2012
@@ -22,6 +22,7 @@ import org.apache.maven.plugin.AbstractM
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.project.MavenProject;
import
org.apache.maven.tools.plugin.annotations.datamodel.ComponentAnnotationContent;
import
org.apache.maven.tools.plugin.annotations.datamodel.ParameterAnnotationContent;
import org.apache.maven.tools.plugin.annotations.scanner.MojoAnnotatedClass;
@@ -50,6 +51,7 @@ public class TestAnnotationsReader
MojoAnnotationsScannerRequest request = new
MojoAnnotationsScannerRequest();
request.setClassesDirectories( Collections.singletonList( new File(
"target/test-classes" ) ) );
request.setIncludePatterns( Arrays.asList( "**/FooMojo.class" ) );
+ request.setProject( new MavenProject( ) );
Map<String, MojoAnnotatedClass> mojoAnnotatedClasses =
mojoAnnotationsScanner.scan( request );