I'm working on a pretty large project (140+ subprojects) and everything is build with gradle. Due to the amount of subprojects the configuration phase of the gradle build takes a while (30+ seconds). Gradle is not only used to build the projects but also to start external tools like a shell with correct environment, consul, ... These non-build tasks actually don't have any dependency to any other projects und thus could simply be executed without configuring all projects. These tasks also live in their own gradle files. For consul f.e. there is a consul-starter.gradle file in a gradle subdir of the root project. That is the structure looks like this:
root-project ├ gradle │ └ consul-starter.gradle ├ subproject 1 - N ├ gradlew ├ build.gradle └ settings.gradle
I want to execute the startConsul task in gradle/consul-starter.gradle without executing the configuration phase for all subprojects, to skip the 30 seconds config phase.
I tried to specify gradle/consul-starter.gradle as build file:
gradlew -b gradle/consul-starter.gradle startConsul
But gradle complains:
Build file '/path/to/root-project/gradle/consul-starter.gradle' is not part of the build defined by settings file '/path/to/root-project/settings.gradle'. If this is an unrelated build, it must have its own settings file.
I tried to specify an empty dummy settings file but got the same error (with the dummy file).
When I move the consul-starter.gradle from the gradle sub folder to the root-project folder execution of the task works and skips the complete configuration phase as desired, but I don't want to move the file to the root-project folder to keep things sorted.
Is there anything else I could do? I "simply" want the execute a task from a standalone gradle file...
Update 2020-04-06:
Indeed after putting an empty settings.gradle file next to the consul-starter.gradle solved the issue. I first tried to specify a settings file using gradle's --config command line switch. But for some reason this didn't work...