Include(':app') vs include('app')

The title says it already: what is the difference between include with leading colon and without leading colon?


As long as we are talking about the leading colon, I don’t think there is any difference. There could some differences in some corner cases, but I have never encountered such a case yet.
Both the userguide and the javadoc do not use the leading colon.

I think there is a difference: without a leading colon every subproject is built in the root project’s build directory (possibly overwriting resources/files with the same name) whereas with the leading colon every subproject is built in its own build directory under the subproject’s directory. This at least what I have established empirically with gradle 5.3 (openjdk11) on win7ent.


I gave it a try with the same setup as yours, or as close as possible to yours.
Yet I witnessed no differences with or without leading colon. I suppose that there is something else in your builds that lead to files being overwritten.


include 'a', ':b'

build.gradle (rootProject’s one):

allProjects {
    apply plugin: 'java'

After creating src/main/resources/ in all projects:

C:\temp\test>gradle --version

Gradle 5.3

Build time:   2019-03-20 11:03:29 UTC
Revision:     f5c64796748a98efdbf6f99f44b6afe08492c2a0

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          11 (Oracle Corporation 11+28)
OS:           Windows 7 6.1 amd64

C:\temp\test>gradle assemble
Starting a Gradle Daemon (subsequent builds will be faster)

6 actionable tasks: 6 executed
C:\temp\test>type build\resources\main\
C:\temp\test>type a\build\resources\main\
subProject a
C:\temp\test>type b\build\resources\main\
subProject b