From 4095b978799962492936d8a4ccea023950cf7241 Mon Sep 17 00:00:00 2001 From: Jared Burrows Date: Tue, 30 Jul 2024 12:48:58 -0400 Subject: [PATCH] build.gradle -> build.gradle.kts (#887) --- build.gradle | 82 ------------------------------------------ build.gradle.kts | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 82 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 6b3c7e08..00000000 --- a/build.gradle +++ /dev/null @@ -1,82 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile - -plugins { - alias(libs.plugins.kotlin.jvm) - alias(libs.plugins.dokka) apply false - alias(libs.plugins.ktlint) apply false - alias(libs.plugins.plugin.publish) apply false - alias(libs.plugins.versions) - id 'java-gradle-plugin' - id 'java-library' - id 'groovy' -} - -allprojects { - configurations.configureEach { - resolutionStrategy { - preferProjectModules() - - enableDependencyVerification() - } - } -} - -subprojects { - tasks.withType(Jar).configureEach { - manifest { - attributes( - 'Implementation-Title': POM_NAME, - 'Implementation-Version': VERSION_NAME, - 'Built-By': System.getProperty('user.name'), - 'Built-JDK': System.getProperty('java.version'), - 'Built-Gradle': gradle.gradleVersion) - } - } - - tasks.withType(KotlinJvmCompile).configureEach { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - } - } - - tasks.withType(JavaCompile).configureEach { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - - configure(options) { - compilerArgs << '-Xlint:all' - compilerArgs << '-Xlint:-options' - encoding = 'utf-8' - fork = true - } - } - - tasks.withType(GroovyCompile).configureEach { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - - configure(options) { - compilerArgs << '-Xlint:all' - compilerArgs << '-Xlint:-options' - encoding = 'utf-8' - fork = true - } - } - - tasks.withType(Test).configureEach { - useJUnitPlatform() - - testLogging { - exceptionFormat 'full' - showCauses true - showExceptions true - showStackTraces true - showStandardStreams true - events 'passed', 'failed', 'skipped' - } - - def maxWorkerCount = gradle.startParameter.maxWorkerCount - maxParallelForks = (maxWorkerCount < 2) ? 1 : maxWorkerCount / 2 - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..80fe1fe1 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,92 @@ +import org.gradle.api.JavaVersion.VERSION_1_8 +import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL +import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED +import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED +import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED +import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile + +plugins { + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.dokka) apply false + alias(libs.plugins.ktlint) + alias(libs.plugins.plugin.publish) apply false + alias(libs.plugins.versions) + `java-gradle-plugin` + `java-library` + groovy +} + +allprojects { + configurations.configureEach { + resolutionStrategy { + preferProjectModules() + + enableDependencyVerification() + } + } +} + +subprojects { + tasks.withType().configureEach { + manifest { + attributes( + "Implementation-Title" to properties["POM_NAME"], + "Implementation-Version" to properties["VERSION_NAME"], + "Built-By" to System.getProperty("user.name"), + "Built-JDK" to System.getProperty("java.version"), + "Built-Gradle" to gradle.gradleVersion, + ) + } + } + + tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JVM_1_8) + } + } + + tasks.withType().configureEach { + sourceCompatibility = VERSION_1_8.toString() + targetCompatibility = VERSION_1_8.toString() + + options.apply { + compilerArgs = compilerArgs + + listOf( + "-Xlint:all", + "-Xlint:-processing", + ) + encoding = "utf-8" + isFork = true + } + } + + tasks.withType().configureEach { + sourceCompatibility = VERSION_1_8.toString() + targetCompatibility = VERSION_1_8.toString() + + options.apply { + compilerArgs = compilerArgs + + listOf( + "-Xlint:all", + "-Xlint:-processing", + ) + encoding = "utf-8" + isFork = true + } + } + + tasks.withType().configureEach { + testLogging { + exceptionFormat = FULL + showCauses = true + showExceptions = true + showStackTraces = true + showStandardStreams = true + events = setOf(PASSED, FAILED, SKIPPED) + } + + val maxWorkerCount = gradle.startParameter.maxWorkerCount + maxParallelForks = if (maxWorkerCount < 2) 1 else maxWorkerCount / 2 + } +}