Skip to content

Commit

Permalink
Merge pull request #6 from petebankhead/toolchains
Browse files Browse the repository at this point in the history
Support toolchain gradle or system property
  • Loading branch information
petebankhead authored Dec 6, 2024
2 parents e686565 + ba091e1 commit d8e4b91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

base {
group = "io.github.qupath"
version = "0.2.0"
version = "0.2.1-SNAPSHOT"
description = "Gradle plugin for developing QuPath extensions"
}

Expand Down
23 changes: 22 additions & 1 deletion src/main/kotlin/qupath-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ tasks.register<Copy>("copyDependencies") {
* Ensure we include sources and javadocs when building.
*/
java {
val jdkVersion = findRequiredVersionInCatalog("jdk")
// Java typically added
var jdkVersion = findToolchainVersion()
if (!jdkVersion.isNullOrEmpty()) {
toolchain {
languageVersion = JavaLanguageVersion.of(jdkVersion)
Expand All @@ -118,6 +119,26 @@ java {
withJavadocJar()
}

/**
* Work out which Java version to use for the build
*/
fun findToolchainVersion(): String? {
// Try Gradle property
var toolchainVersion = providers.gradleProperty("toolchain").orNull
if (!toolchainVersion.isNullOrEmpty()) {
println("Using toolchain version $toolchainVersion from gradle property")
return toolchainVersion
}
// Try System property
toolchainVersion = System.getProperty("toolchain")
if (!toolchainVersion.isNullOrEmpty()) {
println("Using toolchain version $toolchainVersion from system property")
return toolchainVersion
}
// Default to version catalog
return findRequiredVersionInCatalog("jdk")
}

/*
* Set the JavaFX version if we can find it in a version catalog,
* and include the 'standard' modules required by QuPath.
Expand Down

0 comments on commit d8e4b91

Please sign in to comment.