Can inputs and outputs use wildcards


(Ari Maniatis) #1

I have a task which I’d like to reuse in a few child modules within a project. All works well, but inputs and outputs are tricky. One project generates output of foo.exe and another project generates bar.exe.

I tried

outputs.files ".exe

but that doesn’t seem to work right. I guess gradle doesn’t know which files are missing if it doesn’t know while files to look for.

I tried

outputs.files “foo.exe”, “bar.exe”

But that doesn’t seem right, since there will always be something missing in each project.

If there a better solution to this? Do I need to resort to turning this task into a plugin and then passing to it the appropriate outputs?


(Peter Niederwieser) #2

The way to do this is to declare a property in the task (class) that holds the file to be generated, and then pass that property to ouputs.files (or annotate it with @OutputFile). I recommend to have a look at the plugins in the Gradle codebase; you can browse their code on GitHub.


(Ari Maniatis) #3

OK thanks. I’ll turn this code into a plugin and it should be easy enough to do. I’ve written one fairly complex plugin already, so I think I know how to proceed now.