swagger-api / swagger-api/swagger-codegen
[Java] Maven Javadoc Error while building the generated code with Java 11
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.4to3.2.0to 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
- https://github.com/swagger-api/swagger-codegen/pull/10041 - This PR is outdated but addresses the issue
- https://github.com/swagger-api/swagger-codegen/issues/8959 - This is similar but 2 years ago
Suggest a fix/enhancement
Changing the version to 3.2.0 in the template file will solve this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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