You are previewing Gradle Effective Implementation Guide.
O'Reilly logo
Gradle Effective Implementation Guide

Book Description

Empower yourself to automate your build

  • Learn the best of Gradle

  • Work easily with multi-projects

  • Apply Gradle to your Java, Scala and Groovy projects

In Detail

Gradle is the next generation in build automation. It uses convention-over-configuration to provide good defaults, but is also flexible enough to be usable in every situation you encounter in daily development. Build logic is described with a powerful DSL and empowers developers to create reusable and maintainable build logic.

"Gradle Effective Implementation Guide" is a great introduction and reference for using Gradle. The Gradle build language is explained with hands on code and practical applications. You learn how to apply Gradle in your Java, Scala or Groovy projects, integrate with your favorite IDE and how to integrate with well-known continuous integration servers.

Start with the foundations and work your way through hands on examples to build your knowledge of Gradle to skyscraper heights. You will quickly learn the basics of Gradle, how to write tasks, work with files and how to use write build scripts using the Groovy DSL. Then as you develop you will be shown how to use Gradle for Java projects. Compile, package, test and deploy your applications with ease. When you’ve mastered the simple, move on to the sublime and integrate your code with continuous integration servers and IDEs. By the end of the "Gradle Effective Implementation Guide" you will be able to use Gradle in your daily development. Writing tasks, applying plugins and creating build logic will be second nature.

