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 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
Abhinandan Maheshwari Abhinandan Maheshwari
Author Profile Icon Abhinandan Maheshwari
Abhinandan Maheshwari
Kunal Dabir Kunal Dabir
Author Profile Icon Kunal Dabir
Kunal Dabir
Arrow right icon
View More author details
Toc

Chapter 1. Running Your First Gradle Task

We are embarking on a fast-paced ride to learn the Gradle Essentials. To take a gentle start, we will first install Gradle. Then, we will get friendly with the Gradle's command-line interface by looking at the usage of the gradle command. Also, by the end of this chapter, we would have run our first Gradle build script.

Building a software artifact is a complex process involving various activities such as compiling source code, running automated tests, packaging distributable files, and so on. These activities are further split into many steps, often dependent on the execution order, fetching dependent artifacts, resolving configuration variables, and so on. Executing all these activities manually is cumbersome and often error-prone. A good build automation tool helps us reduce the effort and time it takes to build correct artifacts in a repeatable manner.

Gradle is an advanced build automation tool that brings the best from various proven build tools and innovates on top of them. Gradle can be used to produce artifacts such as web applications, application libraries, documentation, static sites, mobile apps, command lines, and desktop applications. Gradle can be used to build projects based on various languages and technology stacks such as Java, C/C++, Android, Scala, Groovy, Play, Grails, and many more. As Java Virtual Machine (JVM) happens to be one of the first class supported platforms by Gradle, the examples in this book will mostly focus on building Java-based projects.

Gradle gives us full control over build just like Ant but without ever needing to repeat ourselves by providing intelligent defaults in the form of conventions. Gradle truly works by conventions over configuration, just like Maven. However, it never gets in our way when we need to deviate. Also this puts it in complete contrast with Maven. Gradle attempts to maintain the right balance between conventions and configurability.

The previous generation of build tools, such as Ant and Maven, chose XML to represent the build logic. While XML is human-readable, it is more of a machine-friendly format (easier to be read/written by programs). It is great for representing and exchanging hierarchical data, but when it comes to writing any logic, even the simplest logic can easily take hundreds of lines. On the other hand, a Gradle build can be configured using very human-friendly Groovy DSL. Groovy is a powerful, expressive, and low ceremony dynamic language and is a perfect fit for build scripts.

Gradle itself is a JVM application written in Java and Groovy. Since Gradle runs on the JVM, it runs the same way on Windows, Mac OS X and Linux. Gradle also boasts an advanced dependency resolution system and can resolve dependencies from the existing Maven and Ivy repositories or even a file system.

Over the years Gradle has matured into a very stable open source project with active contributors and commercial backing. The rich plugin ecosystem and vibrant community makes Gradle an excellent choice for a variety of projects. Gradle already has an impressive list of adopters, which includes tech giants such as Google Android, LinkedIn, Unity 3D, Netflix and many more. Open source libraries and frameworks such as Spring, Hibernate, and Grails are using Gradle to power their builds.

You have been reading a chapter from
Gradle Essentials
Published in: Dec 2015
Publisher:
ISBN-13: 9781783982363
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