Author: agudian Date: Fri Jan 8 18:28:55 2016 New Revision: 1723779 URL: http://svn.apache.org/viewvc?rev=1723779&view=rev Log: [MCOMPILER-203] Allow specifying annotation processor path dependencies
Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/pom.xml maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/java/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/java/org/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/java/org/issue/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/java/org/issue/SimpleAnnotationProcessor.java maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/pom.xml maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleAnnotation.java maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleObject.java maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/java/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/java/org/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/java/org/issue/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/java/org/issue/SimpleTestObject.java maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/pom.xml maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/java/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/java/org/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/java/org/issue/ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/java/org/issue/SourcePathReadGoal.java maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/invoker.properties maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/pom.xml maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/DependencyCoordinate.java Modified: maven/plugins/trunk/maven-compiler-plugin/pom.xml maven/plugins/trunk/maven-compiler-plugin/src/it/jdk16-annotation/src/main/resources/META-INF/services/javax.annotation.processing.Processor maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java Modified: maven/plugins/trunk/maven-compiler-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/pom.xml?rev=1723779&r1=1723778&r2=1723779&view=diff ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/pom.xml (original) +++ maven/plugins/trunk/maven-compiler-plugin/pom.xml Fri Jan 8 18:28:55 2016 @@ -19,7 +19,8 @@ specific language governing permissions 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"> +<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> <parent> @@ -63,7 +64,7 @@ under the License. ! The following property is used in the integration tests MCOMPILER-157 --> <mavenPluginPluginVersion>3.3</mavenPluginPluginVersion> - <plexusCompilerVersion>2.6</plexusCompilerVersion> + <plexusCompilerVersion>2.7-SNAPSHOT</plexusCompilerVersion> <groovyVersion>1.8.0</groovyVersion> <groovyEclipseCompilerVersion>2.7.0-01</groovyEclipseCompilerVersion> <groovy-eclipse-batch>2.0.4-04</groovy-eclipse-batch> @@ -150,18 +151,17 @@ under the License. </dependency> <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - <version>1.5.5</version> - </dependency> - - <dependency> <groupId>org.apache.maven.plugin-testing</groupId> <artifactId>maven-plugin-testing-harness</artifactId> - <version>2.0-alpha-1</version> + <version>2.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-compat</artifactId> + <version>${mavenVersion}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> @@ -171,7 +171,7 @@ under the License. <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.8.1</version> + <version>4.12</version> <scope>test</scope> </dependency> @@ -185,26 +185,23 @@ under the License. <artifactId>apache-rat-plugin</artifactId> <configuration> <excludes combine.children="append"> - <exclude>src/it/jdk16-annotation/src/main/resources/META-INF/services/javax.annotation.processing.Processor</exclude> <exclude>.java-version</exclude> </excludes> </configuration> </plugin> <plugin> <artifactId>maven-enforcer-plugin</artifactId> + <version>1.4.1</version> <executions> <execution> <id>enforce-bytecode-version</id> <configuration> - <rules> - <enforceBytecodeVersion> - <maxJdkVersion>1.5</maxJdkVersion> - <excludes> - <exclude>org.apache.openjpa:openjpa</exclude> - <exclude>org.codehaus.groovy:groovy-eclipse-batch</exclude> - </excludes> - </enforceBytecodeVersion> - </rules> + <rules> + <enforceBytecodeVersion> + <maxJdkVersion>1.6</maxJdkVersion> + </enforceBytecodeVersion> + <requireSameVersions /> + </rules> </configuration> </execution> </executions> @@ -225,22 +222,22 @@ under the License. <executions> <execution> <id>integration-test</id> - <configuration> - <debug>true</debug> - <projectsDirectory>src/it</projectsDirectory> - <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> - <pomIncludes> - <pomInclude>*/pom.xml</pomInclude> - <pomInclude>extras/*/pom.xml</pomInclude> - </pomIncludes> - <postBuildHookScript>verify</postBuildHookScript> - <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> - <settingsFile>src/it/settings.xml</settingsFile> - <goals> - <goal>clean</goal> - <goal>test-compile</goal> - </goals> - </configuration> + <configuration> + <debug>true</debug> + <projectsDirectory>src/it</projectsDirectory> + <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> + <pomIncludes> + <pomInclude>*/pom.xml</pomInclude> + <pomInclude>extras/*/pom.xml</pomInclude> + </pomIncludes> + <postBuildHookScript>verify</postBuildHookScript> + <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> + <settingsFile>src/it/settings.xml</settingsFile> + <goals> + <goal>clean</goal> + <goal>test-compile</goal> + </goals> + </configuration> </execution> </executions> </plugin> Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/pom.xml?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/pom.xml (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/pom.xml Fri Jan 8 18:28:55 2016 @@ -0,0 +1,34 @@ +<?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> + + + <parent> + <groupId>org.issue</groupId> + <artifactId>compiler-test</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>annotation-processor</artifactId> +</project> Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/java/org/issue/SimpleAnnotationProcessor.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/java/org/issue/SimpleAnnotationProcessor.java?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/java/org/issue/SimpleAnnotationProcessor.java (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-processor/src/main/java/org/issue/SimpleAnnotationProcessor.java Fri Jan 8 18:28:55 2016 @@ -0,0 +1,85 @@ +package org.issue; + +/* + * 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 java.io.IOException; +import java.io.Writer; +import java.util.Set; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Filer; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.Name; +import javax.lang.model.element.PackageElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.util.Elements; +import javax.tools.FileObject; +import javax.tools.StandardLocation; + +@SupportedSourceVersion( SourceVersion.RELEASE_6 ) +@SupportedAnnotationTypes( "org.issue.SimpleAnnotation" ) +public class SimpleAnnotationProcessor + extends AbstractProcessor +{ + + @Override + public boolean process( Set<? extends TypeElement> annotations, RoundEnvironment roundEnv ) + { + if ( annotations.isEmpty() ) + { + return true; + } + + Filer filer = processingEnv.getFiler(); + + Elements elementUtils = processingEnv.getElementUtils(); + + Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith( annotations.iterator().next() ); + + for ( Element element : elements ) + { + Name name = element.getSimpleName(); + + PackageElement packageElement = elementUtils.getPackageOf( element ); + + try + { + FileObject resource = + filer.createResource( StandardLocation.SOURCE_OUTPUT, packageElement.getQualifiedName(), name + + ".txt", element ); + + Writer writer = resource.openWriter(); + writer.write( name.toString() ); + writer.close(); + } + catch ( IOException e ) + { + throw new RuntimeException( e ); + } + } + + return !elements.isEmpty(); + } + +} Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/pom.xml?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/pom.xml (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/pom.xml Fri Jan 8 18:28:55 2016 @@ -0,0 +1,81 @@ +<?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> + + <parent> + <groupId>org.issue</groupId> + <artifactId>compiler-test</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>annotation-user</artifactId> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.10</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.6</source> + <target>1.6</target> + <annotationProcessors> + <annotationProcessor>org.issue.SimpleAnnotationProcessor</annotationProcessor> + </annotationProcessors> + <annotationProcessorPaths> + <path> + <groupId>org.issue</groupId> + <artifactId>annotation-processor</artifactId> + <version>1.0-SNAPSHOT</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + <plugin> + <groupId>org.issue</groupId> + <artifactId>annotation-verify</artifactId> + <version>1.0-SNAPSHOT</version> + <executions> + <execution> + <id>verify-annotations</id> + <goals> + <goal>read-source</goal> + </goals> + <configuration> + <sourceClass>org.issue.SimpleObject</sourceClass> + <testSourceClass>org.issue.SimpleTestObject</testSourceClass> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleAnnotation.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleAnnotation.java?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleAnnotation.java (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleAnnotation.java Fri Jan 8 18:28:55 2016 @@ -0,0 +1,31 @@ +package org.issue; + +/* + * 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 java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.SOURCE) +public @interface SimpleAnnotation { + +} Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleObject.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleObject.java?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleObject.java (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/main/java/org/issue/SimpleObject.java Fri Jan 8 18:28:55 2016 @@ -0,0 +1,26 @@ +package org.issue; + +/* + * 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. + */ + +@SimpleAnnotation +public class SimpleObject +{ + +} Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/java/org/issue/SimpleTestObject.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/java/org/issue/SimpleTestObject.java?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/java/org/issue/SimpleTestObject.java (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-user/src/test/java/org/issue/SimpleTestObject.java Fri Jan 8 18:28:55 2016 @@ -0,0 +1,26 @@ +package org.issue; + +/* + * 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. + */ + +@SimpleAnnotation +public class SimpleTestObject +{ + +} Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/pom.xml?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/pom.xml (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/pom.xml Fri Jan 8 18:28:55 2016 @@ -0,0 +1,123 @@ +<?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> + + <parent> + <groupId>org.issue</groupId> + <artifactId>compiler-test</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>annotation-verify</artifactId> + <packaging>maven-plugin</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + <version>3.3</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>@mavenVersion@</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact</artifactId> + <version>@mavenVersion@</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>@mavenVersion@</version> + <exclusions> + <exclusion> + <groupId>org.apache.maven.reporting</groupId> + <artifactId>maven-reporting-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-file</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-http-lightweight</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-ssh</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-ssh-external</artifactId> + </exclusion> + <exclusion> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + </exclusion> + <exclusion> + <groupId>classworlds</groupId> + <artifactId>classworlds</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-container-default</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-interactivity-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-shared-utils</artifactId> + <version>0.1</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>@mavenPluginPluginVersion@</version> + <configuration> + <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> + </configuration> + <executions> + <execution> + <id>mojo-descriptor</id> + <phase>process-classes</phase> + <goals> + <goal>descriptor</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/java/org/issue/SourcePathReadGoal.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/java/org/issue/SourcePathReadGoal.java?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/java/org/issue/SourcePathReadGoal.java (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/annotation-verify/src/main/java/org/issue/SourcePathReadGoal.java Fri Jan 8 18:28:55 2016 @@ -0,0 +1,107 @@ +package org.issue; + +/* + * 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 java.io.File; +import java.io.IOException; +import java.util.List; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.MojoExecutionException; +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.MavenProject; +import org.apache.maven.shared.utils.StringUtils; +import org.apache.maven.shared.utils.io.FileUtils; + +@Mojo( name = "read-source", defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES ) +public class SourcePathReadGoal + extends AbstractMojo +{ + + @Parameter + protected String sourceClass; + + @Parameter + protected String testSourceClass; + + @Parameter( defaultValue = "${project}" ) + protected MavenProject project; + + @SuppressWarnings( "unchecked" ) + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( sourceClass != null ) + { + getLog().info( "Checking compile source roots for: '" + sourceClass + "'" ); + assertGeneratedSourceFileFor( sourceClass, project.getCompileSourceRoots() ); + } + + if ( testSourceClass != null ) + { + getLog().info( "Checking test-compile source roots for: '" + testSourceClass + "'" ); + assertGeneratedSourceFileFor( testSourceClass, project.getTestCompileSourceRoots() ); + } + } + + private void assertGeneratedSourceFileFor( String sourceClass, List<String> sourceRoots ) + throws MojoFailureException, MojoExecutionException + { + String sourceFile = sourceClass.replace( '.', '/' ) + .concat( ".txt" ); + + boolean found = false; + for ( String root : sourceRoots ) + { + File f = new File( root, sourceFile ); + getLog().info( "Looking for: " + f ); + if ( f.exists() ) + { + try + { + String[] nameParts = sourceClass.split( "\\." ); + String content = FileUtils.fileRead( f ); + if ( !nameParts[nameParts.length-1].equals( content ) ) + { + throw new MojoFailureException( "Non-matching content in: " + f + "\n expected: '" + + sourceClass + "'\n found: '" + content + "'" ); + } + + found = true; + break; + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Cannot read contents of: " + f, e ); + } + } + } + + if ( !found ) + { + throw new MojoFailureException( "Cannot find generated source file: " + sourceFile + " in:\n " + + StringUtils.join( sourceRoots.iterator(), "\n " ) ); + } + } + +} Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/invoker.properties?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/invoker.properties (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/invoker.properties Fri Jan 8 18:28:55 2016 @@ -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.6+ +invoker.goals=clean process-test-classes Added: maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/pom.xml?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/pom.xml (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-203-processorpath/pom.xml Fri Jan 8 18:28:55 2016 @@ -0,0 +1,53 @@ +<?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>org.issue</groupId> + <artifactId>compiler-test</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <modules> + <module>annotation-processor</module> + <module>annotation-verify</module> + <module>annotation-user</module> + </modules> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <source>1.6</source> + <target>1.6</target> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> Modified: maven/plugins/trunk/maven-compiler-plugin/src/it/jdk16-annotation/src/main/resources/META-INF/services/javax.annotation.processing.Processor URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/it/jdk16-annotation/src/main/resources/META-INF/services/javax.annotation.processing.Processor?rev=1723779&r1=1723778&r2=1723779&view=diff ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/it/jdk16-annotation/src/main/resources/META-INF/services/javax.annotation.processing.Processor (original) +++ maven/plugins/trunk/maven-compiler-plugin/src/it/jdk16-annotation/src/main/resources/META-INF/services/javax.annotation.processing.Processor Fri Jan 8 18:28:55 2016 @@ -1 +1,18 @@ +# 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. + com.mycompany.jdk16annotation.ServiceProviderProcessor Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java?rev=1723779&r1=1723778&r2=1723779&view=diff ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java (original) +++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java Fri Jan 8 18:28:55 2016 @@ -19,6 +19,14 @@ package org.apache.maven.plugin.compiler * under the License. */ +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.handler.ArtifactHandler; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.artifact.resolver.ResolutionErrorHandler; +import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecution; @@ -26,6 +34,7 @@ import org.apache.maven.plugin.MojoExecu import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.RepositorySystem; import org.apache.maven.shared.incremental.IncrementalBuildHelper; import org.apache.maven.shared.incremental.IncrementalBuildHelperRequest; import org.apache.maven.shared.utils.ReaderFactory; @@ -60,8 +69,9 @@ import java.util.Map; import java.util.Set; /** - * TODO: At least one step could be optimized, currently the plugin will do two scans of all the source code if the - * compiler has to have the entire set of sources. This is currently the case for at least the C# compiler and most + * TODO: At least one step could be optimized, currently the plugin will do two + * scans of all the source code if the compiler has to have the entire set of + * sources. This is currently the case for at least the C# compiler and most * likely all the other .NET compilers too. * * @author others @@ -215,6 +225,35 @@ public abstract class AbstractCompilerMo /** * <p> + * Classpath elements to supply as annotation processor path. If specified, the compiler will detect annotation + * processors only in those classpath elements. If omitted, the default classpath is used to detect annotation + * processors. The detection itself depends on the configuration of {@code annotationProcessors}. + * </p> + * <p> + * Each classpath element is specified using their Maven coordinates (groupId, artifactId, version, classifier, + * type). Transitive dependencies are added automatically. Example: + * </p> + * + * <pre> + * <configuration> + * <annotationProcessorPaths> + * <path> + * <groupId>org.sample</groupId> + * <artifactId>sample-annotation-processor</artifactId> + * <version>1.2.3</version> + * </path> + * <!-- ... more ... --> + * </annotationProcessorPaths> + * </configuration> + * </pre> + * + * @since 3.5 + */ + @Parameter + private List<DependencyCoordinate> annotationProcessorPaths; + + /** + * <p> * Sets the arguments to be passed to the compiler (prepending a dash) if {@link #fork} is set to <code>true</code>. * </p> * <p> @@ -384,6 +423,24 @@ public abstract class AbstractCompilerMo @Parameter( defaultValue = "true", property = "maven.compiler.useIncrementalCompilation" ) private boolean useIncrementalCompilation = true; + /** + * Resolves the artifacts needed. + */ + @Component + private RepositorySystem repositorySystem; + + /** + * Artifact handler manager. + */ + @Component + private ArtifactHandlerManager artifactHandlerManager; + + /** + * Throws an exception on artifact resolution errors. + */ + @Component + private ResolutionErrorHandler resolutionErrorHandler; + protected abstract SourceInclusionScanner getSourceInclusionScanner( int staleMillis ); protected abstract SourceInclusionScanner getSourceInclusionScanner( String inputFileEnding ); @@ -543,6 +600,8 @@ public abstract class AbstractCompilerMo compilerConfiguration.setAnnotationProcessors( annotationProcessors ); + compilerConfiguration.setProcessorPathEntries( resolveProcessorPathEntries() ); + compilerConfiguration.setSourceEncoding( encoding ); Map<String, String> effectiveCompilerArguments = getCompilerArguments(); @@ -1285,4 +1344,60 @@ public abstract class AbstractCompilerMo return false; } + private List<String> resolveProcessorPathEntries() + throws MojoExecutionException + { + if ( annotationProcessorPaths == null || annotationProcessorPaths.isEmpty() ) + { + return null; + } + + try + { + Set<Artifact> requiredArtifacts = new HashSet<Artifact>(); + + for ( DependencyCoordinate coord : annotationProcessorPaths ) + { + ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( coord.getType() ); + + Artifact artifact = new DefaultArtifact( + coord.getGroupId(), + coord.getArtifactId(), + VersionRange.createFromVersionSpec( coord.getVersion() ), + Artifact.SCOPE_RUNTIME, + coord.getType(), + coord.getClassifier(), + handler, + false ); + + requiredArtifacts.add( artifact ); + } + + ArtifactResolutionRequest request = new ArtifactResolutionRequest() + .setArtifact( project.getArtifact() ) + .setResolveRoot( false ) + .setResolveTransitively( true ) + .setArtifactDependencies( requiredArtifacts ) + .setLocalRepository( session.getLocalRepository() ) + .setRemoteRepositories( project.getRemoteArtifactRepositories() ); + + ArtifactResolutionResult resolutionResult = repositorySystem.resolve( request ); + + resolutionErrorHandler.throwErrors( request, resolutionResult ); + + List<String> classpathElements = new ArrayList<String>( resolutionResult.getArtifacts().size() ); + + for ( Object resolved : resolutionResult.getArtifacts() ) + { + classpathElements.add( ( (Artifact) resolved ).getFile().getAbsolutePath() ); + } + + return classpathElements; + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Resolution of annotationProcessorPath dependencies failed: " + + e.getLocalizedMessage(), e ); + } + } } Added: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/DependencyCoordinate.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/DependencyCoordinate.java?rev=1723779&view=auto ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/DependencyCoordinate.java (added) +++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/DependencyCoordinate.java Fri Jan 8 18:28:55 2016 @@ -0,0 +1,183 @@ +package org.apache.maven.plugin.compiler; + +/* + * 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. + */ + +/** + * Simple representation of Maven-coordinates of a dependency. + * + * @author Andreas Gudian + * @since 3.4 + */ +public class DependencyCoordinate +{ + private String groupId; + + private String artifactId; + + private String version; + + private String classifier; + + private String type = "jar"; + + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + public String getVersion() + { + return version; + } + + public void setVersion( String version ) + { + this.version = version; + } + + public String getClassifier() + { + return classifier; + } + + public void setClassifier( String classifier ) + { + this.classifier = classifier; + } + + public String getType() + { + return type; + } + + public void setType( String type ) + { + this.type = type; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ( ( artifactId == null ) ? 0 : artifactId.hashCode() ); + result = prime * result + ( ( classifier == null ) ? 0 : classifier.hashCode() ); + result = prime * result + ( ( groupId == null ) ? 0 : groupId.hashCode() ); + result = prime * result + ( ( type == null ) ? 0 : type.hashCode() ); + result = prime * result + ( ( version == null ) ? 0 : version.hashCode() ); + return result; + } + + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( obj == null ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + DependencyCoordinate other = (DependencyCoordinate) obj; + if ( artifactId == null ) + { + if ( other.artifactId != null ) + { + return false; + } + } + else if ( !artifactId.equals( other.artifactId ) ) + { + return false; + } + if ( classifier == null ) + { + if ( other.classifier != null ) + { + return false; + } + } + else if ( !classifier.equals( other.classifier ) ) + { + return false; + } + if ( groupId == null ) + { + if ( other.groupId != null ) + { + return false; + } + } + else if ( !groupId.equals( other.groupId ) ) + { + return false; + } + if ( type == null ) + { + if ( other.type != null ) + { + return false; + } + } + else if ( !type.equals( other.type ) ) + { + return false; + } + if ( version == null ) + { + if ( other.version != null ) + { + return false; + } + } + else if ( !version.equals( other.version ) ) + { + return false; + } + return true; + } + + @Override + public String toString() + { + return groupId + ":" + artifactId + ( version != null ? ":" + version : "" ) + + ( classifier != null ? ":" + classifier : "" ) + ( type != null ? "." + type : "" ); + } +}