Emre Safak
06/11/2024, 9:50 PMbuild.gradle.kts using the version catalog? I just want to hoist out a plugin's configuration. I tried convention plugins but get unresolved references when I try to use libs or the plugin itself (jooq).
buildSrc/settings.gradle.kts
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
buildSrc/build.gradle.kts
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
repositories {
mavenCentral()
}
buildSrc/src/main/kotlin/jooq.gradle.kts
plugins {
alias(libs.plugin.jooq.codegen)
}
dependencies {
jooqCodegen(libs.jooq.meta.extensions)
jooqCodegen(libs.jooq.meta.kotlin)
}
jooq { [configs] }
I get Unresolved reference: libs for the last file.Adam
06/12/2024, 6:49 AMVampire
06/12/2024, 6:54 AMlibs...) for Kotlin DSL are not.
In Groovy DSL it just works.
In Kotlin DSL you can use the type-unsafe string-y API via versionCatalogs extension.
Or you can use my hack-around documented in the issue Adam linked to, to use the type-safe accessors.Emre Safak
06/12/2024, 6:49 PMplugins {
alias(libs.plugins.jooq.codegen)
}
dependencies {
jooqCodegen(libs.jooq.meta.extensions)
jooqCodegen(libs.jooq.meta.kotlin)
}
I get an unresolved reference, and if I remove this block, the actual jooq {} block that follows it fails. I note that the IDE complains about the libs inside the alias with
> 'val libs: LibrariesForLibs' can't be called in this context by implicit receiver. Use the explicit one if necessary.
I don't know why it's so hard to merely include a file 😐Vampire
06/12/2024, 7:10 PMVampire
06/12/2024, 7:11 PMEmre Safak
06/12/2024, 8:47 PMlibs variously with "org.jooq.jooq-codegen-gradle", "jooq-codegen-gradle", etc.
repositories {
mavenCentral()
}
plugins {
id("org.jooq.jooq-codegen-gradle") // version "3.19.9"
}
but I got
> Plugin [id: 'org.jooq.jooq-codegen-gradle'] was not found in any of the following sources:
>
> - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
> - Plugin Repositories (plugin dependency must include a version number for this source)
If I include the version number it fails with
Plugin requests from precompiled scripts must not include a version number. Please remove the version from the offending request and make sure the module containing the requested plugin 'org.jooq.jooq-codegen-gradle' is an implementation dependency of project ':gradle-configs'.
What is the right string argument to id()? This is the plugin on Maven.Vampire
06/12/2024, 9:56 PMEmre Safak
06/12/2024, 10:22 PMbuild.gradle.kts?
dependencies {
implementation("org.jooq:jooq-codegen-gradle:3.19.9")
}
This hard codes the version and yields this error:
Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class org.jooq.codegen.gradle.MetaExtensions.ConfigurationExtension, unresolved supertypes: org.jooq.meta.jaxb.Configuration
...
If I use implementation(libs.plugins.jooq.codegen) I get
Cannot convert the provided notation to an object of type Dependency: org.jooq.jooq-codegen-gradle:3.19.9Vampire
06/12/2024, 10:25 PMorg.jooq:jooq-codegen-gradle:... or via the marker artifact that is also used to translate plugin ID from plugins { ... } block to a dependency in normal build scripts org.jooq.jooq-codegen-gradle:org.jooq.jooq-codegen-gradle.gradle.plugin:...Emre Safak
06/12/2024, 10:32 PMimplementation("org.jooq:jooq-codegen-gradle:${libs.versions.jooq.get()}")
implementation("org.jooq:jooq-meta-extensions:${libs.versions.jooq.get()}")
which is not ideal. Gradle's DX here needs some improvement.Vampire
06/12/2024, 10:48 PMEmre Safak
06/12/2024, 10:49 PMimplementation(libs.plugins.jooq.codegen) with libs coming from the catalog. The latest incarnation uses the catalog too, but just for the version.Vampire
06/12/2024, 10:52 PMEmre Safak
06/12/2024, 10:55 PMimplementation("org.jooq:jooq-codegen-gradle:${libs.versions.jooq.get()}")Vampire
06/12/2024, 11:16 PMimplementation(libs.jooq.codegen.gradle), if you added a "normal library entry" to the version catalog for it, as opposed to a plugin entryEmre Safak
06/13/2024, 5:45 AMVampire
06/13/2024, 6:31 AM