maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1648726 - in /maven/plugin-tools/trunk: ./ maven-plugin-plugin/src/it/mplugin-272_java8/ maven-plugin-plugin/src/it/mplugin-272_java8/src/ maven-plugin-plugin/src/it/mplugin-272_java8/src/main/ maven-plugin-plugin/src/it/mplugin-272_java8/...
Date Wed, 31 Dec 2014 15:59:28 GMT
Author: rfscholte
Date: Wed Dec 31 15:59:28 2014
New Revision: 1648726

URL: http://svn.apache.org/r1648726
Log:
[MPLUGIN-272] Descriptor goal fail with java 8 and interface with default method: upgrade
QDox
Upgraded QDox from 1.12.1 to 2.0-M3

Added:
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/invoker.properties
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/TestInterface.java
Modified:
    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-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaJavadocMojoDescriptorExtractor.java
    maven/plugin-tools/trunk/pom.xml

Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/invoker.properties?rev=1648726&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/invoker.properties
(added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/invoker.properties
Wed Dec 31 15:59:28 2014
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.java.version = 1.8+
+invoker.goals.1 = clean verify
\ No newline at end of file

Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml?rev=1648726&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml Wed Dec
31 15:59:28 2014
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>test-plugin</groupId>
+    <artifactId>test-plugin</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>maven-plugin</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>3.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.plugin-tools</groupId>
+            <artifactId>maven-plugin-annotations</artifactId>
+            <version>@project.version@</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <version>@project.version@</version>
+                <configuration>
+                    <goalPrefix>FOO</goalPrefix>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>default-descriptor</id>
+                        <goals>
+                            <goal>descriptor</goal>
+                        </goals>
+                        <configuration>
+                        </configuration>
+                        <phase>process-classes</phase>
+                    </execution>
+                    <execution>
+                        <id>help-descriptor</id>
+                        <goals>
+                            <goal>helpmojo</goal>
+                        </goals>
+                        <phase>process-classes</phase>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java?rev=1648726&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java
(added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java
Wed Dec 31 15:59:28 2014
@@ -0,0 +1,37 @@
+package fr.ca;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Created by clement.agarini on 04/08/14.
+ */
+@Mojo(name="test-plugin",defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class MyMojo extends AbstractMojo {
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+
+    }
+}

Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/TestInterface.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/TestInterface.java?rev=1648726&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/TestInterface.java
(added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/TestInterface.java
Wed Dec 31 15:59:28 2014
@@ -0,0 +1,27 @@
+package fr.ca;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public interface TestInterface {
+
+    public default void foo(){
+
+    }
+}

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=1648726&r1=1648725&r2=1648726&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
Wed Dec 31 15:59:28 2014
@@ -19,10 +19,22 @@ package org.apache.maven.tools.plugin.an
  * under the License.
  */
 
-import com.thoughtworks.qdox.JavaDocBuilder;
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -54,18 +66,11 @@ import org.codehaus.plexus.component.ann
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
+import com.thoughtworks.qdox.JavaProjectBuilder;
+import com.thoughtworks.qdox.library.SortedClassLibraryBuilder;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
 
 /**
  * JavaMojoDescriptorExtractor, a MojoDescriptor extractor to read descriptors from java
classes with annotations.
@@ -219,7 +224,8 @@ public class JavaAnnotationsMojoDescript
             unArchiver.setDestDirectory( extractDirectory );
             unArchiver.extract();
 
-            return discoverClasses( request.getEncoding(), Arrays.asList( extractDirectory
) );
+            return discoverClasses( request.getEncoding(), Arrays.asList( extractDirectory
), 
+                                    request.getDependencies() );
         }
         catch ( ArtifactResolutionException e )
         {
@@ -377,7 +383,7 @@ public class JavaAnnotationsMojoDescript
 
         if ( superClass != null )
         {
-            if ( superClass.getFields().length > 0 )
+            if ( superClass.getFields().size() > 0 )
             {
                 rawParams = extractFieldParameterTags( superClass, javaClassesMap );
             }
@@ -394,15 +400,11 @@ public class JavaAnnotationsMojoDescript
             rawParams = new TreeMap<String, JavaField>();
         }
 
-        JavaField[] classFields = javaClass.getFields();
-
-        if ( classFields != null )
+        for ( JavaField field : javaClass.getFields() )
         {
-            for ( JavaField field : classFields )
-            {
-                rawParams.put( field.getName(), field );
-            }
+            rawParams.put( field.getName(), field );
         }
+        
         return rawParams;
     }
 
@@ -429,27 +431,43 @@ public class JavaAnnotationsMojoDescript
             sources.add( generatedPlugin );
         }
 
-        return discoverClasses( encoding, sources );
+        return discoverClasses( encoding, sources,  project.getArtifacts() );
     }
 
-    protected Map<String, JavaClass> discoverClasses( final String encoding, List<File>
sourceDirectories )
+    protected Map<String, JavaClass> discoverClasses( final String encoding, List<File>
sourceDirectories,
+                                                      Set<Artifact> artifacts )
     {
-        JavaDocBuilder builder = new JavaDocBuilder();
+        JavaProjectBuilder builder = new JavaProjectBuilder( new SortedClassLibraryBuilder()
);
         builder.setEncoding( encoding );
 
+        // Build isolated Classloader with only the artifacts of the project (none of this
plugin) 
+        List<URL> urls = new ArrayList<URL>( artifacts.size() );
+        for ( Artifact artifact : artifacts )
+        {
+            try
+            {
+                urls.add( artifact.getFile().toURI().toURL() );
+            }
+            catch ( MalformedURLException e )
+            {
+                // noop
+            }
+        }
+        builder.addClassLoader( new URLClassLoader( urls.toArray( new URL[0] ), ClassLoader.getSystemClassLoader()
) );
+
         for ( File source : sourceDirectories )
         {
             builder.addSourceTree( source );
         }
 
-        JavaClass[] javaClasses = builder.getClasses();
+        Collection<JavaClass> javaClasses = builder.getClasses();
 
-        if ( javaClasses == null || javaClasses.length < 1 )
+        if ( javaClasses == null || javaClasses.size() < 1 )
         {
             return Collections.emptyMap();
         }
 
-        Map<String, JavaClass> javaClassMap = new HashMap<String, JavaClass>(
javaClasses.length );
+        Map<String, JavaClass> javaClassMap = new HashMap<String, JavaClass>(
javaClasses.size() );
 
         for ( JavaClass javaClass : javaClasses )
         {

Modified: maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaJavadocMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaJavadocMojoDescriptorExtractor.java?rev=1648726&r1=1648725&r2=1648726&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaJavadocMojoDescriptorExtractor.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaJavadocMojoDescriptorExtractor.java
Wed Dec 31 15:59:28 2014
@@ -19,12 +19,17 @@ package org.apache.maven.tools.plugin.ex
  * under the License.
  */
 
-import com.thoughtworks.qdox.JavaDocBuilder;
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.Type;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.descriptor.InvalidParameterException;
 import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
@@ -33,19 +38,19 @@ import org.apache.maven.plugin.descripto
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
 import org.apache.maven.tools.plugin.PluginToolsRequest;
-import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
 import org.apache.maven.tools.plugin.extractor.ExtractionException;
+import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
 import org.apache.maven.tools.plugin.util.PluginUtils;
-
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
+import com.thoughtworks.qdox.JavaProjectBuilder;
+import com.thoughtworks.qdox.library.SortedClassLibraryBuilder;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
+import com.thoughtworks.qdox.model.JavaType;
 
 /**
  * Extracts Mojo descriptors from <a href="http://java.sun.com/">Java</a> sources.
@@ -469,29 +474,13 @@ public class JavaJavadocMojoDescriptorEx
         {
             JavaField field = entry.getValue();
 
-            Type type = field.getType();
+            JavaType type = field.getType();
 
             Parameter pd = new Parameter();
 
             pd.setName( entry.getKey() );
 
-            if ( !type.isArray() )
-            {
-                pd.setType( type.getValue() );
-            }
-            else
-            {
-                StringBuilder value = new StringBuilder( type.getValue() );
-
-                int remaining = type.getDimensions();
-
-                while ( remaining-- > 0 )
-                {
-                    value.append( "[]" );
-                }
-
-                pd.setType( value.toString() );
-            }
+            pd.setType( type.getFullyQualifiedName() );
 
             pd.setDescription( field.getComment() );
 
@@ -656,17 +645,12 @@ public class JavaJavadocMojoDescriptorEx
             rawParams = new TreeMap<String, JavaField>();
         }
 
-        JavaField[] classFields = javaClass.getFields();
-
-        if ( classFields != null )
+        for ( JavaField field : javaClass.getFields() )
         {
-            for ( JavaField field : classFields )
+            if ( field.getTagByName( JavadocMojoAnnotation.PARAMETER ) != null
+                || field.getTagByName( JavadocMojoAnnotation.COMPONENT ) != null )
             {
-                if ( field.getTagByName( JavadocMojoAnnotation.PARAMETER ) != null
-                    || field.getTagByName( JavadocMojoAnnotation.COMPONENT ) != null )
-                {
-                    rawParams.put( field.getName(), field );
-                }
+                rawParams.put( field.getName(), field );
             }
         }
         return rawParams;
@@ -676,7 +660,7 @@ public class JavaJavadocMojoDescriptorEx
     public List<MojoDescriptor> execute( PluginToolsRequest request )
         throws ExtractionException, InvalidPluginDescriptorException
     {
-        JavaClass[] javaClasses = discoverClasses( request );
+        Collection<JavaClass> javaClasses = discoverClasses( request );
 
         List<MojoDescriptor> descriptors = new ArrayList<MojoDescriptor>();
 
@@ -704,11 +688,26 @@ public class JavaJavadocMojoDescriptorEx
      * @return an array of java class
      */
     @SuppressWarnings( "unchecked" )
-    protected JavaClass[] discoverClasses( final PluginToolsRequest request )
+    protected Collection<JavaClass> discoverClasses( final PluginToolsRequest request
)
     {
-        JavaDocBuilder builder = new JavaDocBuilder();
+        JavaProjectBuilder builder = new JavaProjectBuilder( new SortedClassLibraryBuilder()
);
         builder.setEncoding( request.getEncoding() );
         
+         // Build isolated Classloader with only the artifacts of the project (none of this
plugin) 
+        List<URL> urls = new ArrayList<URL>( request.getDependencies().size()
);
+        for ( Artifact artifact : request.getDependencies() )
+        {
+            try
+            {
+                urls.add( artifact.getFile().toURI().toURL() );
+            }
+            catch ( MalformedURLException e )
+            {
+                // noop
+            }
+        }
+        builder.addClassLoader( new URLClassLoader( urls.toArray( new URL[0] ), ClassLoader.getSystemClassLoader()
) );
+        
         MavenProject project = request.getProject();
 
         for ( String source : (List<String>) project.getCompileSourceRoots() )

Modified: maven/plugin-tools/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/pom.xml?rev=1648726&r1=1648725&r2=1648726&view=diff
==============================================================================
--- maven/plugin-tools/trunk/pom.xml (original)
+++ maven/plugin-tools/trunk/pom.xml Wed Dec 31 15:59:28 2014
@@ -217,7 +217,7 @@
       <dependency>
         <groupId>com.thoughtworks.qdox</groupId>
         <artifactId>qdox</artifactId>
-        <version>1.12.1</version>
+        <version>2.0-M3</version>
       </dependency>
 
       <dependency>



Mime
View raw message