Skip to content

Commit 193c037

Browse files
committed
[MPMD-379] Add IT for Java 21
1 parent 73b4010 commit 193c037

File tree

6 files changed

+208
-3
lines changed

6 files changed

+208
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
20+
# available toolchains under linux:
21+
# https://github.com/apache/infrastructure-p6/blob/production/modules/build_nodes/files/toolchains.xml
22+
23+
# the jdk toolchain "21:openjdk" is selected in pom.xml
24+
invoker.toolchain.jdk.version = 21
25+
invoker.toolchain.jdk.vendor = openjdk
26+
27+
invoker.goals = clean verify
28+
invoker.buildResult = failure

src/it/MPMD-379-JDK21/pom.xml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
<project xmlns="http://maven.apache.org/POM/4.0.0" 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+
<groupId>org.apache.maven.plugins.pmd.it</groupId>
26+
<artifactId>MPMD-379-JDK21</artifactId>
27+
<version>1.0-SNAPSHOT</version>
28+
29+
<properties>
30+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
31+
<javaVersion>21</javaVersion>
32+
</properties>
33+
34+
<build>
35+
<pluginManagement>
36+
<plugins>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-compiler-plugin</artifactId>
40+
<version>@compilerPluginVersion@</version>
41+
<configuration>
42+
<target>${javaVersion}</target>
43+
<source>${javaVersion}</source>
44+
</configuration>
45+
</plugin>
46+
</plugins>
47+
</pluginManagement>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-pmd-plugin</artifactId>
52+
<version>@project.version@</version>
53+
<configuration>
54+
<linkXRef>false</linkXRef>
55+
<skipPmdError>false</skipPmdError>
56+
<skip>false</skip>
57+
<failOnViolation>true</failOnViolation>
58+
<failurePriority>4</failurePriority>
59+
<printFailingErrors>true</printFailingErrors>
60+
<targetJdk>${javaVersion}</targetJdk>
61+
<minimumTokens>100</minimumTokens>
62+
</configuration>
63+
<executions>
64+
<execution>
65+
<id>default</id>
66+
<phase>verify</phase>
67+
<goals>
68+
<goal>check</goal>
69+
</goals>
70+
</execution>
71+
</executions>
72+
</plugin>
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-toolchains-plugin</artifactId>
76+
<version>3.1.0</version>
77+
<executions>
78+
<execution>
79+
<goals>
80+
<goal>toolchain</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
<configuration>
85+
<toolchains>
86+
<jdk>
87+
<version>${javaVersion}</version>
88+
<vendor>openjdk</vendor>
89+
</jdk>
90+
</toolchains>
91+
</configuration>
92+
</plugin>
93+
</plugins>
94+
</build>
95+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.mycompany.app;
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+
public class App
23+
{
24+
25+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.mycompany.app;
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+
import java.util.ArrayList;
23+
24+
public class Foo
25+
{
26+
public Foo( final ArrayList<String> foo )
27+
{
28+
}
29+
30+
}

src/it/MPMD-379-JDK21/verify.groovy

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
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+
File buildLog = new File( basedir, 'build.log' )
22+
assert buildLog.exists()
23+
assert buildLog.text.contains( '[INFO] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )
24+
assert !buildLog.text.contains( '[WARNING] PMD' )

src/main/java/org/apache/maven/plugins/pmd/PmdReport.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,19 @@
6363
@Mojo(name = "pmd", threadSafe = true, requiresDependencyResolution = ResolutionScope.TEST)
6464
public class PmdReport extends AbstractPmdReport {
6565
/**
66-
* The target JDK to analyze based on. Should match the source used in the compiler plugin. Valid values
67-
* with the default PMD version are
66+
* The target JDK to analyze based on. Should match the source used in the compiler plugin.
67+
* Valid values depend on the used PMD version. With the default PMD version valid values are
6868
* currently <code>1.3</code>, <code>1.4</code>, <code>1.5</code>, <code>1.6</code>, <code>1.7</code>,
6969
* <code>1.8</code>, <code>9</code>, <code>10</code>, <code>11</code>, <code>12</code>, <code>13</code>,
7070
* <code>14</code>, <code>15</code>, <code>16</code>, <code>17</code>, <code>18</code>, <code>19</code>,
71-
* and <code>20</code>.
71+
* <code>20</code>, <code>21</code>, and <code>22</code>.
7272
*
7373
* <p> You can override the default PMD version by specifying PMD as a dependency,
7474
* see <a href="examples/upgrading-PMD-at-runtime.html">Upgrading PMD at Runtime</a>.</p>
7575
*
76+
* <p> To see the supported Java versions for each PMD version, see
77+
* <a href="https://docs.pmd-code.org/latest/pmd_languages_java.html">Java support (PMD)</a>.</p>
78+
*
7679
* <p>
7780
* <b>Note:</b> this parameter is only used if the language parameter is set to <code>java</code>.
7881
* </p>

0 commit comments

Comments
 (0)