Modern Gradle does not discover annotation processors by default. The 3rd-party low-code solution we use calls Gradle internally and to compile our java classes and we want it to discover the annotation processor in a jar with known path.
Unfortunately, build.gradle
is generated and we can't make changes to it, but we can set environment variables and java system properties.
The generated build.gradle
calls JavaCompile
with some options, but it does not allow custom options.
I was hoping there's some environment variable like JAVA_TOOL_OPTIONS
, but recognized by javac
. Or a system property, something like javax.annotation.processing.ProcessorPath
. Or a gradle variable like ORG_GRADLE_PROJECT_compile_annotationProcessorPath
. Or hook objectFactory.newInstance(CompileOptions.class)
The generated task looks like this:
tasks.register("compile", JavaCompile) {
source = ...
classpath = ...
destinationDirectory.set(...)
}