Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Gradle Effective Implementations Guide

You're reading from   Gradle Effective Implementations Guide This comprehensive guide will get you up and running with build automation using Gradle.

Arrow left icon
Product type Paperback
Published in May 2016
Publisher
ISBN-13 9781784394974
Length 368 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Hubert Klein Ikkink Hubert Klein Ikkink
Author Profile Icon Hubert Klein Ikkink
Hubert Klein Ikkink
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Starting with Gradle FREE CHAPTER 2. Creating Gradle Build Scripts 3. Working with Gradle Build Scripts 4. Using Gradle for Java Projects 5. Dependency Management 6. Testing, Building, and Publishing Artifacts 7. Multi-project Builds 8. Mixed Languages 9. Maintaining Code Quality 10. Writing Custom Tasks and Plugins 11. Gradle in the Enterprise 12. IDE Support

Executing multiple tasks

With just a simple build script, we already discussed that we have a couple of default tasks besides our own task that we can execute. To execute multiple tasks, we only have to add each task name to the command line. Let's execute our helloWorld custom task and built-in tasks task:

$ gradle helloWorld tasks
:helloWorld
Hello world.
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]
Help tasks
----------
 components - Displays the components produced by root project 'hello-world'. [incubating]
 dependencies - Displays all dependencies declared in root project 'hello-world'.
dependencyInsight - Displays the insight into a specific  dependency in root project 'hello-world'.
help - Displays a help message.
model - Displays the configuration model of root project 'hello-world'. [incubating]
projects - Displays the sub-projects of root project 'hello-world'.
properties - Displays the properties of root project 'hello-world'.
tasks - Displays the tasks runnable from root project 'hello-world'.
Other tasks
-----------
helloWorld
To see all tasks and more detail, run gradle tasks --all
To see more detail about a task, run gradle help --task <task>
BUILD SUCCESSFUL
Total time: 2.028 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.12/userguide/gradle_daemon.html

We see the output of both tasks. First, helloWorld is executed, followed by tasks. In the output, we see the task names prepended  with a colon (:) and the output is in the next lines.

Gradle executes the tasks in the same order as they are defined in the command line. Gradle will only execute a task once during the build. So even if we define the same task multiple times, it will only be executed once. This rule also applies when tasks have dependencies on other tasks. Gradle will optimize the task execution for us and we don't have to worry about that.

You have been reading a chapter from
Gradle Effective Implementations Guide - Second Edition
Published in: May 2016
Publisher:
ISBN-13: 9781784394974
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime