maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1335766 - in /maven/plugin-tools/branches/MPLUGIN-189: maven-plugin-plugin/ maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/ maven-plugin-tools-annotations/ maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools...
Date Tue, 08 May 2012 21:01:29 GMT
Author: olamy
Date: Tue May  8 21:01:28 2012
New Revision: 1335766

URL: http://svn.apache.org/viewvc?rev=1335766&view=rev
Log:
exclude @Mojo annotation when coming from classes from dependencies

Modified:
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml?rev=1335766&r1=1335765&r2=1335766&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml Tue May  8 21:01:28
2012
@@ -316,6 +316,14 @@
           </plugins>
         </pluginManagement>
       </build>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.maven.plugin-tools</groupId>
+          <artifactId>maven-plugin-tools-annotations</artifactId>
+          <version>${project.version}</version>
+          <classifier>tests</classifier>
+        </dependency>
+      </dependencies>
     </profile>
   </profiles>
 </project>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml?rev=1335766&r1=1335765&r2=1335766&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
(original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
Tue May  8 21:01:28 2012
@@ -45,6 +45,12 @@ under the License.
       <version>2.0</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-tools-annotations</artifactId>
+      <version>@project.version@</version>
+      <classifier>tests</classifier>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
       <version>@mavenVersion@</version>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/pom.xml?rev=1335766&r1=1335765&r2=1335766&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/pom.xml Tue May
 8 21:01:28 2012
@@ -79,4 +79,20 @@
 
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

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=1335766&r1=1335765&r2=1335766&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:28 2012
@@ -75,12 +75,12 @@ public class DefaultMojoAnnotationsScann
                     if ( dependencyFile.isDirectory() )
                     {
                         mojoAnnotatedClasses.putAll(
-                            scanDirectory( dependencyFile, request.getIncludePatterns(),
dependency ) );
+                            scanDirectory( dependencyFile, request.getIncludePatterns(),
dependency, true ) );
                     }
                     else
                     {
                         mojoAnnotatedClasses.putAll(
-                            scanFile( dependencyFile, request.getIncludePatterns(), dependency
) );
+                            scanFile( dependencyFile, request.getIncludePatterns(), dependency,
true ) );
                     }
                 }
             }
@@ -89,8 +89,9 @@ public class DefaultMojoAnnotationsScann
             {
                 if ( classDirectory.exists() && classDirectory.isDirectory() )
                 {
-                    mojoAnnotatedClasses.putAll( scanDirectory( classDirectory, request.getIncludePatterns(),
-                                                                request.getProject().getArtifact()
) );
+                    mojoAnnotatedClasses.putAll(
+                        scanDirectory( classDirectory, request.getIncludePatterns(), request.getProject().getArtifact(),
+                                       false ) );
                 }
             }
 
@@ -102,8 +103,17 @@ public class DefaultMojoAnnotationsScann
         }
     }
 
+    /**
+     * @param archiveFile
+     * @param includePatterns
+     * @param artifact
+     * @param excludeMojo     for dependencies we exclude Mojo annotations found
+     * @return
+     * @throws IOException
+     * @throws ExtractionException
+     */
     protected Map<String, MojoAnnotatedClass> scanFile( File archiveFile, List<String>
includePatterns,
-                                                        Artifact artifact )
+                                                        Artifact artifact, boolean excludeMojo
)
         throws IOException, ExtractionException
     {
         if ( !archiveFile.exists() )
@@ -126,6 +136,10 @@ public class DefaultMojoAnnotationsScann
                     rdr.accept( mojoClassVisitor,
                                 ClassReader.SKIP_FRAMES | ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG
);
                     analyzeVisitors( mojoClassVisitor );
+                    if ( excludeMojo )
+                    {
+                        mojoClassVisitor.getMojoAnnotatedClass().setMojo( null );
+                    }
                     if ( isMojoAnnnotatedClassCandidate( mojoClassVisitor.getMojoAnnotatedClass()
) != null )
                     {
                         getLogger().debug(
@@ -145,8 +159,17 @@ public class DefaultMojoAnnotationsScann
         return mojoAnnotatedClasses;
     }
 
+    /**
+     * @param classDirectory
+     * @param includePatterns
+     * @param artifact
+     * @param excludeMojo     for dependencies we exclude Mojo annotations found
+     * @return
+     * @throws IOException
+     * @throws ExtractionException
+     */
     protected Map<String, MojoAnnotatedClass> scanDirectory( File classDirectory, List<String>
includePatterns,
-                                                             Artifact artifact )
+                                                             Artifact artifact, boolean excludeMojo
)
         throws IOException, ExtractionException
     {
         if ( !classDirectory.exists() )
@@ -177,6 +200,10 @@ public class DefaultMojoAnnotationsScann
                     rdr.accept( mojoClassVisitor,
                                 ClassReader.SKIP_FRAMES | ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG
);
                     analyzeVisitors( mojoClassVisitor );
+                    if ( excludeMojo )
+                    {
+                        mojoClassVisitor.getMojoAnnotatedClass().setMojo( null );
+                    }
                     if ( isMojoAnnnotatedClassCandidate( mojoClassVisitor.getMojoAnnotatedClass()
) != null )
                     {
                         getLogger().debug(



Mime
View raw message