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.
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.
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.
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.
In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With