Gradle Effective Implementations Guide - Second Edition

Book description

A comprehensive guide to get up and running with build automation using Gradle

About This Book

  • Practical and engaging from start to finish covering the fundamentals of Gradle

  • Learn the skills required to develop Java applications with Gradle and integrate at an enterprise level

  • Apply the correct plugin and configuration to our Gradle build files to work with the different languages

  • Who This Book Is For

    This book is for Java developers who have working knowledge of build automation processes and are now looking to gain expertise with Gradle and add to their skill set.

    What You Will Learn

  • Write your first Gradle Script

  • Write build logic with the Gradle build language

  • Explore the Java plugins supported by Gradle

  • Understand dependency management in Gradle

  • Package and publish your (web) application

  • Integrate Scala and Groovy with Gradle

  • Write your own custom tasks and plugins

  • Integrate Gradle with your IDE

  • In Detail

    Gradle is a project automation tool that has a wide range of applications. The basic aim of Gradle is to automate a wide variety of tasks performed by software developers, including compiling computer source code to binary code, packaging binary codes, running tests, deploying applications to production systems, and creating documentation.

    The book will start with the fundamentals of Gradle and introduce you to the tools that will be used in further chapters. You will learn to create and work with Gradle scripts and then see how to use Gradle to build your Java Projects. While building Java application, you will find out about other important topics such as dependency management, publishing artifacts, and integrating the application with other JVM languages such as Scala and Groovy.

    By the end of this book, you will be able to use Gradle in your daily development. Writing tasks, applying plugins, and creating build logic will be your second nature.

    Style and approach

    This step-by-step guide aims to cover the fundamentals of Gradle and focuses on providing the practical skills required to develop web application.

    Table of contents

    1. Gradle Effective Implementations Guide - Second Edition
      1. Gradle Effective Implementations Guide - Second Edition
      2. Credits
      3. About the Author
      4. About the Reviewer
      5. www.PacktPub.com
        1. Why subscribe?
        2. Free access for Packt account holders
      6. 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
      7. 1. Starting with Gradle
        1. Declarative builds and convention over configuration
          1. Support for Ant Tasks and Maven repositories
          2. Incremental builds
          3. Multi-project builds
          4. Gradle Wrapper
          5. Free and open source
        2. Getting started
          1. Installing Gradle
          2. Installing with SKDMAN!
        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
          6. Offline usage
        8. Understanding the Gradle graphical user interface
          1. Task tree
          2. Favorites
          3. Command line
          4. Setup
        9. Summary
      8. 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
          3. Getting more information about a task
        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
      9. 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
          5. Archiving files
        2. Project properties
          1. Defining custom properties in script
          2. Defining properties using an external file
          3. Passing properties via the command line
          4. Defining properties via system properties
          5. Adding properties via environment variables
        3. Using logging
          1. Controlling output
        4. Using the Gradle Wrapper
          1. Creating wrapper scripts
          2. Customizing the Gradle Wrapper
        5. Summary
      10. 4. Using Gradle for Java Projects
        1. Why plugins?
        2. Getting started with the Java plugin
          1. Using the Java plugin
        3. Working with source sets
          1. Creating a new source set
          2. Custom configuration
        4. Working with properties
        5. Creating Javadoc documentation
          1. Assembling archives
        6. Summary
      11. 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
      12. 6. Testing, Building, and Publishing Artifacts
        1. Testing our projects
          1. Using TestNG for testing
          2. Configuring the test process
          3. Determining tests
          4. Logging test output
          5. Changing the test report directory
        2. Running Java applications
          1. Running an application from a project
          2. Running an application as a task
          3. Running an application with the application plugin
          4. Creating a distributable application archive
        3. Publishing artifacts
          1. Uploading our artifacts to a Maven repository
          2. Working with multiple artifacts
          3. Signing artifacts
        4. Packaging Java Enterprise Edition applications
          1. Creating a WAR file
          2. Creating an EAR file
        5. Summary
      13. 7. Multi-project Builds
        1. Working with multi-project builds
          1. Executing tasks by project path
          2. Using a flat layout
          3. Ways of 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
      14. 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
      15. 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. Summary
      16. 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
          3. Creating a task in the project source directory
          4. Writing tests
        2. Creating a task in a standalone project
        3. Creating a custom plugin
          1. Creating a plugin in the build file
        4. Creating a plugin in the project source directory
          1. Testing a plugin
        5. Creating a plugin in a standalone project
        6. Summary
      17. 11. Gradle in the Enterprise
        1. Creating a sample project
        2. Using Jenkins
          1. Adding the Gradle plugin
          2. Configuring a 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 plan
          2. Running the build plan
        5. Summary
      18. 12. IDE Support
        1. Using the Eclipse plugin
          1. Customizing generated files
          2. Customizing using DSL
          3. Customizing with merge hooks
          4. Customizing with an XML manipulation
          5. Merging configuration
          6. Configuring WTP
        2. Using the IntelliJ IDEA plugin
          1. Customizing file generation
        3. Running Gradle in Eclipse
          1. Installing the buildship plugin
          2. Importing a Gradle project
          3. Running tasks
        4. Running Gradle in IntelliJ IDEA
          1. Installing the plugin
          2. Importing a project
          3. Running tasks
        5. Summary

    Product information

    • Title: Gradle Effective Implementations Guide - Second Edition
    • Author(s): Hubert Klein Ikkink
    • Release date: May 2016
    • Publisher(s): Packt Publishing
    • ISBN: 9781784394974