How to use alternate build.gradle with subprojects

I have a top-level project and a set of subprojects. I am trying to create a “build.gradle” that will just build all the subprojects. I tried creating a build.gradle with a different name (say build_subprojects.gradle) and then using the “-b” option, but that didn’t work. Any suggestions?

One suggestion I found by trawling the old forums is to specify the different buildScript name from within settings.gradle, but I couldn’t figure out how to do that.

You shouldn’t need a different build.gradle to do this. You just need another task. e.g.:

task buildSubprojects {
   group = 'build'
   description = 'Builds _only_ the subprojects'
   dependsOn subprojects.collect { it.path + ":build" }
}

Oh, and hi Wes.

Sterling!

I should have been more specific. I want to build the subprojects offline, so I was trying to build an “offline” version of build.gradle that doesn’t try to download gradle plugins or otherwise need to access the network. I was hoping to not have to refactor our build.gradle to work online/offline depending on a property, if that’s even possible.

Actually, modifying build.gradle to support both modes of operation (offline and online) based on a property was straightforward, and overall a much better solution.

If it’s possible, I’m still curious how to use the “-b” flag (or specify an alternate build.gradle file from within settings.gradle) when there are subprojects.