I am trying to create a task in a plugin who’s inputs and outputs are specified by the individual build files. However, it seems that the getInputs and getOutputs method are called as part of apply, so before the extension object is populated by the project build file.
What I tried: Setting a variable on the extension object, and then overriding the getInputs method, having the first call to getInputs parse the value in extension object and add it to the base inputs object. This doesn’t work because (as mentioned) getInputs is called from the build before the extension object is set. (My task extends DefaultTask)
This would have to be possible, because (for example) you can change your inputs to the java compile task, but it doesn’t seem to be possible using the extension convention?
When playing around with the above, I also found this weird behavior: Overwriting the getOutputs method with the following signature: public TaskOutputsInternal getOutputs() gets the following: “The return type of org.gradle.api.internal.TaskOutputsInternal getOutputs() in test.package.CodeGenTask is incompatible with org.gradle.api.tasks.TaskOutputs getOutputs() in org.gradle.api.internal.AbstractTask”
And if I change the signature to: public TaskOutputs getOutputs() gets the following: “The return type of org.gradle.api.tasks.TaskOutputs in test.package.CodeGenTask is incompatible with org.gradle.api.internal.TaskOutputsInternal getOutputs() in org.gradle.api.internal.AbstractTask”
Since the getInputs()/getOutputs() this is kind of moot, but it does seem like undesired behavior (or at least an error message reporting the wrong thing).