Annotation processors are easy to use with bld. Generally, you'll just need to include processor as a dependency, for example:
public class ExampleBuild extends Project {
public ExampleBuild() {
// ...
scope(provided)
.include(dependency("com.example", "annotator", version(1, 0, 0)));
}
}
If the processor is generating source files, you can easily specify where they should be saved, using the -s javac option, for example:
/**
* Saves generated source files in the {@code build/generated} directory.
*/
@Override
public void compile() throws Exception {
var generated = new File(buildDirectory(), "generated");
var ignore = generated.mkdir();
compileOperation().compileOptions().addAll(List.of("-s", generated.getAbsolutePath()));
super.compile();
}
To incorporate the generated source code into the source tree, add this directory as an additional source location in your IDE.
Screenshot from 2023-08-20 21-27-10.png