gradle-one-jar icon indicating copy to clipboard operation
gradle-one-jar copied to clipboard

gradle outputs.files includes ghost file

Open dirkraft opened this issue 10 years ago • 1 comments

Small thing. Not sure what the gradle-recommended behavior is here.

task oneJar(type: OneJar) {
    doLast {
        outputs.files.forEach{
            printf('exists: %s, path: %s%n', it.exists(), it.absolutePath)
        }
    }
}

includes an ephemeral file

exists: false, path: /home/user/myproj/build/libs/standalone.jar
exists: true, path: /home/user/myproj/build/libs/myproj-0.0.1-SNAPSHOT-standalone.jar

which can muck up dependent gradle build scripts a little, since I would like to assume that there is only one OneJar output. So right now I have to filter out the temporary file to get the singleFile that I am expecting.

outputs.files.filter{ it.exists() }.singleFile

Might be nothing. The last line isn't a huge deal, but might be problematic down the road for other build scripts if they reference oneJar.outputs which includes a reference to a non-existent file.

dirkraft avatar Dec 23 '14 15:12 dirkraft

That is annoying. I wouldn't expect that ghost file to be in the outputs.files.

rholder avatar Dec 24 '14 19:12 rholder