Skip to content

Instantly share code, notes, and snippets.

@davidparsson
Last active January 4, 2016 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidparsson/8580251 to your computer and use it in GitHub Desktop.
Save davidparsson/8580251 to your computer and use it in GitHub Desktop.
Gradle bug: Moving file creation from processResources to a dependency will remove the generated file
apply plugin: 'java'
task(copyInput, type: Copy) {
from 'input.txt'
into "${sourceSets.main.output.resourcesDir}"
}
processResources {
//dependsOn copyInput // Enable this line after first execution
from 'input.txt' // Disable this line after first execution
from 'anotherInput.txt'
}
$ gradle clean processResources
:clean
:processResources
BUILD SUCCESSFUL
Total time: 2.119 secs
$ ls build/resources/main/input.txt
build/resources/main/input.txt
$ # Modify build.gradle here, by enabling line 9 and disabling line 10.
$ gradle clean processResources
:clean
:copyInput
:processResources
BUILD SUCCESSFUL
Total time: 2.895 secs
$ ls build/resources/main/input.txt
ls: build/resources/main/input.txt: No such file or directory
$ # File should exist!
$ gradle clean processResources
:clean
:copyInput
:processResources
BUILD SUCCESSFUL
Total time: 2.036 secs
$ ls build/resources/main/input.txt
build/resources/main/input.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment