Gradle Incremental Builds - Declaring Inputs and Outputs with Runtime API: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 9: Line 9:
  [https://docs.gradle.org/current/dsl/org.gradle.api.Task.html#org.gradle.api.Task:outputs Task.getOutputs()] // returns a [https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/TaskOutputs.html TaskOutputs] instance
  [https://docs.gradle.org/current/dsl/org.gradle.api.Task.html#org.gradle.api.Task:outputs Task.getOutputs()] // returns a [https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/TaskOutputs.html TaskOutputs] instance
  [https://docs.gradle.org/current/dsl/org.gradle.api.Task.html#org.gradle.api.Task:destroyables Task.getDestroyables()] // returns a [https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/TaskDestroyables.html TaskDestroyables] instance
  [https://docs.gradle.org/current/dsl/org.gradle.api.Task.html#org.gradle.api.Task:destroyables Task.getDestroyables()] // returns a [https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/TaskDestroyables.html TaskDestroyables] instance
These objects have methods that allow specifying files, directories and values. The API is almost at parity with the annotations, it is only missing @Nested.

Revision as of 03:53, 22 October 2020

External

Internal

Overview

Annotations in custom task types are the cleanest way to declare inputs and outputs. However, simple tasks can be configured to participate in incremental builds by using the Runtime API. There is also the case of the enhanced tasks we don't have source code for. In all these situations, we can configure the task's inputs and outputs with an alternative runtime API:

Task.getInputs() // returns a TaskInputs instance
Task.getOutputs() // returns a TaskOutputs instance
Task.getDestroyables() // returns a TaskDestroyables instance

These objects have methods that allow specifying files, directories and values. The API is almost at parity with the annotations, it is only missing @Nested.