# Input and Output annotations to work for tasks implemented in Java

**URL:** https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161
**Category:** Old Forum Archive
**Created:** [July 29, 2013, 9:52am UTC](https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161 "2013-07-29T09:52:00Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![green\_coder](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/green_coder/32/85_2.png) [@green\_coder](https://discuss.gradle.org/u/green_coder)
#### Post date: [July 29, 2013, 9:52am UTC](https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161/1 "2013-07-29T09:52:00Z")

</div>

It seems that it is not currently (v1.6) possible to use annotations like @OutputDirectory in Java classes (the annotations are ignored).

It would be nice to have this supported. At least, write it somewhere that it is only supported in Groovy - it took me 2 hours to figure out why it was not working.

---

<div class="post-metadata">

### Author: ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)
#### Post date: [July 29, 2013, 9:54am UTC](https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161/2 "2013-07-29T09:54:00Z")

</div>

It definitely is supported; many tasks are implemented in Java.

What did you try?

---

<div class="post-metadata">

### Author: ![green\_coder](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/green_coder/32/85_2.png) [@green\_coder](https://discuss.gradle.org/u/green_coder)
#### Post date: [July 29, 2013, 10:44am UTC](https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161/3 "2013-07-29T10:44:00Z")

</div>

I just took a look at the source files in Gradle, and the only difference I see with my Java file is that I was annotating public fields while Gradle is mostly using annotations on methods.

I will run a test tonight and post a link to a gist here.

---

<div class="post-metadata">

### Author: ![green\_coder](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/green_coder/32/85_2.png) [@green\_coder](https://discuss.gradle.org/u/green_coder)
#### Post date: [July 29, 2013, 12:34pm UTC](https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161/4 "2013-07-29T12:34:00Z")

</div>

I think I found a bug in Gradle. Please take a look at my test project: [https://github.com/green-coder/gradle-annotation-bug/blob/master/buildSrc/src/main/groovy/mypackage/MyTask.java](https://github.com/green-coder/gradle-annotation-bug/blob/master/buildSrc/src/main/groovy/mypackage/MyTask.java)

The annotations are ignored when applied on the fields of java classes.

---

<div class="post-metadata">

### Author: ![green\_coder](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/green_coder/32/85_2.png) [@green\_coder](https://discuss.gradle.org/u/green_coder)
#### Post date: [July 30, 2013, 5:24pm UTC](https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161/5 "2013-07-30T17:24:00Z")

</div>

I would like to bring some attention to this issue.

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [July 30, 2013, 5:46pm UTC](https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161/6 "2013-07-30T17:46:00Z")

</div>

I’m not sure if the bug is in the implementation or documentation (which says that annotations can also be placed on fields). For now, just put them on the getter methods. That’s what all of Gradle’s own tasks do.

---

<div class="post-metadata">

### Author: ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)
#### Post date: [August 2, 2013, 11:21am UTC](https://discuss.gradle.org/t/input-and-output-annotations-to-work-for-tasks-implemented-in-java/2161/7 "2013-08-02T11:21:00Z")

</div>

I’ve raised GRADLE-2856 for this.
