Basic Gradle Commands

Logging options in Gradle

–quite (or -q)Log errors only.
–debug (or -d)This option provides
a lot of output with information about the steps and classes used to run the
–warn(or -w)Set log level to warn.Less verbose that debug
–info (or -i)To get a better insight into the steps that are executed for our task
–stacktrace (or -s)Print out the stacktrace for all exceptions.
(or -S)
Print out the full (very verbose) stacktrace for all exceptions.
gradle -q task
gradle -i task
gradle -d task
gradle -qs task
gradle -is task
gradle -ds task
gradle -qS task
gradle -iS task
gradle -dS task

Help in gradle

gradle -q help 

Find details about task in gradle

gradle -q help --task <task_name>

List of tasks in gradle

gralde -q tasks

List of properties in Gradle

gradle -q properties

Running tasks without actually executing them (dry run)

With the help of –dry-run option or (-m) we can actually run the task without actually executing them, Gradle builds up a DAG(Direct Acyclic Graph) with all the task needed to be executed in that build

gradle --dry-run build
gradle -m build

Gradle Demon

Check status of Gradle Demon

gradle --status  //Status of Demon

Disabling Demon in gradle via properties file


Kill Gradle demon

gradle --stop

Check dependency of a gradle java jar

gradle dependencies
gradle dependencyInsight --configuration compile --dependency <name>
gradle dependencyInsight --configuration testCompile --dependency <name>

If you find it hard to navigate console output then you can apply a gradle plugin and get the report in html file.

apply plugin: 'project-report'

Generate report using below command :

/gradlew htmlDependencyReport

Source and target java version

apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8

Leave a Comment