swagger-api / swagger-api/swagger-codegen

[Java] Maven Javadoc Error while building the generated code with Java 11

Open
#10,421 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I am using Java 11.0.3 with swagger-codegen-cli:3.0.18 and org.hidetake:gradle-swagger-generator-plugin:2.18.2 to build Java Retofit2 based API Client on Ubuntu. The code gets generated without any issue. But when I try to build the generated code using mvn clean package I get this error.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:04 min
[INFO] Finished at: 2020-08-04T12:52:58+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.4:jar (attach-javadocs) on project client: MavenReportException: Error while generating Javadoc: 
[ERROR] Exit code: 1 - javadoc: error - The code being documented uses modules but the packages defined in http://docs.oracle.com/javase/8/docs/api/ are in the unnamed module.
[ERROR] 
[ERROR] Command line was: /usr/lib/jvm/java-11-openjdk-amd64/bin/javadoc @options @packages
[ERROR] 
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

After googling, it seems that this is a bug in JDK but following workarounds are possible.

  • Switch Java version to Java 8, the generated code builds successfully.
  • To use Java 11, manually edit the pom.xml and change the version of org.apache.maven.plugins:maven-javadoc-plugin:2.10.4 to 3.2.0 to build it successfully.

Since it is not feasible to change to java 8 programmatically just for building this, I'm expecting that the javadoc version is updated in the template files itself.

Related issues/PRs
Suggest a fix/enhancement

Changing the version to 3.2.0 in the template file will solve this issue.

https://github.com/swagger-api/swagger-codegen/blob/4607a90d7b69463a0ae8fc94fac68fc95d80965e/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache#L149

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache at the referenced line and inspect the generated Maven configuration. Compare the current Javadoc plugin version with the reported Java 11 workaround, then build generated Retrofit2 client code with Java 11 and confirm that the Javadoc step completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.