[GRADLE-2390] Task input for simple property never UP-TO-DATE Created: 14/Jul/12 Updated: 01/Jun/16 Resolved: 01/Jun/16 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Kelly Robinson | Assignee: | Unassigned |
Resolution: | Not A Bug | Votes: | 0 |
Description |
Taking this example from Mr. Haki's blog, if you don't have the file as an output to the task, it will run every time. The value set for 'version' is never considered UP-TO-DATE, although it will be detected if it has changed. version = '1.0' outputFile = file("$buildDir/version.txt") task generateVersionFile << { if (!outputFile.isFile()) { outputFile.parentFile.mkdirs() outputFile.createNewFile() } outputFile.write "Version: $version" } generateVersionFile.inputs.property "version", version //without the outputFile the task will run every time //generateVersionFile.outputs.files outputFile task showContents << { println outputFile.text } showContents.dependsOn generateVersionFile |
Comments |
Comment by Lóránt Pintér [ 01/Jun/16 ] |
This is by design. A task is up-to-date when both its inputs and outputs match that of the previous execution. A task must have outputs declared (though it doesn't necessarily need inputs) for Gradle to be able to compare its state to the previous execution. |