Cosindering using Gradle Java toolchain to avoid Java 11 check #78

Open
opened 2025-12-30 01:20:27 +01:00 by adam · 7 comments
Owner

Originally created by @StefMa on GitHub (Feb 18, 2024).

When you add gradle Java toolchain to this project it literally doesn't matter which jvm version users (potential contributors) are using to build the project. As long as it can run gradle, the toolchain will make sure that the correct jvm version will be downloaded and used to build the project.

See https://docs.gradle.org/current/userguide/toolchains.html

There is no need for the "is Java 11 check" in the settings.gradle anymore. Additionally, also CI would use that exact same jdk version.

Idea is coming from https://github.com/apple/pkl/issues/181

Originally created by @StefMa on GitHub (Feb 18, 2024). When you add gradle Java toolchain to this project it literally doesn't matter which jvm version users (potential contributors) are using to build the project. As long as it can run gradle, the toolchain will make sure that the correct jvm version will be downloaded and used to build the project. See https://docs.gradle.org/current/userguide/toolchains.html There is no need for the "is Java 11 check" in the settings.gradle anymore. Additionally, also CI would use that exact same jdk version. Idea is coming from https://github.com/apple/pkl/issues/181
Author
Owner

@stackoverflow commented on GitHub (Feb 19, 2024):

This seems like a good idea. Feel free to contribute a PR if you so wish.

@stackoverflow commented on GitHub (Feb 19, 2024): This seems like a good idea. Feel free to contribute a PR if you so wish.
Author
Owner

@holzensp commented on GitHub (Feb 19, 2024):

I thought it wasn't extended to Kotlin toolchains yet in Gradle 7 (and we're still pending the bump to >=8.6)

@holzensp commented on GitHub (Feb 19, 2024): I thought it wasn't extended to Kotlin toolchains yet in Gradle 7 (and we're still pending the bump to >=8.6)
Author
Owner

@StefMa commented on GitHub (Feb 20, 2024):

Kotlin toolchain support is available since 1.5.30. Gradle introduced the base of this feature in 6.7 or maybe 7.0 (to stable).

So I guess we are fine here.

I will try it out and report back 👍

