I'm using the Micronaut OpenAPI module and facing an issue that the default openapi.properties is not correctly processed in IntelliJ. Doing the compilation on the command line works. When analyzing the annotation module I found that it is looking in the IntelliJ related directory C:\Users\<username>\AppData\Local\JetBrains\IntelliJIdea2020.1\compile-server directory for it, where it is obviously not found. This prevents to use the configuration options from the openapi.properties. It seems to be not possible to configure IntelliJ to use the project directory as working directory for the annotation processor.

1

There are 1 answers

0
k_o_ On BEST ANSWER

Micronaut offers the system property configuration option micronaut.openapi.config.file. This can be passed to the annotation processor as system variable using the pom.xml file. IntelliJ will pick up this.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <annotationProcessorPaths>
       ...
       <path>
         <groupId>io.micronaut.configuration</groupId>
          <artifactId>micronaut-openapi</artifactId>
          <version>use most recent version</version>
       </path>
  </annotationProcessorPaths>
  <compilerArgs>
    ...
    <arg>-Amicronaut.openapi.config.file=${project.basedir}/openapi.properties</arg>
    ...
  </compilerArgs>
  ...

For a Gradle based project a similar mechanism should be possible.