fix: Enable javadoc generation for modules with OSGi metadata#705
Merged
tzolov merged 1 commit intomodelcontextprotocol:mainfrom Dec 15, 2025
Merged
Conversation
**Problem:** The javadoc JARs published to Maven Central for `mcp-core` and other modules contain no HTML documentation (only `META-INF` directory structure). This prevents javadoc.io from automatically displaying API documentation for these modules. **Root cause:** The `bnd-maven-plugin` adds an `Automatic-Module-Name` entry to the JAR manifest for OSGi compatibility. When `maven-javadoc-plugin` detects this manifest entry, it switches from traditional classpath mode to JPMS (Java Platform Module System) module mode. In module mode, javadoc uses different command-line arguments (`--module-path` and `--patch-module` instead of `-sourcepath`), which fail to generate HTML output for automatic modules. **Considered solutions:** 1. Remove `Automatic-Module-Name` from the manifest - Fixes javadoc generation - Current module name already invalid for JPMS (contains dash, see modelcontextprotocol#560) - Would not break working JPMS usage (already broken) - Removes future option to support JPMS once module name is fixed 2. Add `legacyMode=true` to `maven-javadoc-plugin` - Forces pre-Java 9 classpath-based javadoc generation instead of module mode - No changes to manifest (preserves invalid module name as-is) - Maven documentation recommends `legacyMode` when automatic module detection causes build issues - Used by other projects with automatic modules (e.g., Apache Avro PR 3041) **Implementation:** - Upgraded `maven-javadoc-plugin` from `3.5.0` to `3.11.2` (`legacyMode` added in `3.6.0`) - Added `<legacyMode>true</legacyMode>` to force classpath-based generation Both solutions were tested in separate git worktrees using Docker-based Maven builds. Both produce identical javadoc output (`mcp-core`: 558 bytes → 1.4 MB, 474 HTML files). Solution 2 was chosen to avoid breaking changes. Fixes javadoc generation for `mcp-core` and other modules using `bnd-maven-plugin`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
tzolov
pushed a commit
that referenced
this pull request
Jan 8, 2026
fix: enable javadoc HTML generation by using legacyMode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DISCLAIMER: As part of an effort to publish API docs for all official MCP SDKs, I am trying to fix publishing of this SDK's Javadoc to javadoc.io. However, I am not a Java developer, and do not have a full understanding of the reason publishing is currently broken. This solution was written by Claude Code after a long conversation with me, but I am relying on the maintainers to judge whether it is a proper solution.
Problem:
The javadoc JARs published to Maven Central for
mcp-coreand other modules contain no HTML documentation (onlyMETA-INFdirectory structure). This prevents javadoc.io from automatically displaying API documentation for these modules.Root cause:
The
bnd-maven-pluginadds anAutomatic-Module-Nameentry to the JAR manifest for OSGi compatibility. Whenmaven-javadoc-plugindetects this manifest entry, it switches from traditional classpath mode to JPMS (Java Platform Module System) module mode. In module mode, javadoc uses different command-line arguments (--module-pathand--patch-moduleinstead of-sourcepath), which fail to generate HTML output for automatic modules.Considered solutions:
Remove
Automatic-Module-Namefrom the manifestAdd
legacyMode=truetomaven-javadoc-pluginlegacyModewhen automatic module detection causes build issuesImplementation:
maven-javadoc-pluginfrom3.5.0to3.11.2(legacyModeadded in3.6.0)<legacyMode>true</legacyMode>to force classpath-based generationBoth solutions were tested in separate git worktrees using Docker-based Maven builds. Both produce identical javadoc output (
mcp-core: 558 bytes → 1.4 MB, 474 HTML files). Solution 2 was chosen to avoid breaking changes.Fixes javadoc generation for
mcp-coreand other modules usingbnd-maven-plugin.🤖 Generated with Claude Code