@StefMa commented on GitHub (Feb 20, 2024): Kotlin toolchain support is available [since 1.5.30](https://blog.jetbrains.com/kotlin/2021/11/gradle-jvm-toolchain-support-in-the-kotlin-plugin/). Gradle introduced the base of this feature in 6.7 or maybe 7.0 (to stable). So I guess we are fine here. I will try it out and report back 👍
Author
Owner

@StefMa commented on GitHub (Feb 21, 2024):

So I tested a bit:
The foojay-toolchain-plugin requires at least Gradle 7.6.
So we can't use it right know until #200 is fixed and merged.

Nevertheless, I update Gradle and made the required changes.
👉 https://pastebin.com/6kJu02YV

Suddently I get a lockfile issue running ./gradlew assemble.

> Task :pkl-gradle:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':pkl-gradle:compileJava'.
> Could not resolve all files for configuration ':pkl-gradle:compileClasspath'.
   > Did not resolve 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10' which is part of the dependency lock state
   > Did not resolve 'org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10' which is part of the dependency lock state
   > Did not resolve 'org.jetbrains:annotations:13.0' which is part of the dependency lock state
   > Did not resolve 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10' which is part of the dependency lock state
   > Did not resolve 'com.github.ajalt.clikt:clikt-jvm:3.5.1' which is part of the dependency lock state
   > Did not resolve 'com.github.ajalt.clikt:clikt:3.5.1' which is part of the dependency lock state
   > Did not resolve 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10' which is part of the dependency lock state

I don't know where this is coming from and how to fix it 😞 .

When running ./gradlew updateDependencyLocks I get a lot of changes

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   bench/gradle.lockfile
        modified:   docs/gradle.lockfile
        modified:   pkl-cli/gradle.lockfile
        modified:   pkl-codegen-java/gradle.lockfile
        modified:   pkl-codegen-kotlin/gradle.lockfile
        modified:   pkl-commons-cli/gradle.lockfile
        modified:   pkl-commons-test/gradle.lockfile
        modified:   pkl-commons/gradle.lockfile
        modified:   pkl-config-java/gradle.lockfile
        modified:   pkl-config-kotlin/gradle.lockfile
        modified:   pkl-core/gradle.lockfile
        modified:   pkl-doc/gradle.lockfile
        modified:   pkl-executor/gradle.lockfile
        modified:   pkl-gradle/gradle.lockfile
        modified:   pkl-server/gradle.lockfile
        modified:   pkl-tools/gradle.lockfile
        modified:   stdlib/gradle.lockfile

However, afterwards I get another issue 😅

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':pkl-tools:shadowJar'.
> Could not resolve all dependencies for configuration ':pkl-tools:runtimeClasspath'.
   > Resolved 'org.jetbrains.kotlin:kotlin-stdlib-common:1.9.22' which is not part of the dependency lock state
@StefMa commented on GitHub (Feb 21, 2024): So I tested a bit: The [foojay-toolchain-plugin](https://github.com/gradle/foojay-toolchains/) requires at least Gradle 7.6. So we can't use it right know until #200 is fixed and merged. Nevertheless, I update Gradle and made the required changes. 👉 https://pastebin.com/6kJu02YV Suddently I get a lockfile issue running `./gradlew assemble`. ``` > Task :pkl-gradle:compileJava FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':pkl-gradle:compileJava'. > Could not resolve all files for configuration ':pkl-gradle:compileClasspath'. > Did not resolve 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10' which is part of the dependency lock state > Did not resolve 'org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10' which is part of the dependency lock state > Did not resolve 'org.jetbrains:annotations:13.0' which is part of the dependency lock state > Did not resolve 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10' which is part of the dependency lock state > Did not resolve 'com.github.ajalt.clikt:clikt-jvm:3.5.1' which is part of the dependency lock state > Did not resolve 'com.github.ajalt.clikt:clikt:3.5.1' which is part of the dependency lock state > Did not resolve 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10' which is part of the dependency lock state ``` I don't know where this is coming from and how to fix it 😞 . When running `./gradlew updateDependencyLocks` I get a lot of changes ❗ ``` Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: bench/gradle.lockfile modified: docs/gradle.lockfile modified: pkl-cli/gradle.lockfile modified: pkl-codegen-java/gradle.lockfile modified: pkl-codegen-kotlin/gradle.lockfile modified: pkl-commons-cli/gradle.lockfile modified: pkl-commons-test/gradle.lockfile modified: pkl-commons/gradle.lockfile modified: pkl-config-java/gradle.lockfile modified: pkl-config-kotlin/gradle.lockfile modified: pkl-core/gradle.lockfile modified: pkl-doc/gradle.lockfile modified: pkl-executor/gradle.lockfile modified: pkl-gradle/gradle.lockfile modified: pkl-server/gradle.lockfile modified: pkl-tools/gradle.lockfile modified: stdlib/gradle.lockfile ``` However, afterwards I get another issue 😅 ``` FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':pkl-tools:shadowJar'. > Could not resolve all dependencies for configuration ':pkl-tools:runtimeClasspath'. > Resolved 'org.jetbrains.kotlin:kotlin-stdlib-common:1.9.22' which is not part of the dependency lock state ```
Author
Owner

@holzensp commented on GitHub (Feb 21, 2024):

I forget about the Kotlin stdlib intricacies for shadowJar. @stackoverflow / @bioball, thoughts?

@holzensp commented on GitHub (Feb 21, 2024): I forget about the Kotlin stdlib intricacies for `shadowJar`. @stackoverflow / @bioball, thoughts?
Author
Owner

@StefMa commented on GitHub (Feb 27, 2024):

Could you explain this a bit more to me? 🤔
What is the issue Iam facing I don't get it...

@StefMa commented on GitHub (Feb 27, 2024): Could you explain this a bit more to me? 🤔 What is the issue Iam facing I don't get it...
Author
Owner

@stackoverflow commented on GitHub (Feb 27, 2024):

When you run ./gradlew updateDependencyLocks you update all dependencies, which is not what you want. You can use gradle classes --update-locks some:dependency to only update what you need. See here for more info: https://docs.gradle.org/current/userguide/dependency_locking.html#selectively_updating_lock_state_entries.

@stackoverflow commented on GitHub (Feb 27, 2024): When you run `./gradlew updateDependencyLocks` you update **all** dependencies, which is not what you want. You can use `gradle classes --update-locks some:dependency` to only update what you need. See here for more info: https://docs.gradle.org/current/userguide/dependency_locking.html#selectively_updating_lock_state_entries.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#78