On 21/07/2011, at 8:22 AM, phil swenson wrote:
> I thought perhaps having the outputs hooked up would make a
> difference. So I modified my code to:
>
> @TaskAction
> public void generate() {
> assert convention: "convention cannot be null"
> FileTree inputFileTree = project.fileTree(dir:
> convention.localizationOutputPath, includes: ['LFW_*Messages-*.xml'])
> inputs.files(inputFileTree)
> FileTree outputFileTree = project.fileTree(dir:
> convention.localizationOutputPath, includes: ['*.properties'])
> outputs.files(outputFileTree)
> convention.supportedModes.each {ResourceMode mode ->
> new GenerateResources(project, convention).generateResources(mode)
> }
> }
>
> No difference. Every time I run the generate task, it runs the
> exportMessages task.
>
> There is something I just don't understand about how this works...
You are configuring this too late.
You need:
class MyTask extends DefaultTask {
MyTask() {
inputs.files { project.fileTree(dir: convention.localizationOutputPath,
includes: ['LFW_*Messages-*.xml']) }
outputs.files { project.fileTree(dir:
convention.localizationOutputPath, includes: ['*.properties']) }
}
@TaskAction
void generate() {
assert convention: "convention cannot be null"
convention.supportedModes.each {ResourceMode mode ->
new GenerateResources(project,
convention).generateResources(mode)
}
}
}
Gradle will interrogate the inputs before invoking the task action, so they
need to be specified before that. The use of closures allows the value to be
evaluated at the last possible minute.
Also, have a look at the annotations in org.gradle.api.tasks that start with
“Input” or “Output” for more declarative ways of modelling this stuff.
--
Luke Daley
Principal Engineer, Gradleware
http://gradleware.com
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email