How to submit FileCollection to WorkerExecutor?

I’m trying to pass an instance of an object with a FileCollection property to the WorkerConfiguration parameters. Unfortunately I get following error Could not serialize parameters. The object itself implements Serializable, however FileCollection does not. If I remove the FileCollection property everything works fine.

I attached a small example below:

class Test implements Serializable {
    String id

    FileCollection target
}

class TestTask extends DefaultTask {
    def workerExecutor

    def tests = []

    @Inject
    FileEncodingTask(WorkerExecutor workerExecutor) {
        this.workerExecutor = workerExecutor
    }

    @TaskAction
    def action() {
        this.tests.each { test ->
            this.workerExecutor.submit(TestThread.class) { WorkerConfiguration conf -> // TestThread implements Runnable
                conf.isolationMode = IsolationMode.NONE
                conf.params = [test]
            }
        }
    }
}

How can I pass the object with FileCollection to params? What I’m missing?

@padme-amidala Did you find a way to solve this? I’m currently struggeling with the same problem.

I used the files() method on the FileCollection to send a Set<File> across. It works, but it is not optimal as it assumes the worker will deal with all of the files.

If you might only want to deal with a subset of the files, then maybe it is better to send a File and a PatternSet (or colelction of patterns) across and reconstruct the FileCollection in the Runable imlemention class.