Skip to content

Commit 8508af3

Browse files
committed
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#204 Signed-off-by: Sam Gammon <[email protected]>
1 parent ffc629f commit 8508af3

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

buildSrc/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ dependencies {
99
exclude(module = "kotlin-android-extensions")
1010
}
1111
implementation(libs.shadowPlugin)
12+
13+
// fix from the Gradle team: makes version catalog symbols available in build scripts
14+
// see here for more: https://github.com/gradle/gradle/issues/15383
15+
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
1216
}
1317

1418
java {

buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@file:Suppress("HttpUrlsUsage")
22

3+
import org.gradle.accessors.dm.LibrariesForLibs
4+
35
plugins {
46
`java-library`
57
id("pklKotlinTest")
@@ -9,6 +11,9 @@ plugins {
911
// make sources Jar available to other subprojects
1012
val sourcesJarConfiguration = configurations.register("sourcesJar")
1113

14+
// Version Catalog library symbols.
15+
val libs = the<LibrariesForLibs>()
16+
1217
java {
1318
withSourcesJar() // creates `sourcesJar` task
1419
withJavadocJar()
@@ -21,7 +26,7 @@ artifacts {
2126

2227
spotless {
2328
java {
24-
googleJavaFormat("1.15.0")
29+
googleJavaFormat(libs.versions.googleJavaFormat.get())
2530
targetExclude("**/generated/**", "**/build/**")
2631
licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.star-block.txt"))
2732
}

buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.accessors.dm.LibrariesForLibs
2+
13
plugins {
24
id("pklJavaLibrary")
35

@@ -6,6 +8,9 @@ plugins {
68

79
val buildInfo = project.extensions.getByType<BuildInfo>()
810

11+
// Version Catalog library symbols.
12+
val libs = the<LibrariesForLibs>()
13+
914
dependencies {
1015
// At least some of our kotlin APIs contain Kotlin stdlib types
1116
// that aren't compiled away by kotlinc (e.g., `kotlin.Function`).
@@ -21,7 +26,7 @@ tasks.compileKotlin {
2126

2227
spotless {
2328
kotlin {
24-
ktfmt("0.44").googleStyle()
29+
ktfmt(libs.versions.ktfmt.get()).googleStyle()
2530
targetExclude("**/generated/**", "**/build/**")
2631
licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.star-block.txt"))
2732
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ clikt = "3.5.1"
77
commonMark = "0.+"
88
downloadTaskPlugin = "4.1.2"
99
geantyref = "1.+"
10+
googleJavaFormat = "1.15.0"
1011
# must not use `+` because used in download URL
1112
graalVm = "22.3.3"
1213
# intentionally empty; replaced by patch file when building pkl-cli macos/aarch64
@@ -30,6 +31,7 @@ kotlin = "1.7.10"
3031
kotlinPoet = "1.6.+"
3132
kotlinxHtml = "0.+"
3233
kotlinxSerialization = "1.+"
34+
ktfmt = "0.44"
3335
# replaces nuValidator's log4j dependency
3436
# something related to log4j-1.2-api is apparently broken in 2.17.2
3537
log4j = "2.17.1"

0 commit comments

Comments
 (0)