I’m using gradle 8.13, and I want to achieve a setup like this (version catalog module hasn’t been added yet, but I use the versions from gradle/libs.versions.toml
in the convention plugin:
- Build repo with these modules, each published separately:
- Build-logic with convention plugins
- Version catalog with a single publication that publishes the catalog from
gradle/libs.versions.toml
- Codegen (gradle build file with codegen config for spring boot)
- Shared libraries monorepo, observability, datasource, etc.
- Service repositories, one per microservice
The challenge is with the build-repo.
The convention plugins are plain build.gradle.kts files that aggregate some build config for all other repos.
I want to share the version catalog among all repos, such that the build repo uses it, and publishes it, and the the convention plugins use that as well.
So far this works for the conventions plugins
I put this is the build.gradle.kts in the root of the convention plugins module:
dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
Then I use it in the convention plugin this way:
val libs = the<LibrariesForLibs>()
dependencies {
implementation(platform(libs.kotlinBom))
}
However, when I try to use the generated plugin in a service repo like this :
plugins {
id("company.kt-spring-conventions") version "0.2.0-SNAPSHOT"
}
I get this error:
> Failed to apply plugin 'company.kt-conventions'.
> Type org.gradle.accessors.dm.LibrariesForLibs not present
I’d like to avoid duplication version declarations, so my question is what is the recommended way to achieve this?
I thought about trying to first publish the version-catalog, and when I have an artifact I’d import that in the conventions, but I’m still unsure regarding how the consuming project would “see” it.
The only documentation I find is about monorepos when there is a buildSrc
folder where conventions go, and has a version catalog usage samples, but I can’t find anything about the use-case I described.
Thanks.