Quarkus runtime recompilation fails due to custom annotation processor

49 Views Asked by At

Quarkus runtime automatic recompilation on source code modification fails due to a custom annotation processor. When we modify the source code during runtime and call a service, we get the following error in application logs and have to restart the application :

Compilation Failed:
Note: Annotation processing is enabled because one or more processors were found
  on the class path. A future release of javac may disable annotation processing
  unless at least one processor is specified by name (-processor), or a search
  path is specified (--processor-path, --processor-module-path), or annotation
  processing is enabled explicitly (-proc:only, -proc:full).
  Use -Xlint:-options to suppress this message.
  Use -proc:none to disable annotation processing.
error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: mycompany.package.processors.MyProcessor Unable to get public no-arg constructor

We configured the annotation processor in Maven by importing it from another module of the project :

<dependencies>
    [...]
    
    <dependency>
        <groupId>mycompany.package</groupId>
        <artifactId>processors</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <compilerArgs>
                    <arg>-parameters</arg>
                </compilerArgs>
                <generatedSourcesDirectory>
                    ${project.build.directory}/generated-sources/
                </generatedSourcesDirectory>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>1.18.30</version>
                    </path>
                    <path>
                        <groupId>mycompany.package</groupId>
                        <artifactId>processors</artifactId>
                        <version>${project.parent.version}</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>

We used google Autoservice annotation to register the annotation processor :

@SupportedAnnotationTypes(
    "mycompany.package.annotations.MyAnnotation"
)
@SupportedSourceVersion(SourceVersion.RELEASE_8)
@AutoService(Processor.class)
public class MyProcessor extends AbstractProcessor {

    public MyProcessor() {
        // empty
    }

    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        // [...]
    }
}

The original maven build completes and the application runs perfectly well as long as we do not modify the code during runtime. However, our team would like to make the quarkus automatic recompilation work, without removing our custom annotation processor if possible.

0

There are 0 best solutions below