Home > Mobile >  Confusing error state in Maven (Eclipse / Mojo) with Code Generation (OpenAPI 5.3) and Custom Templa
Confusing error state in Maven (Eclipse / Mojo) with Code Generation (OpenAPI 5.3) and Custom Templa

Time:12-28

Was working on a simple code generation project in Eclipse (2021-03) with OpenAPI 5.3.0 and getting custom templates working. Snippet of the corresponding POM file :

<plugin>
   <groupId>org.openapitools</groupId>
   <artifactId>openapi-generator-maven-plugin</artifactId>
   <version>5.3.0</version>
...
<executions>
   <execution>
      <goals><goal>generate</goal></goals>
      <configuration>
...
          <templateResourcePath>./src/main/resources/myTemplates</templateResourcePath>
...

This works, in the sense that Run > Maven Generate Sources or Run > Maven Install correctly executes the code gen and picks up the custom template changes I want to incorporate, but the IDE insists that this is broken. I get the red-X mark on the project and the POM file, on the "execution" line with the generic claim "Code Generation Failed". Even though it doesn't fail. (its the same error as when you do have an issue in the YAML and something does fail for real).

I want to resolve the error but, as there isn't an error in code generation, I don't know how.

CodePudding user response:

Turns out, while the path I used in <templateResourcePath> succeeds, that representation isn't right.

Using this instead : <templateResourcePath>${project.basedir}/src/main/resources/myTemplates</templateResourcePath>

Both resolves the error flag and keeps the custom templates working.

  • Related