Hi, I am trying to find a useful reusable multiproject structure, using buildSrc, conventions and platform subprojects.
What I have now is:
root
|--- buildSrc/
|--- build-conventions/
| |--- src/main/groovy/
| | |--- Catalog.groovy # interface Libraries {static guava = 'com.google.guava:guava:31.0.1-jre'}
| | |--- example-convention.gradle # dependencies { implementation Libraries.guava }
| | |--- dummy-convention.gradle # // empty file
|--- platform/
| |--- build.gradle
|--- example/
| |--- build.gradle # plugins { id("example-convention") }
|--- settings.gradle # includeBuild("build-conventions")
I wanted to use constants defined in Catalog.groovy within the platform project to define constraints.
The only way I could get that to work in platform/build.gradle is:
plugins {
id "java-platform"
id("empty-convention") // only using this, I can use Libraries.guava from Catalog.groovy
}
dependencies {
constraints {
api Libraries.guava
}
}
I am not sure whether I am using well-defined behavior or a loophole.
But even this does not allow using the Catalog.groovy constants within buildSrc. If I move it to buildSrc, then the convention project do not see the constants defined in Catalog.groovy.
Is there any cleaner way in gradle 7 to provide build constants such as in the Catalog.groovy to all of: subproject, platform subprojects, convention plugins, buildSrc?
Or should I stop using buildSrc altogether when using composite builds?
Where would incubating Catalog strict dependencies be visible within the project graph?