Table of Contents

  1. Gradle Effective Implementation Guide
    1. Table of Contents
    2. Gradle Effective Implementation Guide
    3. Credits
    4. About the Author
    5. Acknowledgement
    6. About the Reviewers
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Starting with Gradle
      1. Introducing Gradle
        1. Declarative builds and convention over configuration
        2. Support for Ant tasks and Maven repositories
        3. Incremental builds
        4. Multi-project builds
        5. Gradle wrapper
        6. Free and open source
      2. Getting started
        1. Installing Gradle
      3. Writing our first build script
      4. Default Gradle tasks
      5. Task name abbreviation
      6. Executing multiple tasks
      7. Command-line options
        1. Logging options
        2. Changing the build file and directory
        3. Running tasks without execution
        4. Gradle daemon
        5. Profiling
      8. Understanding the Gradle user interface
        1. Task Tree
        2. Favorites
        3. Command Line
        4. Setup
      9. Summary
    10. 2. Creating Gradle Build Scripts
      1. Writing a build script
      2. Defining tasks
        1. Defining actions with the Action interface
      3. Build scripts are Groovy code
      4. Defining dependencies between tasks
        1. Defining dependencies via tasks
        2. Defining dependencies via closures
      5. Setting default tasks
      6. Organizing tasks
        1. Adding a description to tasks
        2. Grouping tasks together
      7. Adding tasks in other ways
        1. Using task rules
      8. Accessing tasks as project properties
      9. Adding additional properties to tasks
      10. Avoiding common pitfalls
      11. Skipping tasks
        1. Using onlyIf predicates
        2. Skipping tasks by throwing StopExecutionException
        3. Enabling and disabling tasks
        4. Skipping from the command line
        5. Skipping tasks that are up-to-date
      12. Summary
    11. 3. Working with Gradle Build Scripts
      1. Working with files
        1. Locating files
        2. Using file collections
        3. Working with file trees
        4. Copying files
          1. Renaming files
          2. Filtering files
        5. Archiving files
      2. Project properties
        1. Defining custom properties in script
        2. Passing properties via the command line
        3. Defining properties via system properties
        4. Adding properties via environment variables
        5. Defining properties using an external file
      3. Using logging
        1. Controlling output
      4. Using the Gradle wrapper
        1. Creating wrapper scripts
        2. Customizing the Gradle wrapper
      5. Summary
    12. 4. Using Gradle for Java Projects
      1. Using plugins
      2. Getting started
      3. Using the Java plugin
      4. Working with source sets
        1. Creating a new source set
        2. Custom configuration
      5. Working with properties
      6. Creating documentation
      7. Assembling archives
      8. Summary
    13. 5. Dependency Management
      1. Dependency configuration
      2. Repositories
        1. Adding Maven repositories
        2. Adding Ivy repositories
        3. Adding a local directory repository
      3. Defining dependencies
        1. Using external module dependencies
        2. Using project dependencies
        3. Using file dependencies
        4. Using client module dependencies
        5. Using Gradle and Groovy dependencies
        6. Accessing configuration dependencies
        7. Setting dynamic versions
        8. Resolving version conflicts
        9. Adding optional ANT tasks
        10. Using dependency configurations as files
      4. Summary
    14. 6. Testing, Building, and Publishing Artifacts
      1. Testing
        1. Using TestNG for testing
        2. Configuring the test process
        3. Determining tests
        4. Logging test output
        5. Generating test reports
      2. Running Java applications
        1. Running an application from a project
        2. Running an application as task
        3. Running an application with the application plugin
        4. Creating a distributable application archive
      3. Publishing artifacts
        1. Uploading to a Maven repository
        2. Multiple artifacts
        3. Signing artifacts
          1. Publishing signature files
          2. Configuring conditional signing
      4. Packaging Java Enterprise Edition applications
        1. Creating a WAR file
          1. Using the War plugin
        2. Creating an EAR file
          1. Using the Ear plugin
      5. Summary
    15. 7. Multi-project Builds
      1. Working with multi-project builds
        1. Executing tasks by project path
        2. Using a flat layout
        3. Defining projects
        4. Filtering projects
        5. Defining task dependencies between projects
        6. Defining configuration dependencies
      2. Working with Java multi-project builds
        1. Using partial builds
      3. Using the Jetty plugin
      4. Summary
    16. 8. Mixed Languages
      1. Using the Groovy plugin
        1. Creating documentation with the Groovy plugin
      2. Using the Scala plugin
        1. Creating documentation with the Scala plugin
      3. Summary
    17. 9. Maintaining Code Quality
      1. Using the Checkstyle plugin
      2. Using the PMD plugin
      3. Using the FindBugs plugin
      4. Using the JDepend plugin
      5. Using the CodeNarc plugin
      6. Using the Sonar plugin
      7. Summary
    18. 10. Writing Custom Tasks and Plugins
      1. Creating a custom task
        1. Creating a custom task in the build file
        2. Using incremental build support
      2. Creating a task in the project source directory
        1. Writing tests
      3. Creating a task in a standalone project
      4. Creating a custom plugin
        1. Creating a plugin in the build file
      5. Creating a plugin in the project source directory
        1. Testing a plugin
      6. Creating a plugin in a standalone project
      7. Summary
    19. 11. Using Gradle with Continuous Integration
      1. Creating a sample project
      2. Using Jenkins
        1. Adding the Gradle plugin
        2. Configuring Jenkins job
        3. Running the job
        4. Configuring artifacts and test results
        5. Adding Gradle versions
      3. Using JetBrains TeamCity
        1. Creating a project
        2. Running the project
      4. Using Atlassian Bamboo
        1. Defining a build plan
        2. Running the build plan
      5. Summary
    20. 12. IDE Support
      1. Using the Eclipse plugin
        1. Customizing generated files
          1. Customizing using DSL
          2. Customizing with merge hooks
          3. Customizing with XML manipulation
        2. Merging configuration
        3. Configuring WTP
          1. Customizing file generation
      2. Using the IntelliJ IDEA plugin
        1. Customizing file generation
          1. Customizing using DSL
          2. Customizing with merged hooks
          3. Customizing with XML manipulation
      3. Running Gradle in Eclipse
        1. Installing Gradle plugin
        2. Importing Gradle project
        3. Running tasks
        4. Editing build files
      4. Running Gradle in IntelliJ IDEA
        1. Installing the plugin
        2. Importing a project
        3. Running tasks
      5. Summary
    21. Index