-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Gradle toolchain support #262
Open
StefMa
wants to merge
7
commits into
apple:main
Choose a base branch
from
StefMa:gradle-toolchain
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+54
−38
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ff11f54
Add Gradle toolchain support
StefMa 0371c2f
Move toolchain version and vendor to single place and make them confi…
StefMa 2921b89
Update development.adoc
StefMa cffa8e0
Fix CI job
StefMa 5b2e95b
Update CI config
StefMa 8338c17
Remove unnecessary conversion
StefMa ad5df18
Set javaLauncher for JavaExec tasks
StefMa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,19 +17,19 @@ extends "GradleJob.pkl" | |
|
||
import "package://pkg.pkl-lang.org/pkl-pantry/[email protected]#/Config.pkl" | ||
|
||
javaVersion: "11.0"|"17.0" | ||
javaVersion: "11"|"17" | ||
|
||
steps { | ||
new Config.RunStep { | ||
name = "gradle check" | ||
command = "./gradlew \(module.gradleArgs) check" | ||
command = "./gradlew \(module.gradleArgs) check -DPKL_JVM_VERSION=\(javaVersion)" | ||
} | ||
} | ||
|
||
job { | ||
docker { | ||
new { | ||
image = "cimg/openjdk:\(javaVersion)" | ||
image = "cimg/openjdk:11.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.jvm.toolchain.JvmVendorSpec | ||
|
||
private const val JDK_VERSION = 11 | ||
|
||
val jvmToolchainVersion: JavaLanguageVersion | ||
get() { | ||
val jvmVersion = System.getProperty("PKL_JVM_VERSION")?.toInt() ?: JDK_VERSION | ||
return JavaLanguageVersion.of(jvmVersion) | ||
} | ||
|
||
val jvmToolchainVendor: JvmVendorSpec | ||
get() = JvmVendorSpec.ADOPTIUM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,11 @@ tasks.compileKotlin { | |
enabled = true // disabled by pklJavaLibrary | ||
} | ||
|
||
kotlin.jvmToolchain { | ||
languageVersion.set(jvmToolchainVersion) | ||
vendor.set(jvmToolchainVendor) | ||
} | ||
Comment on lines
+27
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be necessary because this plugin applies |
||
|
||
spotless { | ||
kotlin { | ||
ktfmt(libs.versions.ktfmt.get()).googleStyle() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would it make sense to configure the global toolchain here as well, for consistency, via the
java { toolchain { } }
block.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
build.gradle.kts
is only responsible for the code withinbuildSrc
, right?Since we are using Kotlin only here, why should we set the
java.toolchain {}
? 🤔Or what do you mean by that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are correct that this build script is responsible for
buildSrc
.In Gradle, the
java
plugin is always applied to JVM-based projects, even if the project uses some other language as the core of its implementation. Therefore, for consistency, it is considered idiomatic to use thejava
plugin methods to configure something first, and use language-specific methods to adjust the configuration, if necessary.In the toolchain case, it is specified explicitly in Kotlin docs (see here) that the toolchain version in the
java
block will be used by Kotlin compilation tasks, therefore, it would be conventional to use thejava
block to set it up.(BTW, it's curious that the docs state that setting the toolchain in the
kotlin
extension will also configure it forJavaCompile
tasks; this is another reason to set it in thejava
block, since it is the built-in way to configure the toolchain, and their effects would be similar anyway)