Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7579cfa

Browse filesBrowse files
committed
[MCOMPILER-395] Support exclusions for 'annotationProcessorPaths'
1 parent 3f95d39 commit 7579cfa
Copy full SHA for 7579cfa

File tree

Expand file treeCollapse file tree

14 files changed

+579
-68
lines changed
Filter options
Expand file treeCollapse file tree

14 files changed

+579
-68
lines changed
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<parent>
27+
<groupId>org.apache.maven.plugins.compiler.it</groupId>
28+
<artifactId>mcompiler395-test</artifactId>
29+
<version>1.0.0-SNAPSHOT</version>
30+
</parent>
31+
32+
<artifactId>mcompiler395-annotation-processor-dep</artifactId>
33+
34+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package mcompiler395;
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
public class AnnotationProcessorDependency
22+
{
23+
}
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<parent>
27+
<groupId>org.apache.maven.plugins.compiler.it</groupId>
28+
<artifactId>mcompiler395-test</artifactId>
29+
<version>1.0.0-SNAPSHOT</version>
30+
</parent>
31+
32+
<artifactId>mcompiler395-annotation-processor</artifactId>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.apache.maven.plugins.compiler.it</groupId>
37+
<artifactId>mcompiler395-annotation-processor-dep</artifactId>
38+
<version>1.0.0-SNAPSHOT</version>
39+
</dependency>
40+
</dependencies>
41+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package mcompiler395;
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
import java.io.IOException;
22+
import java.io.Writer;
23+
import java.util.Set;
24+
25+
import javax.annotation.processing.AbstractProcessor;
26+
import javax.annotation.processing.Filer;
27+
import javax.annotation.processing.RoundEnvironment;
28+
import javax.annotation.processing.SupportedAnnotationTypes;
29+
import javax.annotation.processing.SupportedSourceVersion;
30+
import javax.lang.model.SourceVersion;
31+
import javax.lang.model.element.Element;
32+
import javax.lang.model.element.Name;
33+
import javax.lang.model.element.PackageElement;
34+
import javax.lang.model.element.TypeElement;
35+
import javax.lang.model.util.Elements;
36+
import javax.tools.FileObject;
37+
import javax.tools.JavaFileObject;
38+
import javax.tools.StandardLocation;
39+
40+
@SupportedSourceVersion( SourceVersion.RELEASE_6 )
41+
@SupportedAnnotationTypes( "mcompiler395.SimpleAnnotation" )
42+
public class SimpleAnnotationProcessor
43+
extends AbstractProcessor
44+
{
45+
46+
@Override
47+
public boolean process( Set<? extends TypeElement> annotations, RoundEnvironment roundEnv )
48+
{
49+
if ( annotations.isEmpty() )
50+
{
51+
return true;
52+
}
53+
54+
// assert that mcompiler395-annotation-processor-dep is NOT on the processorpath, since it is excluded
55+
// in the plugin configuration
56+
try {
57+
getClass().getClassLoader().loadClass( "mcompiler395.AnnotationProcessorDependency" );
58+
throw new RuntimeException( "Expected a ClassNotFoundException, because "
59+
+ "mcompiler395.AnnotationProcessorDependency is not supposed to be on the processorpath." );
60+
}
61+
catch ( ClassNotFoundException expected )
62+
{
63+
// expected
64+
}
65+
66+
Filer filer = processingEnv.getFiler();
67+
68+
Elements elementUtils = processingEnv.getElementUtils();
69+
70+
Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith( annotations.iterator().next() );
71+
72+
for ( Element element : elements )
73+
{
74+
Name name = element.getSimpleName();
75+
76+
PackageElement packageElement = elementUtils.getPackageOf( element );
77+
78+
try
79+
{
80+
Name packageName = packageElement.getQualifiedName();
81+
FileObject resource =
82+
filer.createResource( StandardLocation.SOURCE_OUTPUT, packageName, name + ".txt", element );
83+
84+
Writer writer = resource.openWriter();
85+
writer.write( name.toString() );
86+
writer.close();
87+
}
88+
catch ( IOException e )
89+
{
90+
throw new RuntimeException( e );
91+
}
92+
}
93+
return !elements.isEmpty();
94+
}
95+
}
+77Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<parent>
27+
<groupId>org.apache.maven.plugins.compiler.it</groupId>
28+
<artifactId>mcompiler395-test</artifactId>
29+
<version>1.0.0-SNAPSHOT</version>
30+
</parent>
31+
32+
<artifactId>mcompiler395-annotation-user</artifactId>
33+
34+
<build>
35+
<plugins>
36+
<plugin>
37+
<artifactId>maven-compiler-plugin</artifactId>
38+
<configuration>
39+
<annotationProcessors>
40+
<annotationProcessor>mcompiler395.SimpleAnnotationProcessor</annotationProcessor>
41+
</annotationProcessors>
42+
<annotationProcessorPaths>
43+
<path>
44+
<groupId>org.apache.maven.plugins.compiler.it</groupId>
45+
<artifactId>mcompiler395-annotation-processor</artifactId>
46+
<version>1.0.0-SNAPSHOT</version>
47+
<exclusions>
48+
<exclusion>
49+
<groupId>org.apache.maven.plugins.compiler.it</groupId>
50+
<artifactId>mcompiler395-annotation-processor-dep</artifactId>
51+
</exclusion>
52+
</exclusions>
53+
</path>
54+
</annotationProcessorPaths>
55+
</configuration>
56+
</plugin>
57+
<plugin>
58+
<groupId>org.apache.maven.plugins.compiler.it</groupId>
59+
<artifactId>annotation-verify-plugin</artifactId>
60+
<version>1.0.0-SNAPSHOT</version>
61+
<executions>
62+
<execution>
63+
<id>verify-annotations</id>
64+
<phase>process-test-classes</phase>
65+
<goals>
66+
<goal>read-source</goal>
67+
</goals>
68+
<configuration>
69+
<sourceClass>mcompiler395.SimpleObject</sourceClass>
70+
<testSourceClass>mcompiler395.SimpleTestObject</testSourceClass>
71+
</configuration>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package mcompiler395;
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
import java.lang.annotation.ElementType;
22+
import java.lang.annotation.Retention;
23+
import java.lang.annotation.RetentionPolicy;
24+
import java.lang.annotation.Target;
25+
26+
@Target(ElementType.TYPE)
27+
@Retention(RetentionPolicy.SOURCE)
28+
public @interface SimpleAnnotation
29+
{
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package mcompiler395;
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
@SimpleAnnotation
22+
public class SimpleObject
23+
{
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package mcompiler395;
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
@SimpleAnnotation
22+
public class SimpleTestObject
23+
{
24+
}
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals=process-test-classes

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.