Odd behavior with command line parameters

I am seeing some odd behavior with the -c and -b command line options.

If I just specify -c then everything is fine
If I add a -b and a -c the settings file is ignored

I’m working on a large multi-project build and have two versions of the settings.gradle and build.gradle
This is so I can develop a plugin to simplify the build
The -c settings file is using the ProjectDescriptor.setBuildFilename to use alternate build files for the subprojects
The -b build file is the new logic in the root project for the plugins

Am I misunderstanding the -b options?
Is it only for single project builds with one build script and no settings file?

Yes, the -b option is really designed to reference one build script. With the -c option, you can specify the version of the settings.gradle file to configure your entire multi-project build with the appropriate build files.

You’re most of the way there with what you’re already doing, but you should set the appropriate file name for your root project build script (like you are for the subprojects) in each version of the settings.gradle file instead of specifying it with the -b option.

Although these are quite old now (2012), here’s a couple threads that support this intention of the -b option and some related information:

I tried using
rootProject.buildFile = 'buildNew.gradle’
but I get this error
Cannot set readonly property: buildFile for class: org.gradle.initialization.DefaultProjectDescriptor

This build has ~400 projects
The goal was to simplify the current one root script into a set of plugins and move code out of the subprojects
I thought I could just add the buildSrc folder and a new build.gradle and settings.gradle script as I migrate script code into a plugin.

My settings.gradle looks for files in the project with a prefix ‘PFS2_’ and end in gradle
The original build files start with 'PFS_'
This way I can have both version of the build in the same project tree.

I guess a new root project with the plugin code and the new build.gradle and settings.gradle is the solution.

You would need to use rootProject.buildFileName = 'buildNew.gradle' for this to work.

ProjectDescriptor has a getter/setter pair for buildFileName. You cannot directly set the value returned by the File getBuildFile() method because it is derived from both the project directory and the build file name, which is why you receive the error ‘Cannot set readonly property: buildFile’.