Skip to content

Dynamically select Gradle based on Java version

Adam Cohen requested to merge select-gradle-for-java-version into master

What does this MR do?

While working on adding support for Java 17 and Gradle 7, I noticed that the Gradle Java compatibility chart shows that different versions of Java require different versions of Gradle.

This MR improves the logic for switching the gradle version in analyzer-wrapper so that in addition to supporting Java 17, we also support dynamically switching the Gradle version for Java 13, 14, 15 and 16.

See this discussion for more details.

Testing

None of the following test projects contain a gradlew file, so the version of gradle is not pinned, and is dynamically selected based on the DS_JAVA_VERSION value:

  • Java 14:

    Using java version 'adoptopenjdk-14.0.1+7.1'
    Using gradle version '6.7.1'
  • Java 16

    Using java version 'adoptopenjdk-16.0.0+36'
    Using gradle version '7.3.3'
  • Java 17

    Using java version 'adoptopenjdk-17.0.2+8'
    Using gradle version '7.3.3'

What are the relevant issue numbers?

gitlab-org/gitlab#341170 (closed)

Does this MR meet the acceptance criteria?

Edited by Adam Cohen

Merge request reports