English subtitles

← Typed Tasks

Get Embed Code
4 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. We've seen how to create new Gradle
    tasks, and add task actions to them.
  2. So far, task action
    implementations have been simple,
  3. such as just writing
    text out to the console.
  4. But what about more sophisticated tasks?
  5. How might we go about implementing
    a task action for, say, copying files?
  6. We would first have to
    define some way for
  7. the users to configure which files
    should be copied and to where.
  8. We then have to write all the I/O code
    necessary to perform the copy action,
  9. handle errors, and
    report status back to the user.
  10. Thankfully, Gradle includes many
    tasks which are preconfigured
  11. to provide commonly
    needed functionality.
  12. We distinguish these tasks by their
    type, such as copy, delete, or zip.
  13. We refer to these kinds
    of task as type task.
  14. In contrast, tasks whose actions are
    implemented inline in the build script
  15. using gif first or gif last
    are referred to as ad hoc tasks.
  16. The syntax for creating a type task
    is similar to that of an ad hoc task,
  17. the difference being that we define the
    type of the task as a name parameter.