Input and Output annotations to work for tasks implemented in Java

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.

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

What did you try?

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.

I think I found a bug in Gradle. Please take a look at my test project:

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

I would like to bring some attention to this issue.

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.

I’ve raised GRADLE-2856 for this.