Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Gradle Essentials

You're reading from   Gradle Essentials Master the fundamentals of Gradle using real-world projects with this quick and easy-to-read guide

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781783982363
Length 176 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
 Dabir Dabir
Author Profile Icon Dabir
Dabir
 Maheshwari Maheshwari
Author Profile Icon Maheshwari
Maheshwari
Arrow right icon
View More author details
Toc

Tasks


As we have seen so far, a task is a named action that performs some build logic. It's a unit of build work. For example, clean, compile, dist, and so on, are typical build tasks that easily come to our mind if we have to write tasks for our project. Tasks are more or less analogous to Ant's targets.

The simplest way to create a task is as follows:

task someTask

Before we go any further with tasks, let's take a moment to ponder about task creation.

We used the taskName task form of a statement.

If we rewrite it as a task (taskName), it will immediately look like the method call.

The preceding method, as we might have already guessed by now, is available on the project object.

So, we could write one of the following as well:

  • project.task "myTask"

  • project.task("myTask")

Notice that in the later examples we had to pass the task name as a string. The task taskName is a special form where we can use taskName as a literal instead of string. This is done by Groovy AST transformation magic.

The project...

lock icon The rest of the chapter is locked
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 $15.99/month. Cancel anytime
Visually different images