Root project name cannot be changed with custom build files

Using Gradle 2.3, setting rootProject.name in the settings.gradle only works when using the default build.gradle as build script. Using an alternate build script will always set the parent folder name as root project name.

To illustrate the issue, use the trivial example attached:
foo.zip (696 Bytes)

D:\foo>gradle -b build.gradle
rootProject.name is bar
[…]
BUILD SUCCESSFUL

Total time: 3.48 secs

and:

D:\foo>gradle -b other.gradle
rootProject.name is bar

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘D:\SVN\devops\extension-plugins\trunk - Copy\foo\other.gradle’ line: 1
  • What went wrong:
    A problem occurred evaluating root project ‘foo’.
    assert rootProject.name == ‘bar’
    | | |
    | foo false
    root project ‘foo’
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.12 secs

1 Like