Reputation: 572
Gradlew newb here, trying to figure out why when I invoke my task it's missing it's expected sources. I was under the impression that the tasks are executing in the correct order based on gradle explodeJars --info
$ gradle explodeJars --info
...
:copyJarsOver (Thread[main,5,main]) completed. Took 0.051 secs.
:explodeJars (Thread[main,5,main]) started.
:explodeJars
Skipping task ':explodeJars' as it has no source files.
:explodeJars UP-TO-DATE
:explodeJars (Thread[main,5,main]) completed. Took 0.0 secs.
The tasks in question:
task copyJarsOver(type: Copy, dependsOn: ["buildAll"]) {
from 'some/folder/cool.jar'
from 'another/folder/fancy.jar'
from 'best/folder/awesome.jar'
into 'build/modules'
rename { String fileName ->
fileName.replace('.jar', '.zip')
}
}
// Explodejars doesn't work when first ran, works second time <?>
task explodeJars(type: Copy, dependsOn: ["copyJarsOver"]) {
fileTree(dir: 'build/modules').each({ zipModule ->
def module = zipTree(zipModule)
from module
})
into 'build/explodedJars'
}
explodeJars.mustRunAfter copyJarsOver
Upvotes: 1
Views: 344
Reputation: 572
Ok so I got confused about the life-cycle of the tasks...
Code inside the task gets executed at configuration time - at which point the files haven't been copied to the folder yet. If I wanted it ran at execution time I should've put it in a doLast.
Either way, from accepts a closure like: from { fileTree(...).collect { zipModule -> zipTree(zipModule) } }
Upvotes: 1