saeg / jaguar2

🐆
Eclipse Public License 1.0
3 stars 1 forks source link

Maven PMD Plugin >= 3.14.0 can't execute on JDK 6 toolchain #76

Closed andrioli closed 7 months ago

andrioli commented 11 months ago

Build failing after upgrade Maven PMD Plugin to version 3.14.0

(this is not a integration problem when using Jaguar 2 and Maven PMD Plugin, it's a problem to building Jaguar 2)

See PR #64 commit 7e5c36e and 4688afa

On version 3.14.0 and afterwards, Maven PMD Plugin add support for toolchains. Version 3.14.0 uses PMD version 6.29, that target Java 7, so it can't be executed on JDK 6 toolchain.

See: https://maven.apache.org/plugins/maven-pmd-plugin/examples/upgrading-PMD-at-runtime.html See: https://github.com/pmd/pmd/blob/pmd_releases/6.29.0/pom.xml#L81

On version 3.15.0, the plugin is targeting Java 8, but the PMD version in use (6.38.0) is still targeting Java 7.

See: https://github.com/apache/maven-pmd-plugin/blob/maven-pmd-plugin-3.15.0/pom.xml#L91 See: https://issues.apache.org/jira/browse/MPMD-316

The same for the latest plugin version (3.21.2). The plugin targets Java 8 but the PMD version in use (6.55.0) targets Java 7.

See: https://github.com/apache/maven-pmd-plugin/blob/maven-pmd-plugin-3.21.2/pom.xml#L85 See: https://github.com/pmd/pmd/blob/pmd_releases/6.55.0/pom.xml#L86

In any case, we can't upgrade the plugin when using JDK 6 toolchain!

andrioli commented 7 months ago

On https://github.com/saeg/jaguar2/commit/4688afa86234f35983a4c29817c874325ef727ee I proposed 3 solutions.

Three options occur to me:

  1. Ignore PMD when running with toolchain for JDK 6

Probably doesn't hurt as we still execute PMD on GitHub Actions CI for other Java versions.

  1. Use plugin version 3.14.0 but downgrade PMD

See: https://maven.apache.org/plugins/maven-pmd-plugin/examples/upgrading-PMD-at-runtime.html

No success, the plugin is not compatible with older PMD versions.

  1. Use the latest version that does not have toolchain support

This was my choice, the plugin is now on version 3.13.0.

We discarded option 2 and sticked with option 3. But now occurs to me other two possibly solution:

Instead of Ignore PMD when building with JDK 6 toolchain (as in option 1), we can stick on version 3.13.0 when building with JDK 6, use version 3.14.0 when building with JDK 7 toolchain and use the latest version when building with JDK >= 8.

Another solution is to use a different toolchain only for PMD.

See: https://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html#jdkToolchain

But in my option it will make the build much more complicated! So I will try the "multiple versions" solution!

andrioli commented 7 months ago

Instead of Ignore PMD when building with JDK 6 toolchain (as in option 1), we can stick on version 3.13.0 when building with JDK 6, use version 3.14.0 when building with JDK 7 toolchain and use the latest version when building with JDK >= 8.

Actually, since the minimum Java to start the build is version 8, the latest plugin version (3.21.2) will work for all JDK versions we build. We just need to pay attention to the PMD version. On the latest plugin version the PMD version in use (6.55.0) targets Java 7. So we just need to change the configuration when using JDK 6 toolchain.

andrioli commented 7 months ago

Actually, since the minimum Java to start the build is version 8, the latest plugin version (3.21.2) will work for all JDK versions we build. We just need to pay attention to the PMD version. On the latest plugin version the PMD version in use (6.55.0) targets Java 7. So we just need to change the configuration when using JDK 6 toolchain.

This is not true: See PR #93 commit beaa2c9