O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Gradle Beyond the Basics

Book Description

If you’re familiar with Gradle’s basics elements—possibly through the author’s previous O’Reilly book, Building and Testing with Gradle—this more advanced guide provides the recipes, techniques, and syntax to help you master this build automation tool. With clear, concise explanations and lots of ready-to-use code examples, you’ll explore four discrete areas of Gradle functionality: file operations, custom Gradle plugins, build lifecycle hooks, and dependency management.

Learn how to use Gradle’s rich set of APIs and Groovy-based Domain Specific Language to customize build software that actually conforms to your product. By using the techniques in this book, you’ll be able to write domain-specific builds that support every other line of code your team creates.

  • Examine Gradle’s file API, including copy tasks, pattern matching, content filtering, and the FileCollection interface
  • Understand the process for building and packaging a custom Gradle plug-in
  • Manage build complexity with hook methods and Gradle’s rule feature
  • Learn how Gradle handles dependency management natively and through customization
  • Explore Gradle’s core plug-ins as well as key examples from the Gradle community

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. Safari® Books Online
    3. How to Contact Us
    4. Acknowledgments
  2. 1. File Operations
    1. Copy Task
      1. Transforming Directory Structure
      2. Renaming Files During Copy
    2. Filtering and Transforming Files
      1. Keyword Expansion
      2. Filtering Line by Line
      3. Filtering File by File
    3. The File Methods
      1. file()
      2. files()
      3. fileTree()
    4. The FileCollection Interface
      1. Converting to a Set
      2. Converting to a Path String
      3. Module Dependencies as FileCollections
      4. Adding and Subtracting FileCollections
      5. SourceSets as FileCollections
    5. Lazy Files
    6. Conclusion
  3. 2. Custom Plug-Ins
    1. Plug-In Philosophy
    2. The Plug-In API
    3. The Example Plug-In
    4. Setup
    5. Sketching Out Your Plug-In
      1. Custom Liquibase Tasks
      2. Applying Yourself
      3. Extensions
    6. Packaging a Plug-In
    7. Conclusion
  4. 3. Build Hooks
    1. The Gradle Lifecycle: A Review
    2. Advising the Build Graph
    3. Advising Project Evaluation
      1. Global Project Loading and Evaluation Hooks
      2. Build Finished
    4. Rules
      1. Creating a Rule
      2. Dealing with Imperative Rule Code
      3. Generalizing Rules Beyond Tasks
    5. Conclusion
  5. 4. Dependency Management
    1. What Is Dependency Management?
    2. Dependency Concepts
      1. Configurations
        1. Extending configurations
      2. Module Dependencies
      3. Dynamic Versions
      4. File Dependencies
      5. Project Dependencies
      6. Internal Dependencies
    3. Repositories: Dependency Resolution
      1. Maven Repositories
        1. Changing modules
      2. Ivy
      3. Repository Credentials
      4. Static Dependencies
    4. Buildscript Dependencies
    5. Dependency Caching
    6. Configuring Resolution Strategy
      1. Failing on Version Conflict
      2. Forcing Versions
      3. Cache Expiration
    7. Conclusion
  6. Afterword
  7. About the Author
  8. Colophon
  9. Copyright