Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Foreword

Preface

Acknowledgments

About this Book

About the Cover Illustration

1. Introducing Gradle

Chapter 1. Introduction to project automation

1.1. Life without project automation

1.2. Benefits of project automation

1.2.1. Prevents manual intervention

1.2.2. Creates repeatable builds

1.2.3. Makes builds portable

1.3. Types of project automation

1.3.1. On-demand builds

1.3.2. Triggered builds

1.3.3. Scheduled builds

1.4. Build tools

1.4.1. What’s a build tool?

1.4.2. Anatomy of a build tool

1.5. Java build tools

1.5.1. Apache Ant

1.5.2. Apache Maven

1.5.3. Requirements for a next-generation build tool

1.6. Summary

Chapter 2. Next-generation builds with Gradle

2.1. Why Gradle? Why now?

2.1.1. Evolution of Java build tools

2.1.2. Why you should choose Gradle

2.2. Gradle’s compelling feature set

2.2.1. Expressive build language and deep API

2.2.2. Gradle is Groovy

2.2.3. Flexible conventions

2.2.4. Robust and powerful dependency management

2.2.5. Scalable builds

2.2.6. Effortless extendibility

2.2.7. Integration with other build tools

2.2.8. Community-driven and company-backed

2.2.9. Icing on the cake: additional features

2.3. The bigger picture: continuous delivery

2.3.1. Automating your project from build to deployment

2.4. Installing Gradle

2.5. Getting started with Gradle

2.6. Using the Command line

2.6.1. Listing available tasks of a project

2.6.2. Task execution

2.6.3. Command-line options

2.6.4. Gradle daemon

2.7. Summary

Chapter 3. Building a Gradle project by example

3.1. Introducing the case study

3.1.1. The To Do application

3.1.2. Task management use cases

3.1.3. Examining the component interaction

3.1.4. Building the application’s functionality

3.2. Building a Java project

3.2.1. Using the Java plugin

3.2.2. Customizing your project

3.2.3. Configuring and using external dependencies

3.3. Web development with Gradle

3.3.1. Adding web components

3.3.2. Using the War and Jetty plugins

3.4. Gradle wrapper

3.4.1. Setting up the wrapper

3.4.2. Using the wrapper

3.4.3. Customizing the wrapper

3.5. Summary

2. Mastering the fundamentals

Chapter 4. Build script essentials

4.1. Building blocks

4.1.1. Projects

4.1.2. Tasks

4.1.3. Properties

4.2. Working with tasks

4.2.1. Managing the project version

4.2.2. Declaring task actions

4.2.3. Accessing DefaultTask properties

4.2.4. Defining task dependencies

4.2.5. Finalizer tasks

4.2.6. Adding arbitrary code

4.2.7. Understanding task configuration

4.2.8. Declaring task inputs and outputs

4.2.9. Writing and using a custom task

4.2.10. Gradle’s built-in task types

4.2.11. Task rules

4.2.12. Building code in buildSrc directory

4.3. Hooking into the build lifecycle

Internal task graph representation

4.3.1. Hooking into the task execution graph

4.3.2. Implementing a task execution graph listener

4.3.3. Initializing the build environment

4.4. Summary

Chapter 5. Dependency management

5.1. A quick overview of dependency management

5.1.1. Imperfect dependency management techniques

5.1.2. Importance of automated dependency management

5.1.3. Using automated dependency management

5.1.4. Challenges of automated dependency management

5.2. Learning dependency management by example

5.3. Dependency configurations

5.3.1. Understanding the configuration API representation

5.3.2. Defining a custom configuration

5.3.3. Accessing a configuration

5.4. Declaring dependencies

5.4.1. Understanding the dependency API representation

5.4.2. External module dependencies

5.4.3. File dependencies

5.5. Using and configuring repositories

5.5.1. Understanding the repository API representation

5.5.2. Maven repositories

5.5.3. Ivy repositories

5.5.4. Flat directory repositories

5.6. Understanding the local dependency cache

5.6.1. Analyzing the cache structure

5.6.2. Notable caching features

5.7. Troubleshooting dependency problems

5.7.1. Responding to version conflicts

5.7.2. Enforcing a specific version

5.7.3. Using the dependency insight report

5.7.4. Refreshing the cache

5.8. Summary

Chapter 6. Multiproject builds

6.1. Modularizing a project

6.1.1. Coupling and cohesion

