Neat feature, but I am trying to give members of my team full freedom on using this feature at all, and if so, be free to put their library project whenever they want on their local machine.
Is it possible to configure the composite build outside of the project, like in the local user gradle.properties file?
You can specify any path you like from the command-line, like --include-build ../some/path. Thatâs fine for one off/temporary situations.
You can specify a path that you look at, by convention, e.g., youâll include all builds that are checked out into $HOME/checkedOutProjects. This could potentially be something thatâs configurable per-person.
Lastly, you could also externalize the list of included builds into a file that you check for, e.g. $HOME/my-included-builds.txt could contain the fully qualified paths to all included builds. In that case, you could read the file in settings.gradle and call includedBuild for each.
As an aside, I think your example might be referring to the build.gradle? Either way, you should avoid the use of new File(...) because it will always be relative to the current working directory of the daemon which may not be your project directory. You should use file() if you need a File-like thing instead. includeBuild already does this in settings.gradle, so you can just pass the file path (includedBuild '../library').
You also donât want to litter your build.gradle with checks for included builds. If you want to have a build task that depends on all of the other included builds build tasks, you can just do build.dependsOn gradle.includedBuilds*.task(":build"). If there arenât any included builds, you wonât depend on anything (this returns an empty list).
The doc also suggests that includeBuild checks the existence of the build to include, but when trying includeBuild('../library') only without checking the existence of the folder myself I get the following error:
Error:Included build â/Users/myuser/gradle/libraryâ does not exist.
This check is quite important because we donât want to have to use composite builds on the CI Server, and that is the whole point of the feature, right?
I am a little surprised in settings.gradle includeBuild does not check itself if the folder exists, that we all have to wrap it in a file() check. Is there a plan to add this check in includeBuild and silently fail on error?