Skip to content

Commit

Permalink
Move tool versions to Version Catalog
Browse files Browse the repository at this point in the history
- fix: make version catalog accessible from `buildSrc` plugins
- chore: declare `googleFormatVersion` in version catalog
- chore: declare `ktfmt` in version catalog

Relates-To: #204
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon authored and holzensp committed Feb 21, 2024
1 parent 21e0e14 commit ca31185
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@file:Suppress("HttpUrlsUsage")

import org.gradle.accessors.dm.LibrariesForLibs

plugins {
`java-library`
id("pklKotlinTest")
Expand All @@ -9,6 +11,9 @@ plugins {
// make sources Jar available to other subprojects
val sourcesJarConfiguration = configurations.register("sourcesJar")

// Version Catalog library symbols.
val libs = the<LibrariesForLibs>()

java {
withSourcesJar() // creates `sourcesJar` task
withJavadocJar()
Expand All @@ -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"))
}
Expand Down
7 changes: 6 additions & 1 deletion buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.accessors.dm.LibrariesForLibs

plugins {
id("pklJavaLibrary")

Expand All @@ -6,6 +8,9 @@ plugins {

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

// Version Catalog library symbols.
val libs = the<LibrariesForLibs>()

dependencies {
// At least some of our kotlin APIs contain Kotlin stdlib types
// that aren't compiled away by kotlinc (e.g., `kotlin.Function`).
Expand All @@ -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"))
}
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit ca31185

Please sign in to comment.