Skip to content

Commit 37e39f2

Browse files
famodslachiewicz
authored andcommitted
Fix ECJ not using annotation processor when defined via processorpath
Works around https://bugs.eclipse.org/bugs/show_bug.cgi?id=573833 by adding -classpath to the command line before -processorpath is added. Fixes #349
1 parent ee40a6a commit 37e39f2

File tree

8 files changed

+217
-16
lines changed

8 files changed

+217
-16
lines changed

plexus-compiler-its/src/main/it/eclipse-compiler-mapstruct/pom.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,16 @@
2424
<modelVersion>4.0.0</modelVersion>
2525

2626
<groupId>org.codehaus.plexus.compiler.it</groupId>
27-
<artifactId>simple-javac</artifactId>
27+
<artifactId>eclipse-compiler-mapstruct</artifactId>
2828
<version>1.0-SNAPSHOT</version>
2929

30-
<name>Test for default configuration</name>
31-
3230
<properties>
3331
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3432
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
3533
<maven.compiler.source>1.8</maven.compiler.source>
3634
<maven.compiler.target>1.8</maven.compiler.target>
3735
<plexus.compiler.version>@pom.version@</plexus.compiler.version>
38-
<org.mapstruct.version>1.5.2.Final</org.mapstruct.version>
36+
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
3937
</properties>
4038

4139
<dependencies>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.maven.version = 3.9.6+
19+
20+
invoker.goals = clean compile
21+
invoker.buildResult = success
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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/maven-v4_0_0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<groupId>org.codehaus.plexus.compiler.it</groupId>
27+
<artifactId>eclipse-compiler-procpath</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
30+
<properties>
31+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
33+
<maven.compiler.source>1.8</maven.compiler.source>
34+
<maven.compiler.target>1.8</maven.compiler.target>
35+
<plexus.compiler.version>@pom.version@</plexus.compiler.version>
36+
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>org.mapstruct</groupId>
42+
<artifactId>mapstruct</artifactId>
43+
<version>${org.mapstruct.version}</version>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-compiler-plugin</artifactId>
52+
<version>@maven.compiler.version@</version>
53+
<configuration>
54+
<compilerId>eclipse</compilerId>
55+
<annotationProcessorPaths>
56+
<path>
57+
<groupId>org.mapstruct</groupId>
58+
<artifactId>mapstruct-processor</artifactId>
59+
<version>${org.mapstruct.version}</version>
60+
</path>
61+
</annotationProcessorPaths>
62+
</configuration>
63+
<dependencies>
64+
<dependency>
65+
<groupId>org.codehaus.plexus</groupId>
66+
<artifactId>plexus-compiler-api</artifactId>
67+
<version>${plexus.compiler.version}</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.codehaus.plexus</groupId>
71+
<artifactId>plexus-compiler-eclipse</artifactId>
72+
<version>${plexus.compiler.version}</version>
73+
</dependency>
74+
</dependencies>
75+
</plugin>
76+
</plugins>
77+
</build>
78+
79+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
public class Car
21+
{
22+
public String make;
23+
public int numberOfSeats;
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
public class CarDto
21+
{
22+
public String make;
23+
public int seatCount;
24+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import org.mapstruct.Mapper;
21+
import org.mapstruct.Mapping;
22+
import org.mapstruct.factory.Mappers;
23+
24+
@Mapper
25+
public interface CarMapper
26+
{
27+
28+
CarMapper INSTANCE = Mappers.getMapper( CarMapper.class );
29+
30+
@Mapping( source = "numberOfSeats", target = "seatCount" )
31+
CarDto carToCarDto( Car car );
32+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
def mapperImplClass = new File( basedir, "target/classes/CarMapperImpl.class" )
20+
assert mapperImplClass.exists()
21+

plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompiler.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,21 @@ public CompilerResult performCompile(CompilerConfiguration config) throws Compil
147147
args.add("-d");
148148
args.add(config.getOutputLocation());
149149

150+
// -- classpath
151+
// must be done before annotation processors: https://bugs.eclipse.org/bugs/show_bug.cgi?id=573833
152+
List<String> classpathEntries = new ArrayList<>(config.getClasspathEntries());
153+
classpathEntries.add(config.getOutputLocation());
154+
args.add("-classpath");
155+
args.add(getPathString(classpathEntries));
156+
157+
List<String> modulepathEntries = config.getModulepathEntries();
158+
if (modulepathEntries != null && !modulepathEntries.isEmpty()) {
159+
args.add("--module-path");
160+
args.add(getPathString(modulepathEntries));
161+
}
162+
150163
// Annotation processors defined?
164+
// must be done after classpath: https://bugs.eclipse.org/bugs/show_bug.cgi?id=573833
151165
if (!isPreJava1_6(config)) {
152166
File generatedSourcesDir = config.getGeneratedSourcesDirectory();
153167
if (generatedSourcesDir != null) {
@@ -198,18 +212,6 @@ public CompilerResult performCompile(CompilerConfiguration config) throws Compil
198212
}
199213
}
200214

201-
// -- classpath
202-
List<String> classpathEntries = new ArrayList<>(config.getClasspathEntries());
203-
classpathEntries.add(config.getOutputLocation());
204-
args.add("-classpath");
205-
args.add(getPathString(classpathEntries));
206-
207-
List<String> modulepathEntries = config.getModulepathEntries();
208-
if (modulepathEntries != null && !modulepathEntries.isEmpty()) {
209-
args.add("--module-path");
210-
args.add(getPathString(modulepathEntries));
211-
}
212-
213215
// Collect sources
214216
List<String> allSources = Arrays.asList(getSourceFiles(config));
215217
List<CompilerMessage> messageList = new ArrayList<>();

0 commit comments

Comments
 (0)