Skip to content

Commit ea36bb0

Browse files
authored
Add Maven Compiler Plugin compiler it tests (#99)
* add compiler its test with maven compiler plugin Signed-off-by: olivier lamy <[email protected]> * fix dependencyManagement Signed-off-by: olivier lamy <[email protected]> * it compiler test source/target 8 as minimum Signed-off-by: olivier lamy <[email protected]> * it compiler test source/target 8 as minimum Signed-off-by: olivier lamy <[email protected]>
1 parent c6b5949 commit ea36bb0

File tree

13 files changed

+480
-0
lines changed

13 files changed

+480
-0
lines changed

plexus-compiler-its/pom.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.codehaus.plexus</groupId>
7+
<artifactId>plexus-compiler</artifactId>
8+
<version>2.8.8-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>plexus-compiler-its</artifactId>
12+
<packaging>pom</packaging>
13+
14+
<name>Plexus Compiler It Tests</name>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.codehaus.plexus</groupId>
19+
<artifactId>plexus-compiler-javac-errorprone</artifactId>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.codehaus.plexus</groupId>
23+
<artifactId>plexus-compiler-javac</artifactId>
24+
</dependency>
25+
</dependencies>
26+
<build>
27+
<plugins>
28+
<plugin>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-invoker-plugin</artifactId>
31+
<version>3.2.1</version>
32+
<executions>
33+
<execution>
34+
<id>integration-tests</id>
35+
<phase>verify</phase>
36+
<goals>
37+
<goal>install</goal>
38+
<goal>run</goal>
39+
<goal>verify</goal>
40+
</goals>
41+
<configuration>
42+
<debug>true</debug>
43+
<projectsDirectory>src/main/it</projectsDirectory>
44+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
45+
<postBuildHookScript>verify</postBuildHookScript>
46+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
47+
<settingsFile>src/main/it/settings.xml</settingsFile>
48+
<goals>
49+
<goal>clean</goal>
50+
<goal>test-compile</goal>
51+
</goals>
52+
</configuration>
53+
</execution>
54+
</executions>
55+
</plugin>
56+
</plugins>
57+
</build>
58+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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.java.version = 1.8+
19+
invoker.goals = clean test-compile
20+
invoker.buildResult = failure
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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.apache.maven.plugins.compiler.it</groupId>
27+
<artifactId>error-prone-compiler</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
30+
<name>Test for default configuration</name>
31+
32+
<properties>
33+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
<javac.version>9+181-r4173-1</javac.version>
35+
</properties>
36+
37+
<dependencies>
38+
<dependency>
39+
<groupId>junit</groupId>
40+
<artifactId>junit</artifactId>
41+
<version>3.8.2</version>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-compiler-plugin</artifactId>
50+
<version>3.8.1</version>
51+
<configuration>
52+
<target>8</target>
53+
<source>8</source>
54+
<compilerArgs>
55+
<arg>-XDcompilePolicy=simple</arg>
56+
<arg>-Xplugin:ErrorProne</arg>
57+
</compilerArgs>
58+
<annotationProcessorPaths>
59+
<path>
60+
<groupId>com.google.errorprone</groupId>
61+
<artifactId>error_prone_core</artifactId>
62+
<version>2.4.0</version>
63+
</path>
64+
</annotationProcessorPaths>
65+
</configuration>
66+
</plugin>
67+
</plugins>
68+
</build>
69+
<profiles>
70+
<profile>
71+
<id>jdk8</id>
72+
<activation>
73+
<jdk>1.8</jdk>
74+
</activation>
75+
<build>
76+
<plugins>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-compiler-plugin</artifactId>
80+
<configuration>
81+
<fork>true</fork>
82+
<compilerArgs combine.children="append">
83+
<arg>-J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${javac.version}/javac-${javac.version}.jar</arg>
84+
</compilerArgs>
85+
</configuration>
86+
</plugin>
87+
</plugins>
88+
</build>
89+
</profile>
90+
</profiles>
91+
</project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 MyClass
21+
{
22+
23+
public static void main(String[] args) {
24+
// error: dead exception
25+
// BUG: Diagnostic contains: throw new RuntimeException
26+
new RuntimeException("Not thrown, and reference lost");
27+
}
28+
29+
}
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 junit.framework.TestCase;
21+
22+
import java.util.*;
23+
24+
public class MyTest
25+
extends TestCase
26+
{
27+
// InfiniteRecursion
28+
int oops() {
29+
return oops();
30+
}
31+
32+
}
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+
def logFile = new File( basedir, 'build.log' )
20+
assert logFile.exists()
21+
content = logFile.text
22+
23+
assert content.contains( 'Compilation failure' )
24+
assert content.contains( '[DeadException] Exception created but not thrown' )
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<settings>
23+
<profiles>
24+
<profile>
25+
<id>it-repo</id>
26+
<activation>
27+
<activeByDefault>true</activeByDefault>
28+
</activation>
29+
<repositories>
30+
<repository>
31+
<id>local.central</id>
32+
<url>@localRepositoryUrl@</url>
33+
<releases>
34+
<enabled>true</enabled>
35+
</releases>
36+
<snapshots>
37+
<enabled>true</enabled>
38+
</snapshots>
39+
</repository>
40+
</repositories>
41+
<pluginRepositories>
42+
<pluginRepository>
43+
<id>local.central</id>
44+
<url>@localRepositoryUrl@</url>
45+
<releases>
46+
<enabled>true</enabled>
47+
</releases>
48+
<snapshots>
49+
<enabled>true</enabled>
50+
</snapshots>
51+
</pluginRepository>
52+
</pluginRepositories>
53+
</profile>
54+
</profiles>
55+
</settings>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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.java.version = 1.8+
19+
invoker.goals = clean test-compile
20+
#invoker.buildResult = failure

0 commit comments

Comments
 (0)