You are previewing Gradle Effective Implementation Guide.

Gradle Effective Implementation Guide

Cover of Gradle Effective Implementation Guide by Hubert Klein Ikkink Published by Packt Publishing
  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
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
    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
    9. 1. Starting with Gradle
      1. Introducing Gradle
      2. Getting started
      3. Writing our first build script
      4. Default Gradle tasks
      5. Task name abbreviation
      6. Executing multiple tasks
      7. Command-line options
      8. Understanding the Gradle user interface
      9. Summary
    10. 2. Creating Gradle Build Scripts
      1. Writing a build script
      2. Defining tasks
      3. Build scripts are Groovy code
      4. Defining dependencies between tasks
      5. Setting default tasks
      6. Organizing tasks
      7. Adding tasks in other ways
      8. Accessing tasks as project properties
      9. Adding additional properties to tasks
      10. Avoiding common pitfalls
      11. Skipping tasks
      12. Summary
    11. 3. Working with Gradle Build Scripts
      1. Working with files
      2. Project properties
      3. Using logging
      4. Using 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
      5. Working with properties
      6. Creating documentation
      7. Assembling archives
      8. Summary
    13. 5. Dependency Management
      1. Dependency configuration
      2. Repositories
      3. Defining dependencies
      4. Summary
    14. 6. Testing, Building, and Publishing Artifacts
      1. Testing
      2. Running Java applications
      3. Publishing artifacts
      4. Packaging Java Enterprise Edition applications
      5. Summary
    15. 7. Multi-project Builds
      1. Working with multi-project builds
      2. Working with Java multi-project builds
      3. Using the Jetty plugin
      4. Summary
    16. 8. Mixed Languages
      1. Using the Groovy plugin
      2. Using 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
      2. Creating a task in the project source directory
      3. Creating a task in a standalone project
      4. Creating a custom plugin
      5. Creating a plugin in the project source directory
      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
      3. Using JetBrains TeamCity
      4. Using Atlassian Bamboo
      5. Summary
    20. 12. IDE Support
      1. Using the Eclipse plugin
      2. Using the IntelliJ IDEA plugin
      3. Running Gradle in Eclipse
      4. Running Gradle in IntelliJ IDEA
      5. Summary
    21. Index
O'Reilly logo

Chapter 3. Working with Gradle Build Scripts

A Gradle script is a program. We use a Groovy DSL to express our build logic. Gradle has several useful built-in methods for handling files and directories, because we often deal with files and directories in our build logic.

In this chapter we will learn how we can use Gradle's features to work with files and directories. Also, we will take a look at how we can set properties in a Gradle build and use Gradle's logging framework. Finally, we see will how we can use the Gradle wrapper task to distribute a configurable Gradle with our build scripts.

Working with files

It is very common in a build script that we have to work with files and directories. For example, when we need to copy a file from one directory ...

The best content for your career. Discover unlimited learning on demand for around $1/day.