Skip to content

Commit

Permalink
Daemon Toolchains: remove vendor restriction (gradle#32116)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacomet authored Feb 7, 2025
2 parents 87ce472 + b2f24c7 commit ca03714
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import gradlebuild.commons.configureJavaToolChain

/*
* Copyright 2020 the original author or authors.
*
Expand All @@ -25,8 +23,6 @@ plugins {
id("gradlebuild.private-javadoc")
}

java.configureJavaToolChain()

dependencies {
api(platform("gradlebuild:build-platform"))
implementation("gradlebuild:gradle-plugin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import gradlebuild.commons.configureJavaToolChain
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -26,8 +25,6 @@ plugins {
id("gradlebuild.private-javadoc")
}

java.configureJavaToolChain()

dependencies {
api(platform("gradlebuild:build-platform"))
implementation("gradlebuild:gradle-plugin")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import gradlebuild.commons.configureJavaToolChain

plugins {
`java-library`
groovy
Expand All @@ -15,7 +13,6 @@ plugins {
description = "A plugin that sets up a Java code that is shared between build-logic and runtime"

java {
configureJavaToolChain()
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import gradlebuild.commons.configureJavaToolChain
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
Expand All @@ -17,7 +16,6 @@ plugins {
description = "A plugin that sets up a Kotlin DSL code that is shared between build-logic and runtime"

java {
configureJavaToolChain()
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions build-logic-commons/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,3 @@ include("gradle-plugin")
include("publishing")

rootProject.name = "build-logic-commons"

// Make sure all the build-logic is compiled for the right Java version
gradle.lifecycle.beforeProject {
pluginManager.withPlugin("java-base") {
the<JavaPluginExtension>().toolchain {
// if you change this java version please also consider changing .idea/misc.xml#project/component(@project-jdk-name}
// Also, there are a lot of other places this should be changed.
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.ADOPTIUM
}
}
}
7 changes: 0 additions & 7 deletions build-logic-settings/build-environment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,3 @@ plugins {
description = "Provides plugins for configuring build environment"

group = "gradlebuild"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.ADOPTIUM
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,3 @@ plugins {
description = "Provides plugins for Configuration Cache usage adjustments"

group = "gradlebuild"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.ADOPTIUM
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import java.net.URI

tasks.named<UpdateDaemonJvm>("updateDaemonJvm") {
jvmVersion = JavaLanguageVersion.of(17)
jvmVendor = "adoptium"
}

tasks.withType<UpdateReleasedVersions>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ val gradlebuildJava = extensions.create<UnitTestAndCompileExtension>("gradlebuil
usesJdkInternals.convention(false)
}

// Use the Java 17 compiler, when possible, to perform compilation.
// This does not mean we target Java 17 bytecode. The target bytecode
// is controlled by the `gradlebuildJava.targetVersion` property.
configureDefaultToolchain(17)
enforceCompatibility(gradlebuildJava)

removeTeamcityTempProperty()
Expand All @@ -110,22 +106,6 @@ fun configureCompileDefaults() {
}
}

/**
* When possible, use a Java compiler with the given version when
* performing compilation. This does not necessarily mean we are
* emitting bytecode for the given version.
* <p>
* In some cases, the toolchain used here may be overridden, for
* example when compiling Groovy code, as it does not support
* the --release flag, or when targeting much older bytecode versions.
*/
fun configureDefaultToolchain(toolchainVersion: Int) {
java.toolchain {
languageVersion = JavaLanguageVersion.of(toolchainVersion)
vendor = JvmVendorSpec.ADOPTIUM
}
}

/**
* Given the user-configured values in the extension, configure the compilation tasks
* to enforce compatibility with the target JVM version.
Expand Down Expand Up @@ -186,7 +166,6 @@ fun enforceJavaCompatibility(targetVersion: Provider<Int>, useRelease: Provider<
provider { JavaLanguageVersion.of(11) }
}
}
vendor = JvmVendorSpec.ADOPTIUM
}
}

Expand Down Expand Up @@ -369,7 +348,9 @@ fun Test.configureJvmForTest() {
jvmArgumentProviders.add(CiEnvironmentProvider(this))
val launcher = project.javaToolchains.launcherFor {
languageVersion = jvmVersionForTest()
vendor = project.testJavaVendor.orElse(JvmVendorSpec.ADOPTIUM)
if (project.testJavaVendor.isPresent) {
vendor = project.testJavaVendor
}
}
javaLauncher = launcher
if (jvmVersionForTest().canCompileOrRun(9)) {
Expand Down
1 change: 0 additions & 1 deletion gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#This file is generated by updateDaemonJvm
toolchainVendor=adoptium
toolchainVersion=17

0 comments on commit ca03714

Please sign in to comment.