-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: polish build scripts, use Java 17 for the build, target Java 11
Previously, TestNG was build with the "current Java" version which was not very reproducible. Now the build script would use Java 17 for building the code no matter which Java is selected for launching Gradle. Even though the code is always build with Java 17, the tests execute with a configurable Java version. It enables executing tests with EA Java versions.
- Loading branch information
Showing
19 changed files
with
226 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build/ | ||
/*/build/ |
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,27 @@ | ||
import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "org.testng.build-logic" | ||
|
||
dependencies { | ||
// We use precompiled script plugins (== plugins written as src/kotlin/build-logic.*.gradle.kts files, | ||
// and we need to declare dependency on org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin | ||
// to make it work. | ||
// See https://github.com/gradle/gradle/issues/17016 regarding expectedKotlinDslPluginsVersion | ||
implementation("org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:$expectedKotlinDslPluginsVersion") | ||
} | ||
|
||
// We need to figure out a version that is supported by the current JVM, and by the Kotlin Gradle plugin | ||
// So we settle on 17 or 11 if the current JVM supports it | ||
listOf(17, 11) | ||
.firstOrNull { JavaVersion.toVersion(it) <= JavaVersion.current() } | ||
?.let { buildScriptJvmTarget -> | ||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(buildScriptJvmTarget)) | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...gic-commons/gradle-plugin/src/main/kotlin/build-logic.kotlin-dsl-gradle-plugin.gradle.kts
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,21 @@ | ||
plugins { | ||
id("java-library") | ||
id("org.gradle.kotlin.kotlin-dsl") // this is 'kotlin-dsl' without version | ||
} | ||
|
||
tasks.validatePlugins { | ||
failOnWarning.set(true) | ||
enableStricterValidation.set(true) | ||
} | ||
|
||
// We need to figure out a version that is supported by the current JVM, and by the Kotlin Gradle plugin | ||
// So we settle on 17 or 11 if the current JVM supports it | ||
listOf(17, 11) | ||
.firstOrNull { JavaVersion.toVersion(it) <= JavaVersion.current() } | ||
?.let { buildScriptJvmTarget -> | ||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(buildScriptJvmTarget)) | ||
} | ||
} | ||
} |
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,9 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic-commons" | ||
|
||
include("gradle-plugin") |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
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,20 @@ | ||
import buildparameters.BuildParametersExtension | ||
import org.gradle.api.JavaVersion | ||
|
||
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.buildJdkVersion: Int | ||
get() = buildJdk?.version ?: JavaVersion.current().majorVersion.toInt() | ||
|
||
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,24 @@ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
plugins { | ||
id("org.gradlex.build-parameters") version "1.4.3" | ||
id("com.github.vlsi.gradle-extensions") version "1.90" | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
buildParameters { | ||
// Other plugins can contribute parameters, so below list is not exhaustive | ||
enableValidation.set(false) | ||
pluginId("build-logic.build-params") | ||
bool("enableMavenLocal") { | ||
defaultValue.set(true) | ||
description.set("Add mavenLocal() to repositories") | ||
} | ||
integer("targetJavaVersion") { | ||
defaultValue.set(11) | ||
mandatory.set(true) | ||
description.set("Java version for source and target compatibility") | ||
} | ||
integer("jdkBuildVersion") { | ||
defaultValue.set(17) | ||
mandatory.set(true) | ||
description.set("JDK version to use for building JMeter. If the value is 0, then the current Java is used. (see https://docs.gradle.org/8.0/userguide/toolchains.html#sec:consuming)") | ||
} | ||
string("jdkBuildVendor") { | ||
description.set("JDK vendor to use building JMeter (see https://docs.gradle.org/8.0/userguide/toolchains.html#sec:vendors)") | ||
} | ||
string("jdkBuildImplementation") { | ||
description.set("Vendor-specific virtual machine implementation to use building JMeter (see https://docs.gradle.org/8.0/userguide/toolchains.html#selecting_toolchains_by_virtual_machine_implementation)") | ||
} | ||
integer("jdkTestVersion") { | ||
description.set("JDK version to use for testing JMeter. If the value is 0, then the current Java is used. (see https://docs.gradle.org/8.0/userguide/toolchains.html#sec:consuming)") | ||
} | ||
string("jdkTestVendor") { | ||
description.set("JDK vendor to use testing JMeter (see https://docs.gradle.org/8.0/userguide/toolchains.html#sec:vendors)") | ||
} | ||
string("jdkTestImplementation") { | ||
description.set("Vendor-specific virtual machine implementation to use testing JMeter (see https://docs.gradle.org/8.0/userguide/toolchains.html#selecting_toolchains_by_virtual_machine_implementation)") | ||
} | ||
bool("sonarqube") { | ||
defaultValue.set(false) | ||
description.set("Report verification results to Sonarqube") | ||
} | ||
bool("skipAutostyle") { | ||
defaultValue.set(false) | ||
description.set("Skip AutoStyle verifications") | ||
} | ||
bool("failOnJavadocWarning") { | ||
defaultValue.set(true) | ||
description.set("Fail build on javadoc warnings") | ||
} | ||
} |
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,3 @@ | ||
plugins { | ||
`embedded-kotlin` apply false | ||
} |
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 |
---|---|---|
@@ -1,20 +1,10 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation("org.sonarqube:org.sonarqube.gradle.plugin:4.4.1.3373") | ||
implementation("com.github.autostyle:autostyle-plugin-gradle:4.0") | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = "11" | ||
} | ||
api(projects.buildParameters) | ||
api(projects.basics) | ||
api("org.sonarqube:org.sonarqube.gradle.plugin:4.4.1.3373") | ||
api("com.github.autostyle:autostyle-plugin-gradle:4.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":basics")) | ||
implementation(project(":code-quality")) | ||
implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.90") | ||
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.6.21") | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = "11" | ||
} | ||
api(projects.buildParameters) | ||
api(projects.basics) | ||
api(projects.codeQuality) | ||
api("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.90") | ||
api("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.6.21") | ||
} |
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 |
---|---|---|
@@ -1,22 +1,10 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":jvm")) | ||
implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.90") | ||
implementation("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:8.1.1") | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin") | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = "11" | ||
} | ||
api(projects.jvm) | ||
api("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.90") | ||
api("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:8.1.1") | ||
api("org.jetbrains.kotlin:kotlin-gradle-plugin") | ||
} |
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