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

Publisher resources

View/Submit Errata

Table of contents

  1. Gradle Beyond the Basics
  2. Preface
    1. Conventions Used in This Book
    2. Safari® Books Online
    3. How to Contact Us
    4. Acknowledgments
  3. 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
  4. 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
  5. 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
  6. 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
  7. Afterword
  8. About the Author
  9. Colophon
  10. Copyright

Product information

  • Title: Gradle Beyond the Basics
  • Author(s): Tim Berglund
  • Release date: July 2013
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449373825