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

**URL:** <https://discuss.gradle.org/t/mixing-input-and-outputfile-in-one-task-field-with-gradle-6/35050>\
**Category:** Help/Discuss\
**Created:** [February 26, 2020, 10:21am UTC](https://discuss.gradle.org/t/mixing-input-and-outputfile-in-one-task-field-with-gradle-6/35050 "2020-02-26T10:21:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcin](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/marcin/32/1870_2.png) [@Marcin](https://discuss.gradle.org/u/Marcin)\
**Post date:** [February 26, 2020, 10:21am UTC](https://discuss.gradle.org/t/mixing-input-and-outputfile-in-one-task-field-with-gradle-6/35050/1 "2020-02-26T10:21:22Z")

</div>

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

```gradle
@CompileStatic
class PitestTask extends JavaExec {

    @Input
    @OutputFile
    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:

```gradle
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?

---

<div class="post-metadata">

**Author:** ![Stefan\_Wolf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/stefan_wolf/32/5519_2.png) [@Stefan\_Wolf](https://discuss.gradle.org/u/Stefan_Wolf)\
**Post date:** [February 26, 2020, 12:33pm UTC](https://discuss.gradle.org/t/mixing-input-and-outputfile-in-one-task-field-with-gradle-6/35050/2 "2020-02-26T12:33:45Z")

</div>

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.

Cheers,  
Stefan

---

<div class="post-metadata">

**Author:** ![Marcin](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/marcin/32/1870_2.png) [@Marcin](https://discuss.gradle.org/u/Marcin)\
**Post date:** [February 26, 2020, 12:47pm UTC](https://discuss.gradle.org/t/mixing-input-and-outputfile-in-one-task-field-with-gradle-6/35050/3 "2020-02-26T12:47:49Z")

</div>

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)?
