Mixing @Input and @OutputFile in one task field with Gradle 6+

In my pitest-gradle-plugin I have additionalClasspathFile file in a task:

class PitestTask extends JavaExec {

    File additionalClasspathFile //RegularFileProperty after migration

It seems perfectly valid from the “business logic” point of view. additionalClasspathFile as @Input points out that name (location) is important as an input (not its content) and as @OutputFile is needed to tell others that my task - during execution - put there generated content (so it is output).

It generates deprecation warnings in Gradle 6:

Property 'additionalClasspathFile' has conflicting type annotations declared: @Input, @OutputFile; assuming @Input. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.

As the last resort I could divide it into two files, but it just for technical reasons. Is that a known limitation of Gradle that I have to deal with or there is any better way to handle that with just one field?

Hi Marcin,

what do you need the location of additionalClasspathFile apart from to know where you want to produce the generated file? Since that is what @OutputFile already tracks. If you change the location, then the task will re-run since there isn’t a file at the new location. That is why @Input is not allowed.


Thanks Stefan for your reply.

There could be some other task which consumes that file and depends on the first task execution.

However, if I understood you correctly, if Task A changes content of a file ("${buildDir}/xxx") and Task B has that file (its location) set as @Input (and Task B depends on Task A), would it (Task B) be marked as dirty due to the content of that file change (without the need to mark that file as @OutputFile in Task A)?