Compile the files generated by the annotation processor in your own test project with Gradle

I have a Gradle project in which I am defining an annotation processor. When using the processor in other projects down the line, this works great.

However, I want to unit test the processor, so I have some test code that uses the processor. The processor works fine in test code without the need to configure anything, but unlike other projects, the generated code does not compile.

For clarification, this looks like my project (after being called gradle clean test

):

src
|- main
  |- java
    |- my.package.Processor
  |- resources
    |- META-INF/javax.annotation.processing.Processor
|- test
  |- java
    |- my.package.ClassWithAnnotationToBeProcessed.java
    |- my.package.TheUnitTest.java
build
|- main
|- test
  |- my.package.GeneratedFile.java // missing .class file!
build.gradle

      

+3


source to share





All Articles