About this Book

Roadmap

This book is divided into three parts. The first part gives an introduction to Gradle’s concepts and philosophy, explaining how it compares to other build tools and how to write scripts to automate simple tasks. Part two explores the tool’s building blocks and core techniques in greater depth. You should be able to use this knowledge to implement complex, extendable, enterprise builds. The third part describes how Gradle can be used in the context of continuous deliver, focusing on topics like polyglot builds, code quality, artifact assembly, and deployment.

The chapters in part 1, Introducing Gradle, are as follows:

1.  Introduction to project automation—This chapter gives a gentle introduction into why it’s a good idea to automate your projects and how build tools can help get the job done.

2.  Next generation builds with Gradle—How does Gradle compare to existing JVM-language build tools? This chapter covers Gradle’s extensive feature set and how it helps automate your software delivery process in the context of a Continuous Delivery deployment pipeline. As a first taste, you’ll write a simple build script and run it on the command line.

3.  Building a Gradle project by example—This chapter introduces a Java-based web application as a vehicle to demonstrate some of Gradle’s core features. We’ll explore the use of the Java plugin for standardized and nonconventional use cases and examine productivity tools for fast development turnaround.

Part 2, Mastering the fundamentals, focuses on applying important Gradle concepts to the case study introduced in part 1:

4.  Build script essentials—What are the main building blocks of a Gradle project? This chapter discusses the use of important domain objects, namely projects and tasks. We’ll touch on how these objects map to the corresponding classes in the Gradle API, Gradle’s build lifecycle, the incremental build feature, and the mechanics of registering lifecycle hooks.

5.  Dependency management—No enterprise project can do without reusing functionality from external libraries. This chapter explores Gradle’s declarative support for dependency management, version conflict resolution strategies, and the inner workings of its cache.

6.  Multiproject builds—Does your project consist of multiple, modularized software components? This chapter covers the options for organizing build logic in a multiproject setting, how to declare project dependencies, and the use of partial builds to improve execution time.

7.  Testing with Gradle—Testing your code is an important activity of the software development lifecycle. By the end of this chapter, you’ll write tests with JUnit, TestNG, and Spock and execute them as part of the build lifecycle. You’ll also learn how to configure test execution, register listeners to react to test lifecycle events, and organize different types of tests with the help of source sets.

8.  Extending Gradle—Gradle provides an extensible domain object model. If you want to add completely new functionality to a project or extend the existing domain model, this chapter is for you. You’ll learn how to write your own plugin to deploy your sample application to the cloud.

9.  Integration and migration—In this chapter, we’ll look at how Gradle integrates with Ant and Maven. We’ll also explore migration strategies in case you decide to go with Gradle long term.

Part 3, From build to deployment, examines how Gradle can be used to bring the example application from the developer’s machine into the production environment with the help of a build pipeline:

10.  IDE support and tooling—IDEs are key enablers for boosting developer productivity. This chapter explains Gradle’s capabilities for generating project files for popular IDEs like Eclipse, IntelliJ, and NetBeans. We also discuss how to navigate and manage Gradle-backed projects within these IDEs.

11.  Building polyglot projects—In this chapter, we’ll discuss how Gradle faces the challenge of organizing and building polyglot projects by using your case study application as an example. The languages you’ll integrate include JavaScript, Groovy, and Scala.

12.  Code quality management and monitoring—In this chapter we’ll focus on tools that measure code quality and visualize the results to help you pinpoint problem areas in your code. By the time you finish this chapter, you’ll know how to integrate code quality tools with your build.

13.  Continuous integration—Continuous integration (CI) is a software development practice where source code is integrated frequently, optimally multiple times a day. This chapter discusses the installation and configuration procedures needed to run Gradle on Jenkins, an open-source CI server.

14.  Artifact assembly and publishing—A build either consumes or produces binary artifacts. This chapter explores the artifact assembly process and the configuration needed to publish artifacts, including their metadata, to a binary repository.

15.  Infrastructure provisioning and deployment—A configured target environment is a prerequisite for any software deployment. In this chapter, we’ll discuss the importance of “infrastructure as code” for setting up and configuring an environment and its services in an automated fashion. Later, you’ll implement an exemplary deployment process with Gradle.

Two appendixes cover additional topics:

A.  Driving the command line—This appendix explains how to operate Gradle from the command line. We’ll explore tasks available to all Gradle builds, plus command line options and their use cases.

B.  Groovy for Gradle users—If you’re new to Groovy, this appendix provides you with a gentle introduction to the most important and widely used language features.

Who should read the book?

This book is primarily for developers and build automation engineers who want to implement a repeatable build that’s easy to read and extend. I assume that you have a basic understanding of an object-oriented programming language. You’ll get the most out of the content if you have a working knowledge of Java.

In this book, you’ll use a lot of Groovy; however, I don’t assume you already have experience with the language. For a jump-start on Groovy, look at appendix B, Groovy for Gradle users. The appendix also provides additional references to books that dig deeper into more advanced aspects of the language.

Throughout the chapters, we’ll touch on topics you can’t circumnavigate when dealing with automated builds. It will be helpful to have some knowledge of tools like Ant, Ivy, and Maven; practices like continuous integration and delivery; and concepts like dependency management. But don’t worry if that’s not your technical background. Every chapter will explain the “why” in great detail.

Code conventions and downloads

Source code in listings and text is in a fixed-width font like this to separate it from ordinary text. Code annotations accompany many of the code listings and highlight important concepts.

The full source code is available from the publisher’s website at www.manning.com/GradleInAction and from the GitHub repository at https://github.com/bmuschko/gradle-in-action-source. You’ll find additional references to source code repositories that either take some examples from the book to the next level or demonstrate the use of Gradle in contexts not covered in the book.

Author Online

The purchase of Gradle in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and other users. To access the forum and subscribe to it, visit http://www.manning.com/GradleInAction. This page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct on the forum.

Manning’s commitment to readers is to provide a venue for meaningful dialogue between individual readers and between readers and the author. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). Let your voice be heard, and keep the author on his toes!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

About the author

Benjamin Muschko is a software engineer with more than 10 years of experience in developing and delivering business applications. He is a member of the Gradleware engineering team and developer of several popular Gradle plugins.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.92.102