6.1.2. Identifying modules

6.1.3. Refactoring to modules

6.2. Assembling a multiproject build

6.2.1. Introducing the settings file

6.2.2. Understanding the Settings API representation

6.2.3. Settings execution

6.2.4. Settings file resolution

6.2.5. Hierarchical versus flat layout

6.3. Configuring subprojects

6.3.1. Understanding the Project API representation

6.3.2. Defining specific behavior

6.3.3. Declaring project dependencies

6.3.4. Partial multiproject builds

6.3.5. Declaring cross-project task dependencies

6.3.6. Defining common behavior

6.4. Individual project files

6.4.1. Creating build files per project

6.4.2. Defining the root project’s build code

6.4.3. Defining the subprojects’ build code

6.5. Customizing projects

6.6. Summary

Chapter 7. Testing with Gradle

7.1. Automated testing

7.1.1. Types of automated testing

7.1.2. Test automation pyramid

7.2. Testing Java applications

7.2.1. Project layout

7.2.2. Test configurations

7.2.3. Test tasks

7.2.4. Automatic test detection

7.3. Unit testing

7.3.1. Using JUnit

7.3.2. Using alternative unit testing frameworks

7.3.3. Multiple unit testing frameworks in harmony

7.4. Configuring test execution

7.4.1. Command-line options

7.4.2. Understanding the Test API representation

7.4.3. Controlling runtime behavior

7.4.4. Controlling test logging

7.4.5. Parallel test execution

7.4.6. Reacting to test lifecycle events

7.4.7. Implementing a test listener

7.5. Integration testing

7.5.1. Introducing the case study

7.5.2. Writing the test class

7.5.3. Supporting integration tests in the build

7.5.4. Establishing conventions for integration tests

7.5.5. Bootstrapping the test environment

7.6. Functional testing

7.6.1. Introducing the case study

7.6.2. Supporting functional tests in the build

7.7. Summary

Chapter 8. Extending Gradle

8.1. Introducing the plugin case study

8.1.1. Application management in the cloud with Gradle

8.1.2. Setting up the cloud environment

8.2. From zero to plugin

8.3. Writing a script plugin

8.3.1. Adding the CloudBees API library

8.3.2. Using the CloudBees API from tasks

8.4. Writing custom task classes

8.4.1. Custom task implementation options

8.4.2. Defining a custom task in buildSrc

8.5. Using and building object plugins

8.5.1. Applying object plugins

8.5.2. Anatomy of an object plugin

8.5.3. Writing an object plugin

8.5.4. Plugin extension mechanism

8.5.5. Assigning a meaningful plugin name

8.5.6. Testing an object plugin

8.5.7. Developing and consuming a standalone object plugin

8.6. Summary

Chapter 9. Integration and migration

9.1. Ant and Gradle

9.1.1. Using Ant script functionality from Gradle

9.1.2. Using standard Ant tasks from Gradle

9.1.3. Migration strategies

9.2. Maven and Gradle

9.2.1. Commonalities and differences

9.2.2. Migration strategies

9.3. Comparing builds

9.4. Summary

3. From build to deployment

Chapter 10. IDE support and tooling

10.1. Using IDE plugins to generate project files

10.1.1. Using the Eclipse plugins

10.1.2. Using the IDEA plugin

10.1.3. Using the Sublime Text plugin

10.2. Managing Gradle projects in popular IDEs

10.2.1. Gradle support in SpringSource STS

10.2.2. Gradle support in IntelliJ IDEA

10.2.3. Gradle support in NetBeans IDE

10.3. Embedding Gradle with the tooling API

10.4. Summary

Chapter 11. Building polyglot projects

11.1. Managing JavaScript with Gradle

11.1.1. Typical tasks when dealing with JavaScript

11.1.2. Using JavaScript in the To Do application

11.1.3. Dependency management for JavaScript libraries

11.1.4. Merging and minifying JavaScript using a third-party Ant task

11.1.5. JavaScript optimization as part of the development workflow

11.1.6. JavaScript code analysis using an external Java library

11.1.7. Using a third-party Gradle JavaScript plugin

11.1.8. Executing Grunt from Gradle

11.2. Building polyglot, JVM-based projects

11.2.1. Base capabilities of JVM language plugins

11.2.2. Building Groovy projects

11.2.3. Building Scala projects

11.3. Other languages

11.4. Summary

