[GRADLE-3435] Task is UP-TO-DATE after moving files between @InputFiles properties Created: 13/Apr/16  Updated: 25/Jan/17  Resolved: 07/Jun/16

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 3.0-milestone-2, 3.0-rc-2

Type: Bug
Reporter: Lóránt Pintér Assignee: Lóránt Pintér
Resolution: Fixed Votes: 0


 Description   

Consider the following build script:

class TaskWithTwoFileCollectionInputs extends DefaultTask {
    @InputFiles
    FileCollection files1

    @InputFiles
    FileCollection files2

    @OutputDirectory File outputDirectory = project.buildDir

    @TaskAction
    void action() {}
}

task test(type: TaskWithTwoFileCollectionInputs) {
    files1 = files("input1.txt", "input2.txt")
    files2 = files("input3.txt")
}

Execute it, and then change the task creation part to this:

task test(type: TaskWithTwoFileCollectionInputs) {
    files1 = files("input1.txt")
    files2 = files("input2.txt", "input3.txt")
}

Obviously the purpose of input2.txt is now different, yet the task is detected as UP-TO-DATE during the next build.

The background of the problem is that Gradle considers all input files of a task as a single collection, erasing boundaries between different properties.



 Comments   
Comment by Lóránt Pintér [ 13/Apr/16 ]

Similarly, when a directory is move between two @OutputDirectories properties, the task is considered up-to-date.

Comment by Lóránt Pintér [ 13/May/16 ]

Added some tests for this bug: https://github.com/gradle/gradle/blob/bf4d314fe053eb48600cda0f1152aa63e9da8bac/subprojects/core/src/integTest/groovy/org/gradle/api/tasks/TaskInputPropertiesIntegrationTest.groovy#L63-L155

Generated at Wed Jun 30 12:48:46 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.