What is the difference between project(':projectName') {} and $projectRoot/projectName/build.gradle

Solution 1:

Gradle offers flexibility here. Some teams prefer to maintain only one build script in the root folder (e.g. the Spring project maintains the whole Gradle build in one build.gradle file). Some others like to split things up and add subproject specific settings into a subproject specific build file.

To make things even more complex, you can mix both options. You can have a subproject Gradle file and additionally to that, make further configurations to this subproject in the root project.

Cheers,
René