Gradle's in-built tasks

For day-to-day build-related activities, Gradle provides a variety of tasks. We will take a look at some of Gradle's in-built tasks.

The Copy Task

This task is used to copy file(s) or directories from one location to the other:

task copyTask(type: Copy) {
  from "."
  into "abc"
  include('employees.xml')
}

In copyTask, we have configured the from location and into location, and have also added the condition to include only employees.xml.

The Rename Task

This task is an extended version of the copy task, which is used to rename files or directories:

task copyWithRename(type: Copy) {
  from "."
  into "dir1"
  include('employees.xml')
  rename { String fileName ->
  fileName.replace("employees", "abc")
  }
}

In the copyWithRename task, an additional ...

Get Mastering Gradle now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.