Slackbot
12/12/2023, 1:56 PMVampire
12/12/2023, 2:12 PMsubprojects { ... } in the root project to cross-configure the subprojects, but that is discouraged bad practice.
You should use convention plugins for example in buildSrc or an included build for example implemented as precompiled script plugin to centralize build logic and and apply those in the projects where you want their effect to be present.Vampire
12/12/2023, 2:15 PMAdam
12/12/2023, 2:15 PMsubprojects {} and allprojects{}?
The modern Gradle way is to use 'convention plugins', which is basically equivalent to moving the `allprojects {}`/`subprojects{}` configuration into custom plugins, which can be applied to each subproject on demand. This is a big improvement, because the config can be refined and only applied to subprojects as required.
It's possible to keep using `subprojects {}`/`allprojects {}`, so it really depends on how deep you want to (or are able to!) dive into GradleAdam
12/12/2023, 2:16 PMFrank
12/12/2023, 2:21 PMsubprojects { ... } is considered bad practice but have tried it just to make it work but it isn't - at least for me. Also, I'm not using allprojects {}.
I am seeing some rather strange "behaviour" and it could be based on my current folder structure (one that has been successfully working in 6.8) but wanted to quickly as if using the buildSrc project is the way to share configurations (assuming no plugins for now) or can I avoid that and just use a setting.gradle and build.gradle in the root and then build.gradle in the subproject (as we're currently doing it in 6.8)?Vampire
12/12/2023, 2:28 PMFrank
12/12/2023, 2:29 PMrootProject.name = 'isg-core-platform'
include 'shared:serialization:csv'
build.gradle
subprojects {
apply plugin: "application"
println(project.name + ":" + System.getenv("GRADLE_USER_HOME"))
repositories {
mavenCentral()
...
build output:
> Configure project :
shared:null
serialization:null
csv:null
As you can see it sees the nested folders as projects too - I don't recall this with our previous build. I also see this in my IDE:Vampire
12/12/2023, 2:31 PMAdam
12/12/2023, 2:33 PMinclude 'shared:serialization:csv' actually adds shared and shared/serialization and shared/serialization/csv as subprojects, and so the subprojects {} block is going to add the application plugin to each directoryVampire
12/12/2023, 2:35 PMFrank
12/12/2023, 2:36 PMdependencies {
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-csv")
}
Output:Frank
12/12/2023, 2:37 PMVampire
12/12/2023, 2:38 PMLOL...my expectation is that only "csv" would show up as the project as the nesting; shared and serialization aren't projects. Perhaps my expectations are incorrect but I also don't see this behaviour in our current project - but I will review to be sure.Then just do
include("csv") and then set the project dir to the path to the project. But as I said, this was always like that.
it seems as though the configuration for the subprojects is functioning as I expect it because when I add a dependency to the subproject it fails as it can't see the repositoryThe problem is probably more that you do not have a version for the dependency
Frank
12/12/2023, 2:41 PMFrank
12/12/2023, 3:24 PMFrank
12/12/2023, 4:39 PMVampire
12/12/2023, 11:36 PMFrank
12/13/2023, 1:25 PM