My goal is to configure all tasks in a multi project build (more concretely, I want to add a system variable as an input for all tasks, such that all tasks are rebuilt whenever the value of the system variable changes).
I believe that the following code snippet should achieve this:
allprojects {
tasks {
inputs.property 'foo', System.properties['foo']
}
}
But, it does not. The system property is not added as input to all my tasks.
In contrast, the following code works (where I restrict the tasks for which I configure the inputs to tasks of type AbstractTask
):
allprojects {
tasks.withType(org.gradle.api.internal.AbstractTask) {
inputs.property 'foo', System.properties['foo']
}
}
However, this does not look like the ‘correct’ way to achieve this (using an internal API). Can anybody help me towards a better (or even canonical) solution to this problem?
(I use gradle version 2.7 on Windows 7)