John Svensson
08/01/2025, 3:04 PMLibrariesForLibs
. Will post in thread to not clutter the main channel.John Svensson
08/01/2025, 3:07 PMkotlin-conventions
plugin that all sub projects will use, and one quarkus-conventions
that a few of them will use in addition. One of the things I have put in the kotlin-conventions
plugin is Detekt.
However, when testing with some dummy code, Gradle warned me that the task detektMain
must depend on the task compileQuarkusGeneratedSourcesJava
. That task is of course in the quarkus-conventions
plugin, so my first thought was to apply the kotlin-conventions
plugin inside of the quarkus-conventions
plugin to get a hold of the Detekt
task type. But since I like the type-safe accessors that the "`LibrariesForLibs` work-around" provides, I use that in both conventions plugins, which then gives me the error "Extension of type 'LibrariesForLibs' does not exist"
when I try to apply the kotlin-conventions
plugin inside of the quarkus-conventions
plugin...
Is there a way to solve this, so that the LibrariesForLibs
extension gets "carried over" from one convention plugin to the other to make this work? Or maybe this whole approach is suboptimal and I should structure these conventions in another way? 😉
The most relevant files pasted below, and further down a zipped MCVE.John Svensson
08/01/2025, 3:08 PM./gradle/build-logic/kotlin-conventions/src/main/kotlin/kotlin-conventions.gradle.kts
import org.gradle.accessors.dm.LibrariesForLibs
plugins {
kotlin("jvm")
id("io.gitlab.arturbosch.detekt")
}
val libs = the<LibrariesForLibs>()
dependencies {
implementation(libs.kotlin.logging)
}
kotlin {
jvmToolchain(21)
}
detekt {
buildUponDefaultConfig = true
}
John Svensson
08/01/2025, 3:09 PM./gradle/build-logic/kotlin-conventions/build.gradle.kts
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
}
dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.kotlin.gradle.plugin)
implementation(libs.detekt.gradle.plugin)
}
Vampire
08/01/2025, 3:10 PMVampire
08/01/2025, 3:11 PMdependsOn
where on the left-hand side is not a lifecycle task, you are most probably doing something wrong, and the suggested solutions by the Gradle finding are usually the wrong thing to do but only symptom treatment like calling Platform.runLater
to "fix" a GUI problem.Vampire
08/01/2025, 3:12 PMVampire
08/01/2025, 3:12 PMVampire
08/01/2025, 3:13 PMsrcDir
which makes its outputs be treated as source files, automatically getting necessary task dependencies implicitly.John Svensson
08/01/2025, 3:18 PMVampire
08/01/2025, 3:28 PMVampire
08/01/2025, 3:32 PMdependsOn
and mustRunAfter
instead of properly wiring things together, resulting in that issue. 🤷