apache / apache/maven-javadoc-plugin

[MJAVADOC-698] javadoc:javadoc fails for non-JPMS mojo

Open
#1,077 1 comment 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
107
Forks
116
Avg merge
1d 10h
Merged PRs (30d)
16

Description

**[Gili](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=cowwoc)** opened **[MJAVADOC-698](https://issues.apache.org/jira/browse/MJAVADOC-698?redirect=false)** and commented

I upgraded maven-javadoc-plugin from version 3.2.0 to 3.3.1. At the same time, I upgraded from JDK 11 to 17. All of a sudden I am getting the following build failure I was not getting before:

```java
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.3.1:jar (attach-javadocs) on project maven_plugin: MavenReportException: Error while generating Javadoc: 
[ERROR] Exit code: 1 - Loading source file C:\Users\Gili\Documents\requirements.java\maven_plugin\src\main\java\com\github\cowwoc\requirements\maven\AbstractGeneratorMojo.java...
[ERROR] Loading source file C:\Users\Gili\Documents\requirements.java\maven_plugin\src\main\java\com\github\cowwoc\requirements\maven\GenerateApiMojo.java...
[ERROR] Loading source file C:\Users\Gili\Documents\requirements.java\maven_plugin\src\main\java\com\github\cowwoc\requirements\maven\OptimizeExceptionsMojo.java...
[ERROR] Loading source file C:\Users\Gili\Documents\requirements.java\maven_plugin\src\main\java\com\github\cowwoc\requirements\maven\package-info.java...
[ERROR] Loading source file C:\Users\Gili\Documents\requirements.java\maven_plugin\src\main\java\com\github\cowwoc\requirements\maven\UnpackMojo.java...
[ERROR] Loading source file C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java...
[ERROR] Loading source files for package com.github.cowwoc.requirements.maven...
[ERROR] Constructing Javadoc information...
[ERROR] C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java:8: error: package org.w3c.dom is not visible
[ERROR] import org.w3c.dom.Document;
[ERROR]               ^
[ERROR]   (package org.w3c.dom is declared in module java.xml, but module com.github.cowwoc.requirements.maven_plugin does not read it)
[ERROR] C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java:9: error: package org.w3c.dom is not visible
[ERROR] import org.w3c.dom.Element;
[ERROR]               ^
[ERROR]   (package org.w3c.dom is declared in module java.xml, but module com.github.cowwoc.requirements.maven_plugin does not read it)
[ERROR] C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java:10: error: package org.w3c.dom is not visible
[ERROR] import org.w3c.dom.Node;
[ERROR]               ^
[ERROR]   (package org.w3c.dom is declared in module java.xml, but module com.github.cowwoc.requirements.maven_plugin does not read it)
[ERROR] C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java:11: error: package org.w3c.dom is not visible
[ERROR] import org.w3c.dom.NodeList;
[ERROR]               ^
[ERROR]   (package org.w3c.dom is declared in module java.xml, but module com.github.cowwoc.requirements.maven_plugin does not read it)
[ERROR] C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java:12: error: package org.xml.sax is not visible
[ERROR] import org.xml.sax.SAXException;
[ERROR]               ^
[ERROR]   (package org.xml.sax is declared in module java.xml, but module com.github.cowwoc.requirements.maven_plugin does not read it)
[ERROR] C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java:14: error: package javax.xml.parsers is not visible
[ERROR] import javax.xml.parsers.DocumentBuilder;
[ERROR]                 ^
[ERROR]   (package javax.xml.parsers is declared in module java.xml, but module com.github.cowwoc.requirements.maven_plugin does not read it)
[ERROR] C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java:15: error: package javax.xml.parsers is not visible
[ERROR] import javax.xml.parsers.DocumentBuilderFactory;
[ERROR]                 ^
[ERROR]   (package javax.xml.parsers is declared in module java.xml, but module com.github.cowwoc.requirements.maven_plugin does not read it)
[ERROR] C:\Users\Gili\Documents\requirements.java\maven_plugin\target\generated-sources\plugin\com\github\cowwoc\requirements\maven\HelpMojo.java:16: error: package javax.xml.parsers is not visible
[ERROR] import javax.xml.parsers.ParserConfigurationException;
[ERROR]                 ^
[ERROR]   (package javax.xml.parsers is declared in module java.xml, but module com.github.cowwoc.requirements.maven_plugin does not read it)
[ERROR] 8 errors
[ERROR] 
[ERROR] Command line was: cmd.exe /X /C "C:\Users\Gili\.jdks\openjdk-17.0.1\bin\javadoc.exe @options @packages @argfile"
[ERROR] 
[ERROR] Refer to the generated Javadoc files in 'C:\Users\Gili\Documents\requirements.java\maven_plugin\target\apidocs' dir.
[ERROR] 
[ERROR] -> [Help 1]
```

The Mojo in question did not change at all. It is not a Java Module so I don't understand why the Javadoc engine is treating it as such. I would be more than happy to upgrade the Mojo to a Java Module but at last check this isn't technically possible (I get `Error: the unnamed module reads package org.apache.maven.plugin from both maven.core and maven.plugin.api`).

Any ideas?

---

**Affects:** 3.3.1

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the javadoc:javadoc failure on JDK 17 with the non-JPMS Mojo and inspect the generated HelpMojo.java imports shown in the report. Compare how the plugin handles module visibility for non-modular projects; done means Javadoc generation succeeds without the reported java.xml visibility errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.