forked from apache/jmeter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use Gradle toolchains for JDK provisioning
It enables automatic JDK provisioning (e.g. download), and it enables using different JDKs for executing Gradle and for building JMeter Java version can be specified when building with -PjdkVersion=11 You could use ./gradlew -q javaToolchains to list the detected toolchains. See https://docs.gradle.org/8.0/userguide/toolchains.html#sec:consuming Fixes apache#5986
- Loading branch information
Showing
18 changed files
with
265 additions
and
47 deletions.
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
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 |
---|---|---|
|
@@ -18,3 +18,7 @@ | |
plugins { | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
api(projects.buildParameters) | ||
} |
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,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import buildparameters.BuildParametersExtension | ||
|
||
class ToolchainProperties( | ||
val version: Int, | ||
val vendor: String?, | ||
val implementation: String?, | ||
) | ||
|
||
val BuildParametersExtension.buildJdk: ToolchainProperties? | ||
get() = jdkBuildVersion.takeIf { it != 0 } | ||
?.let { ToolchainProperties(it, jdkBuildVendor.orNull, jdkBuildImplementation.orNull) } | ||
|
||
val BuildParametersExtension.testJdk: ToolchainProperties? | ||
get() = jdkTestVersion.orNull?.takeIf { it != 0 } | ||
?.let { ToolchainProperties(it, jdkTestVendor.orNull, jdkTestImplementation.orNull) } | ||
?: buildJdk |
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,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import org.gradle.api.provider.Provider | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.jvm.toolchain.JavaLauncher | ||
import org.gradle.jvm.toolchain.JavaToolchainService | ||
import org.gradle.jvm.toolchain.JavaToolchainSpec | ||
import org.gradle.jvm.toolchain.JvmImplementation | ||
import org.gradle.jvm.toolchain.JvmVendorSpec | ||
|
||
fun JavaToolchainService.launcherFor(jdk: ToolchainProperties): Provider<JavaLauncher> = launcherFor { | ||
configureToolchain(jdk) | ||
} | ||
|
||
fun JavaToolchainSpec.configureToolchain(jdk: ToolchainProperties?) { | ||
if (jdk == null) { | ||
return | ||
} | ||
languageVersion.set(JavaLanguageVersion.of(jdk.version)) | ||
jdk.vendor?.let { | ||
vendor.set(JvmVendorSpec.matching(it)) | ||
} | ||
if (jdk.implementation.equals("J9", ignoreCase = true)) { | ||
implementation.set(JvmImplementation.J9) | ||
} | ||
} |
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
Oops, something went wrong.