Skip to content
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

Use Gradle toolchains to build ORT with a consistent Java version #8411

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions buildSrc/src/main/kotlin/ort-kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
private val Project.libs: LibrariesForLibs
get() = extensions.getByType()

val javaLanguageVersion: String by project

plugins {
// Apply core plugins.
jacoco
Expand Down Expand Up @@ -105,8 +107,13 @@ detekt {
basePath = rootDir.path
}

val javaVersion = JavaVersion.current()
val maxKotlinJvmTarget = runCatching { JvmTarget.fromTarget(javaVersion.majorVersion) }
java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaLanguageVersion)
}
}

val maxKotlinJvmTarget = runCatching { JvmTarget.fromTarget(javaLanguageVersion) }
.getOrDefault(enumValues<JvmTarget>().max())

val mergeDetektReportsTaskName = "mergeDetektReports"
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ org.gradle.parallel = true

kotlin.code.style = official

# The version of the JDK to use for building ORT.
javaLanguageVersion = 11
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I'd be fine with giving this another / shorter name. Maybe just buildJdk?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either name, but add javaToolchainVersion to the candidates.


# The version of the SPDX license list which is used to import license texts and generate SPDX enums. Must be a valid
# tag, see https://github.com/spdx/license-list-data/tags.
spdxLicenseListVersion = 3.23