[MNG-11642] Add JPMS module support to Maven 4#12135
Conversation
|
Thanks. There are a lot of export, for example in this implementation module. Are all these exported packages public API? If not, are there some exports that we could omit, or restrict to qualified exports? |
|
Claude Code on behalf of Guillaume Nodet Good point. None of the maven-impl:
Other impl modules:
Left unchanged:
Since all consumers currently use |
Add explicit module-info.java to 17 modules (11 API + 6 impl) and Automatic-Module-Name manifest entries to all 17 remaining modules. Only org.apache.maven.api.* packages are public API. All implementation packages use qualified exports restricted to internal consumers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
left a comment
There was a problem hiding this comment.
Self-review notes — the JPMS module support looks correctly implemented across all 34 modules. All 17 module-info.java module names are consistent with their POM javaModuleName properties, the qualified exports in maven-impl properly restrict internal packages, and the build infrastructure changes (javadoc exclusions, legacyMode, annotationProcessorPaths, useModulePath=false) are appropriate.
Minor items to fix in the PR description
-
PR body mentions
maven-executor— Under "Modules with Automatic-Module-Name only", the description lists "Impl (4):maven-core,maven-cli,maven-executor,maven-testing". There are actually 3 impl modules in this category —maven-executordoes not exist in the project's module structure. -
Unrelated fix not in diff — The PR body mentions "AbstractUpgradeGoal: Fixed domtrip API change
children()→childElements()" under "Unrelated fix", but this change does not appear in the diff. It may have been dropped during a rebase.
Neither of these affects the code — only the PR description text.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Summary
module-info.javato 17 modules (11 API + 6 impl) with properrequires,exports,uses, andprovidesdirectivesAutomatic-Module-Namemanifest entries to all 16 remaining modules (3 impl + 13 compat) viamaven-jar-pluginconfiguration in root POMorg.apache.maven.api.*is public API--add-exportsfor plexus-interpolation)DefaultModelProcessorandDefaultModelBuilderDetails
Modules with
module-info.java(17)API modules (11):
maven-api-annotations,maven-api-di,maven-api-xml,maven-api-metadata,maven-api-model,maven-api-settings,maven-api-toolchain,maven-api-plugin,maven-api-core,maven-api-spi,maven-api-cliImpl modules (6):
maven-di,maven-xml,maven-support,maven-impl(open module),maven-jline,maven-loggingModules with
Automatic-Module-Nameonly (16)Impl (3):
maven-core,maven-cli,maven-testing— cannot usemodule-info.javadue to split packages with compat modules or complex DI/compat dependenciesCompat (13): All compat modules — split packages among themselves prevent named module status
Qualified exports for non-API packages
Only
org.apache.maven.api.*packages are Maven 4's public API. All implementation packages use qualified exports restricted to internal consumers:org.apache.maven.impl.*exports qualified tomaven-core,maven-cli,maven-testing,maven-compat,maven-embedder. Removed unusedorg.apache.maven.impl.model.profile. Onlyorg.apache.maven.api.services.modelremains unqualified (it's an API package).org.apache.maven.di.implqualified to internal consumers (keptorg.apache.maven.diunqualified as DI API)org.apache.maven.slf4jqualified tomaven-cling,maven-embedder,maven-coreorg.apache.maven.jlinequalified tomaven-logging,maven-cling,maven-embedderSince all consumers currently compile in classpath mode (no
module-info.java), the qualified exports serve as documentation of intent and will be enforced when those modules gain module descriptors.Build infrastructure changes
maven-jar-pluginin<pluginManagement>setsAutomatic-Module-Namefrom${javaModuleName}propertymaven-javadoc-pluginconfigured withsourceFileExcludesformodule-info.javato prevent javadoc tool from switching to modular modelegacyMode=truefor aggregate javadoc — forces classpath mode to avoid "named and unnamed modules" conflict--add-exports=org.codehaus.plexus.interpolation/org.codehaus.plexus.interpolation.utilfor javadoc — plexus-interpolation 1.29 does not export the.utilpackage in its module descriptorannotationProcessorPathsforDiIndexProcessor— required when compiling with module-info.java since the processor is no longer on the classpathuseModulePath=falsein surefire to preserve existing test behavior on the classpathBug fixes included
nullfor@Nullablecollections when no providers exist; added null-safe defaults (Map.of()/List.of())ProjectBuildLogAppendercreation to occur before terminal initializationrequires static org.jline.terminal.ffm— the FFM terminal provider is discovered via ServiceLoader at runtime, and therequires staticdirective fails compilation on Java 17 CI where the module doesn't existNotable design decisions
maven-implis anopen modulebecause Maven's DI framework needs reflective access to instantiate componentsmaven-cliusesAutomatic-Module-Nameinstead ofmodule-info.javadue to split packages with compat modules it depends on (e.g.,org.apache.maven.settingsin bothmaven-settingsandmaven-core)requires transitivefor inter-API dependencies since API types leak across module boundariesmaven-api-modeldeclaresuses ModelObjectProcessorfor ServiceLoader supportmaven-impldeclaresuses RootDetectorfor ServiceLoader supportTest plan
mvn verify -B— all modules compile and tests passmvn site -Preporting) passjar --describe-moduleshows correct module descriptors for all 17 module-info modulesAutomatic-Module-Namemanifest entries present in all 16 remaining module JARs🤖 Generated with Claude Code