Robert Elliot
03/21/2025, 1:43 PMsettings.gradle.kts
, but now I'm worrying that Gradle won't know that a change to gradle/libs.versions.toml
invalidates the plugins section of settings.gradle.kts
. Is this a terrible idea?
plugins {
id("com.autonomousapps.build-health") version "2.13.0"
val kotlinVersion = rootDir.resolve("gradle/libs.versions.toml")
.readLines()
.dropWhile { !it.matches("""^\h*\[\h*versions\h*\]\h*$""".toRegex()) }
.drop(1)
.takeWhile { !it.matches("""^\h*\[""".toRegex()) }
.firstNotNullOf {
"""^\h*kotlin\h*=\h*"(?<version>[^"]*)"\h*$""".toRegex()
.matchEntire(it)?.groups?.get("version")?.value
}
// Kotlin must be loaded in the same (or parent) class loader as the
// Dependency Analysis Plugin. The lines below are one way to accomplish this
id("org.jetbrains.kotlin.jvm") version kotlinVersion apply false
}
Philip W
03/21/2025, 1:46 PMPhilip W
03/21/2025, 1:48 PMRobert Elliot
03/21/2025, 1:58 PMcom.autonomousapps.build-health
because it won't load the kotlin classes in the correct classloader, which is the reason why I'm loading the org.jetbrains.kotlin.jvm
plugin in the settings.gradle.kts
plugins
block.Robert Elliot
03/21/2025, 2:00 PMPhilip W
03/21/2025, 2:01 PMRobert Elliot
03/21/2025, 2:13 PMcom.autonomousapps.build-health
plugin in individual subprojects build
rather than as a settings plugin?
I'm pretty hazy as to the difference between settings plugins and build plugins but I think they're different, and the com.autonomousapps.build-health
plugin documentation says it should be applied as a settings plugin:
https://github.com/autonomousapps/dependency-analysis-gradle-plugin/wiki/Adding-to-your-project#via-the-build-health-settings-pluginPhilip W
03/21/2025, 2:14 PMRobert Elliot
03/21/2025, 2:19 PMPhilip W
03/21/2025, 2:19 PM