Gradle -b alternate-build.gradle: how does it work?


With an multi module configuration, I am trying to use an alternate-build.gradle script with the -b command line option, but it fails to pickup all the scripts from the submodules.

How does the option -b work?

For example, using a copy of a working build.gradle script, one got:

C:\Users\fandre\Documents\git\poco-1.9.1>gradle\bin\gradle -b wix

> Configure project :
C:\Users\fandre\Documents\git\poco-1.9.1\bin;interface org.gradle.model.Path
task coverage: covered modules

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':pocoDoc'.
> Task with path ':PocoDoc::assemble' not found in root project 'poco-1.9.1'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at

The -b alternate-build.gradle option implies that you want a single project build using alternate-build.gradle as the build file. When you have a multi-project build, use the -c option to provide an alternate settings.gradle file that configures an alternate build.gradle for the specific projects you care to alter. This could be every project, just the root project, or any combination. The -b option isn’t sophisticated enough to determine the intention here in a multi-project build.

Thank for the tip but I did not succeed in adding the specific build.script in my customized file. Could you just drop me a sample?

Which condition do you need a sample for?

If you’re just trying to use an alternate root project build.gradle file, add the following to an alternate-settings.gradle:

rootProject.buildFileName = 'alternate-build.gradle'

Run as:

./gradlew -c alternate-settings.gradle build
1 Like

Thank for the sample. I was using = ‘alternate-build.gradle’