Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does UP-TO-DATE in gradle indicate?

Tags:

gradle

I have recently started using gradle in a project and I am running the standard

gradle clean init build

I noticed that in many of the tasks that are running, I get this UP-TO-DATE message in the console, next to the current task that's running. eg:-

:foo:bar:test UP-TO-DATE

I am curious as to what does this message mean. Couldn't find any documentation around the same.

like image 769
Ankit Dhingra Avatar asked Feb 28 '13 13:02

Ankit Dhingra


People also ask

What does doLast mean in Gradle?

The doLast creates a task action that runs when the task executes. Without it, you're running the code at configuration time on every build. Both of these print the line, but the first one only prints the line when the testTask is supposed to be executed.

Is not up to date because task upToDateWhen is false?

upToDateWhen { false } means “outputs are not up to date”. If any upToDateWhen spec returns false, the task is considered out of date. If they return true, Gradle does the normal behavior of checking input/output files.

What is the purpose of the Gradle?

It is popular for its ability to build automation in languages like Java, Scala, Android, C/C++, and Groovy. The tool supports groovy based Domain Specific Language over XML. Gradle provides building, testing, and deploying software on several platforms. The tool is popular for building any software and large projects.

How do I know which version of Gradle is installed?

In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here.


3 Answers

Everything that Gradle does is a task. Most tasks have inputs and outputs declared. Gradle will determine if a task is up to date by checking the inputs and outputs.

For example, your compile task input is the source code. If the source code hasn't changed since the last compile, then it will check the output to make sure you haven't blown away your class files generated by the compiler. If the input and output is unchanged, it considers the task "up to date" and doesn't execute that task. This can save a lot of time, especially on large builds.

like image 116
CaTalyst.X Avatar answered Sep 28 '22 17:09

CaTalyst.X


BTW: In case you really want to bypass this build optimization, you can use the --rerun-tasks command-line option to enforce execution of every task. see documentation of gradle command-line options

like image 22
roomsg Avatar answered Sep 28 '22 19:09

roomsg


Gradle is an incremental build system. This means that it checks that a task must really be executed before actually executing it, in order to be faster.

So, for example, if you already compiled your source files in a previous build, and didn't modify any source file (nor any other input of the compile task), then Gradle won't recompile all the source files, because it know it will lead to exactly the same output as the one already present in the build folder. And the compilation is thus safely skipped, leading to a faster build.

More information in the documentation

like image 41
JB Nizet Avatar answered Sep 28 '22 17:09

JB Nizet