We have a multi-repo setup with every repo containing multiple projects. Cross repo dependencies do exist which are defined using includeBuild("../repoB") in settings.gradle.
Now we are able to build every repo separately by going inside the repo and running gradle build. We would also like to be able to do a full build of all repositories.
The first thing you do wrong is, that you use gradle, you should always use the Gradle wrapper.
But that is unrelated to your question.
When you do gradle build (or ./gradlew build), then the build task of all projects in the given build that have such a task is executed.
But this logic does only work within one build.
In your composite build root, repoA and repoB are separate builds and to those this logic does not apply, as it does not cross build boundaries.
If you know each included build has a build task, you could for example do something like this in the root project’s build script:
But be aware that this would only depend on the build task in the root project of those builds, like when doing ./gradlew :build instead of ./gradlew build within repoA or repoB.
I added your snipped in root/build.gradle and get following error:
Could not find method build() for arguments [build_7kfwdttl4bo3clu8pg62oi22v$_run_closure1@7de51ae3] on task set of type org.gradle.api.internal.tasks.DefaultTaskContainer
gradle :build in both repositories this works more or less:
Ah, yeah, if the build script is otherwise empty, no build task exists.
This task is added by the lifecycle-base plugin.
You can of course create the task yourself, or you just apply the lifecycle-base plugin.
Btw. I highly recommend you switch to Kotlin DSL.
By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and an amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.
Now I get following error. Maybe we should (if we still easily can) switch to kotlin.
> No signature of method: com.google.common.collect.SingletonImmutableList.map() is applicable for argument types: (build_7kfwdttl4bo3clu8pg62oi22v$_run_closure1$_closure2) values: [build_7kfwdttl4bo3clu8pg62oi22v$_run_closure1$_closure2@35f8d824]
Possible solutions: max(), max(groovy.lang.Closure), max(java.util.Comparator), tap(groovy.lang.Closure), pop(), min()
Yeah, that’s indeed because what I sent is Kotlin DSL but you try to use it in Groovy DSL.
Replace map with collect which is the Groovy equivalent of map in Kotlin, then it should probably also work with Groovy DSL.
But yes, switching to Kotlin DSL imho is a good idea.
Btw. base != lifecycle-base.
It also works with that, as base sits on top of lifecycle-base and so applies it.
But it does more than you need in this case, so lifecycle-base would be enough, but you can also use base, doesn’t matter too much.