Chapter 12. Code quality management and monitoring

12.1. Integrating code analysis into your build

12.2. Measuring code coverage

12.2.1. Exploring code coverage tools

12.2.2. Using the JaCoCo plugin

12.2.3. Using the Cobertura plugin

12.3. Performing static code analysis

12.3.1. Exploring static code analysis tools

12.3.2. Using the Checkstyle plugin

12.3.3. Using the PMD plugin

12.3.4. Using the FindBugs plugin

12.3.5. Using the JDepend plugin

12.4. Integrating with Sonar

12.4.1. Installing and running Sonar

12.4.2. Analyzing a project with Sonar Runner

12.4.3. Publishing code coverage metrics to Sonar

12.5. Summary

Chapter 13. Continuous integration

13.1. Benefits of continuous integration

13.2. Setting up Git

13.2.1. Creating a GitHub account

13.2.2. Forking the GitHub repository

13.2.3. Installing and configuring Git

13.3. Building a project with Jenkins

13.3.1. Starting Jenkins

13.3.2. Installing the Git and Gradle plugins

13.3.3. Defining the build job

13.3.4. Executing the build job

13.3.5. Adding test reporting

13.4. Exploring cloud-based solutions

13.5. Modeling a build pipeline with Jenkins

13.5.1. Challenges of building a pipeline

13.5.2. Exploring essential Jenkins plugins

13.5.3. Configuring the pipeline jobs

13.6. Summary

Chapter 14. Artifact assembly and publishing

14.1. Building artifacts and distributions

14.1.1. Declaring additional artifacts

14.1.2. Creating distributions

14.2. Publishing artifacts to a binary repository

14.2.1. Publishing to a Maven repository

14.2.2. Old versus new publishing mechanisms

14.2.3. Declaring a software component as a Maven publication

14.2.4. Publishing a software component to the local Maven cache

14.2.5. Declaring custom artifacts for publication

14.2.6. Modifying the generated POM

14.2.7. Publishing to a local Maven repository

14.2.8. Publishing to a remote Maven repository

14.3. Publishing to a public binary repository

14.3.1. Publishing to JFrog Bintray

14.3.2. Publishing to Maven Central

14.4. Artifact assembly and publishing as part of the build pipeline

14.4.1. Build binaries once

14.4.2. Publish once, reuse later

14.4.3. Picking an appropriate versioning scheme

14.4.4. Including build information in a deployable artifact

14.4.5. Publishing your To Do application WAR file

14.4.6. Extending the build pipeline

14.5. Summary

Chapter 15. Infrastructure provisioning and deployment

15.1. Infrastructure provisioning

15.1.1. Infrastructure as code

15.1.2. Creating a virtual machine with Vagrant and Puppet

15.1.3. Executing Vagrant from Gradle

15.2. Targeting a deployment environment

15.2.1. Defining configuration in a Groovy script

15.2.2. Reading the configuration with Groovy’s ConfigSlurper

15.2.3. Using the configuration throughout the build

15.3. Automated deployments

15.3.1. Retrieving the artifact from the binary repository

15.3.2. Identifying necessary deployment steps

15.3.3. Deployment through SSH commands

15.4. Deployment tests

15.4.1. Verifying a successful deployment with smoke tests

15.4.2. Verifying application functionality with acceptance tests

15.5. Deployment as part of the build pipeline

15.5.1. Automatic deployment to test environment

15.5.2. Deployment tests

15.5.3. On-demand deployment to UAT and production environment

15.6. Summary

Appendix A. Driving the command line

A.1. Discovery tasks

A.2. Build setup tasks

A.3. Configuration input

A.3.1. Common options

A.3.2. Property options

A.3.3. Logging options

A.3.4. Caching options

A.3.5. Daemon options

Appendix B. Groovy for Gradle users

B.1. What is Groovy?

B.2. How much Groovy do I need to know?

B.3. Comparing Java and Groovy syntax

B.4. Essential Groovy features

B.4.1. Assert statement

B.4.2. Optional data type declaration

B.4.3. Optional parentheses

B.4.4. Strings

B.4.5. Groovy Strings (GStrings)

B.4.6. Collections API

B.4.7. Named parameters

B.4.8. Closures

B.4.9. Groovy Development Toolkit

B.5. Applied Groovy in Gradle build scripts

Index

List of Figures

List of Tables

List of Listings

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

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