Change @InputFiles in my plugin task in continuous build


I’m starting to play with gradle 2.5-RC1 to use continuous build. I don’t know if is possible to change @InputFiles while gradle is running in continuous mode. The files that I want to listen changes, can change during gradle execution, maybe new files have to be added. If I try to change inputs or outputs in a task, while task is being executed I get an error. Can I change inputs / outputs in my gradle task that extends org.gradle.api.DefaultTask?

Thank you!

Can you explain a bit more about what problem you are trying to solve here?

Yes sorry, I hope I can explain better. In my last tests, I don’t get error, but when I add files to source, that files are ignored. If I run this task with -t, only changes in original source files are detected. If I change ‘file.groovy’ nothing happens. Can I do something to change files that gradle is listen for changes?

class ConvertTask extends DefaultTask {
    List<File> source

    void convert() {
        println ' source: ' + source

And I have other problem. If I have a task that works great with -t, for example called ‘convert’. When I have other task, for example ‘runTomcat’ and I put runTomcat.dependsOn ‘convert’. If I run ‘runTomcat’ with -t, changes in ‘convert’ task are not detected. Can I use continuous build while running this ‘runTomcat’ task?

Thank you!

1 Like

Adding inputs during a @TaskAction won’t work. Why do you need to do this?

The reason that runTomcat doesn’t work is that it blocks the build, which prevents it from entering the ‘watch’ state. We are currently working on APIs that the tomcat plugin will be able to use to launch the server in a non blocking way. Unfortunately, this isn’t possible with 2.5.

I need that because in my plugin I need to listen more files that initial inputs. For example I listen a file ‘one.groovy’, but at some point someone add an import to ‘AnyClass.groovy’ in ‘one.groovy’. So I need listen ‘AnyClass.groovy’ to convert that file if something changes. It’s similar to any compilation process, but I don’t listen to a full folder with subfolders, just I need to listen to some specific files that change in time.

I think you can improve this continuous build, to work in background when other task is running watching changes. For example when I have a task that is running a server, would be nice to have other tasks in background compiling *.scss, compressing *.js, converting files,…

Thank you!

I’d recommend splitting this into discrete steps. The first would be to do whatever analysis you need to do to work the actual inputs (from the sounds of things, parsing ‘one.groovy’ for the imports) and output something that represents the real inputs. Then have the actual task that does work use this an an input and express the contents as input files.