34
votes

I have searched on Gradle docs and on the stackoverflow and some other places but I can't find information about what is bundled in this task in depth, or I missed it, if so please point me to the direction.

  • It comes from java-base plugin, right?
  • Running gradle -q tasks doesn't say much about it.

build - Assembles and tests this project.

  • Running gradle help --task build shows detailed info, ok - but it show where the task is used, in which groups is included, type of a task, and paths.

  • I have tried to track manually what does comes with it, and noticed, compile, test etc tasks.

I would like to know what exactly comes from Gradle build task, what are the task dependencies.

4

4 Answers

23
votes

You can use the Gradle Task Tree Plugin to see the task dependencies

eg:

plugins {
    id "com.dorongold.task-tree" version "1.3.1"
}

Then run

gradle build taskTree

Output

:build
+--- :assemble
|    \--- :jar
|         \--- :classes
|              +--- :compileJava
|              \--- :processResources
\--- :check
     \--- :test
          +--- :classes
          |    +--- :compileJava
          |    \--- :processResources
          \--- :testClasses
               +--- :compileTestJava
               |    \--- :classes
               |         +--- :compileJava
               |         \--- :processResources
               \--- :processTestResources
18
votes

From the Gradle Java plugin docs

build dependencies

It's dependencies are the check & assemble task which you can see have their own dependencies

11
votes

Starting with version 4.0 you have to run gradle build --console=plain to see the complete list of task dependencies.

If you use java-base plugin then the dependencies are:

$ gradle build --console=plain
:assemble
:check
:build

enter image description here

If you use java (which automatically applies java-base) then the dependencies are:

$ gradle build --console=plain
:compileJava
:processResources
:classes
:jar
:assemble
:compileTestJava
:processTestResources
:testClasses
:test
:check
:build

enter image description here

In order to see the exact chain of dependencies shown in the pictures above I used a little Perl helper that can be run inside of a Gradle project. It produces a dot string describing dependency graph:

#/bin/perl
use strict;

my @deps;
my %tasks;

getDeps($ARGV[0]);
printDot();

sub getDeps {
    my $task = shift;
    $tasks{$task} = "";
    chomp(my @subtasks = `gradle $task`);
    @subtasks = grep { $_ =~ "^:" } @subtasks;
    pop @subtasks;
    foreach(@subtasks) {
        my ($s) = $_ =~ "^:(.*) ";
        push @deps, "$task -> $s;";
        if(!defined $tasks{$s}) {getDeps($s)}
    }
}

sub printDot {
    my $dot = "digraph main {\n";
    if(@deps>1) {
        foreach(@deps) {$dot .= "$_\n"}
    } else {
        $dot .= "$ARGV[0];\n";
    }
    print $dot . "}";
}

Then run the following to turn the output into a PNG image:

$ t=build; perl dependencies.pl $t | tred | dot -T png > $t.png

or ASCII text:

$ t=build; perl dependencies.pl $t | tred | graph-easy > $t.txt
0
votes

gradlew build --dry-run

Starting a Gradle Daemon, 1 busy and 1 incompatible and 3 stopped Daemons could not be reused, use --status for details

:compileJava SKIPPED
:processResources SKIPPED
:classes SKIPPED
:bootWarMainClassName SKIPPED
:bootWar SKIPPED
:bootStartScripts SKIPPED
:bootDistTar SKIPPED
:bootDistZip SKIPPED
:jar SKIPPED
:startScripts SKIPPED
:distTar SKIPPED
:distZip SKIPPED
:war SKIPPED
:assemble SKIPPED
:compileTestJava SKIPPED
:processTestResources SKIPPED
:testClasses SKIPPED
:test SKIPPED
:check SKIPPED
:build SKIPPED

BUILD SUCCESSFUL in 32s