Upgrading Application to Java 21 and Maven PMD Plugin Incompatibility

146 views Asked by At

I'm encountering an issue while upgrading my application to Java 21. The existing Maven PMD Plugin (version 3.19.0) seems incompatible with Java 21.

Here's a breakdown of the problem:

Upgrade Requirement: My application needs to be upgraded to use Java 21.

PMD Plugin Issue: During the mvn clean install command, I receive an error message: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.19.0:pmd (pmd) on project domain: Execution pmd of goal org.apache.maven.plugins:maven-pmd-plugin:3.19.0:pmd failed: org.apache.maven.reporting.MavenReportException: Unsupported targetJdk value '21'.

Lack of Java 21 Support: According to the Maven PMD Plugin documentation (https://maven.apache.org/plugins/maven-pmd-plugin/examples/targetJdk.html), supported versions only go up to Java 20. Java 21 compatibility is not explicitly listed.

Could you please advise on how to proceed with the upgrade given this PMD plugin limitation? Any suggestions or workarounds would be greatly appreciated.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.19.0</version>
                <executions>
                    <execution>
                        <id>pmd</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>pmd</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>pmd-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>cpd</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>cpd</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>cpd-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>cpd-check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <targetJdk>21</targetJdk>
                    <printFailingErrors>true</printFailingErrors>
                    <minimumTokens>40</minimumTokens>
                    <minimumPriority>0</minimumPriority>
                    <linkXRef>false</linkXRef>
                    <rulesets>
                        <ruleset>${pmd.ruleset.relative.path}</ruleset>
                    </rulesets>
                    <excludeRoots>
                        <excludeRoot>target/generated-sources</excludeRoot>
                    </excludeRoots>
                </configuration>
            </plugin>
0

There are 0 answers