From 0b9e3ec609f196ebe44ea1a9c6eb6c55f907921f Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Tue, 20 Feb 2024 10:24:19 -0800 Subject: [PATCH] Move tool versions to Version Catalog - fix: make version catalog accessible from `buildSrc` plugins - chore: declare `googleFormatVersion` in version catalog - chore: declare `ktfmt` in version catalog Relates-To: apple/pkl#204 Signed-off-by: Sam Gammon --- buildSrc/build.gradle.kts | 4 ++++ buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts | 7 ++++++- buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts | 7 ++++++- gradle/libs.versions.toml | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 73eb36728..6c61d5079 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -9,6 +9,10 @@ dependencies { exclude(module = "kotlin-android-extensions") } implementation(libs.shadowPlugin) + + // fix from the Gradle team: makes version catalog symbols available in build scripts + // see here for more: https://github.com/gradle/gradle/issues/15383 + implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) } java { diff --git a/buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts b/buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts index a33ec9331..720eb746f 100644 --- a/buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts +++ b/buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts @@ -1,5 +1,7 @@ @file:Suppress("HttpUrlsUsage") +import org.gradle.accessors.dm.LibrariesForLibs + plugins { `java-library` id("pklKotlinTest") @@ -9,6 +11,9 @@ plugins { // make sources Jar available to other subprojects val sourcesJarConfiguration = configurations.register("sourcesJar") +// Version Catalog library symbols. +val libs = the() + java { withSourcesJar() // creates `sourcesJar` task withJavadocJar() @@ -21,7 +26,7 @@ artifacts { spotless { java { - googleJavaFormat("1.15.0") + googleJavaFormat(libs.versions.googleJavaFormat.get()) targetExclude("**/generated/**", "**/build/**") licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.star-block.txt")) } diff --git a/buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts b/buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts index 72a829cff..cbc728365 100644 --- a/buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts +++ b/buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts @@ -1,3 +1,5 @@ +import org.gradle.accessors.dm.LibrariesForLibs + plugins { id("pklJavaLibrary") @@ -6,6 +8,9 @@ plugins { val buildInfo = project.extensions.getByType() +// Version Catalog library symbols. +val libs = the() + dependencies { // At least some of our kotlin APIs contain Kotlin stdlib types // that aren't compiled away by kotlinc (e.g., `kotlin.Function`). @@ -21,7 +26,7 @@ tasks.compileKotlin { spotless { kotlin { - ktfmt("0.44").googleStyle() + ktfmt(libs.versions.ktfmt.get()).googleStyle() targetExclude("**/generated/**", "**/build/**") licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.star-block.txt")) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fd80c52ed..ec99df8e0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ clikt = "3.5.1" commonMark = "0.+" downloadTaskPlugin = "4.1.2" geantyref = "1.+" +googleJavaFormat = "1.15.0" # must not use `+` because used in download URL graalVm = "22.3.3" # intentionally empty; replaced by patch file when building pkl-cli macos/aarch64 @@ -30,6 +31,7 @@ kotlin = "1.7.10" kotlinPoet = "1.6.+" kotlinxHtml = "0.+" kotlinxSerialization = "1.+" +ktfmt = "0.44" # replaces nuValidator's log4j dependency # something related to log4j-1.2-api is apparently broken in 2.17.2 log4j = "2.17.1"