[MNG-11642] Add JPMS module support to Maven 4#12135
Draft
gnodet wants to merge 1 commit into
Draft
Conversation
Contributor
|
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? |
Contributor
Author
|
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>
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.
Summary
module-info.javato 17 modules (11 API + 6 impl) with properrequires,exports,uses, andprovidesdirectivesAutomatic-Module-Namemanifest entries to all 17 remaining modules (4 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 (17)Impl (4):
maven-core,maven-cli,maven-executor,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 supportUnrelated fix
children()→childElements()(pre-existing on master after domtrip bump to 1.5.1)Test 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 17 remaining module JARs🤖 Generated with Claude Code