Gradle cheat sheet

dependency graph

gradle :someChildProject:dependencies

dependency insights

./gradlew :someChildProject:dependencyInsight --dependency com.beust --configuration runtimeClasspath

Java plugin project conventions

Directory Meaning
src/main/java Production Java source
src/main/resources Production resources
src/test/java Test Java source
src/test/resources Test resources
src/sourceSet/java Java source for the given source set
src/sourceSet/resources Resources for the given source set


Gradle In Action, by Benjamin Muschko

  • Highly recommend Appendix B: “Groovy for Gradle users”

Build phases

initialization, configuration, execution (p. 80, 4.2.7)

Build phase Responsibility File executed Instance being configured
may configure listeners or delayed project configuration

init scripts Gradle
initialization instantiate the project’s hierarchy

(tell the system which projects are participating)

(p. 140, 6.2.3)

settings.gradle Settings
configuration construct a model of the tasks that will take part in the build, determine which need to be run build.gradle Project
execution execute the tasks

Gradle DSL


Plugins receive a type parameter for which type they are applied to. (Project, Settings, Gradle)