Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Up-to-date checks for missing files can be incorrect #6592

Closed
gavra0 opened this issue Sep 1, 2018 · 1 comment
Closed

Up-to-date checks for missing files can be incorrect #6592

gavra0 opened this issue Sep 1, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@gavra0
Copy link
Contributor

gavra0 commented Sep 1, 2018

A missing directory that is part of inputs to snapshot can cause issues with the up-to-date checks.

When a missing directory is input for two different tasks, during the first run, snapshot will be evaluated to FileSystemSnapshot.EMPTY for both tasks.

However, in the second run, the 1st task that runs will add the directory snapshot to the FileSystemMirror, and it won't invoke FileSystemMirror.clear() as the task does not run (it is up-to-date). The second task in the second run will get the snapshot information and if there are no patterns set for the directory tree, the PhysicalMissingSnapshot will be used for snapshotting. This is causing the 2nd run of the 2nd task to see a new file in the input.

Here is the build file that reproduces the issue. Running ./gradlew mytask && ./gradlew mytask will execute mytask in both runs. It should mark it as up-to-date in the second run:

File content = new File("content")
content.mkdir()
new File(content, "readme").createNewFile()

FileTree fst = project.fileTree(content)
FileTree snd = project.fileTree(new File("doesNotExist"))
FileTree fc = project.files(snd, fst).getAsFileTree()

def bef = tasks.create("beforeTask", MyTask) {
    source = fc
    outDir = new File(project.buildDir, "beforeTask")
}

tasks.create("mytask", MyTask) {
    source = fc
    outDir = new File(project.buildDir, "mytask")
}.dependsOn(bef)

class MyTask extends DefaultTask {
    @InputFiles FileTree source
    @OutputDirectory File outDir

    @TaskAction
    void doStuff() {}
}
@wolfs
Copy link
Member

wolfs commented Sep 6, 2018

Fixed via #6650. The fix will be included in 4.10.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants