Subproject inclusion in build scripts named something other than 'build.gradle'


(Kirk) #1

Gradle 1.7

I have a project in which I would like to have more than one gradle build file, but have them all share the settings.gradle file.

settings.gradle contains a bunch of include ‘subproject’ lines that name the subproject, but for which there is no sub-directory in the project layout. Also, I’ve put in a print statement to indicate whether the settings.gradle file is being processed.

All build files access the subprojects in a

subprojects

block that applies the base plugin and then defines tasks.

This works fine for the ‘build.gradle’ script which uses the subproject name to choose files to operate on.

gradle -b build.gradle projects
===
You have accessed the settings file. ===
:projects
  ------------------------------------------------------------
Root project
------------------------------------------------------------
  Root project 'my-project'
+--- Project ':SubA'
+--- Project ':SubB'
  etc
  To see a list of the tasks of a project, run gradle <project-path>:tasks
For example, try running gradle :SubA:tasks
  BUILD SUCCESSFUL

Now in any other build file, say “process.gradle” I would expect those subprojects to exist, but they don’t:

gradle -b process.gradle projects

or

gradle -b process.gradle -c settings.gradle projects
gradle -b process.gradle projects
===
You have accessed the settings file. ===
:projects
  ------------------------------------------------------------
Root project
------------------------------------------------------------
  Root project 'my-project'
No sub-projects
  To see a list of the tasks of a project, run gradle <project-path>:tasks
For example, try running gradle :tasks
  BUILD SUCCESSFUL

The settings file is being accessed, so I’m confused by this behavior. Is there a trick to making a build file with a non-standard name respect the subproject includes? (or is buildfile naming not the issue?)


(Peter Niederwieser) #2

‘-b’ turns the build into a single-project build. In multi-project builds, build scripts are determined based on ‘settings.gradle’.