In a Java project I use Immutables library which generates source code via annotation processing (AP). When Eclipse is configured with AP, it generates the code into a separate folder (e.g. .apt_generated). Everything works correctly, but Bndtools warns that this folder is not set as a source path for bnd:
Bndtools: Found source folder '.apt_generated' that is not on bnd's source path 'src'
So I modify the bnd.bnd file:
and the warning is gone, and my generated sources land in bundle's OSGI-OPT/src.
However, when now I switch to the console and do a Gradle build, the bnd gradle plugin also passes the information about source files found .apt_generated to javac. Due to seeing the same classfile — once via compilation in .apt_generated, and secondly in effect of applying application processing of source files in src folder, the javac complains:
:annotation.processing.example:compileJava
/home/jest/work/eclipses-ws/apt_generated_bug/annotation.processing.example/bin/annotation/processing/example/ImmutableSampleInterface.java:14: error: duplicate class: annotation.processing.example.ImmutableSampleInterface
public final class ImmutableSampleInterface implements SampleInterface {
^
1 error
:annotation.processing.example:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':annotation.processing.example:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
My question is, how do I configure the thing to achieve:
- compilation from Gradle
- compilation from Eclipse
- sources of annotation processing results in OSGI-OPT/src
- no warning in Bndtools about source path not being added to bnd
From my perspective, it is the Gradle plugin that should be blamed (or instructed better), since bnd itself doesn't compile anything, just copies source folders' contents into OSGI-OPT/src.
Regards,
Przemek