Skip to content

feat: internalize plexus-classworlds (fixes #11028) - #13490

Merged
gnodet merged 14 commits into
apache:masterfrom
gnodet:feature/maven-internalize-classworlds
Oct 23, 2026
Merged

gnodet merged 14 commits into
apache:masterfrom
gnodet:feature/maven-internalize-classworlds

Conversation

@gnodet

@gnodet gnodet commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Internalizes plexus-classworlds as impl/maven-classworlds, replacing the external dependency with an in-tree module.

Per review feedback from @rmannibucau, the public API module (api/maven-api-classworlds) has been removed — the codebase uses the implementation types directly. A stable API can be designed and introduced in a follow-up once the internalization has settled.

This is a prerequisite for:

Changes

New module

  • impl/maven-classworlds — fork of plexus-classworlds with the org.codehaus.plexus.classworlds implementation, backward-compat adapters under org.codehaus.classworlds, and new capabilities:
    • module directive in m2.conf — loads JARs on the JPMS module-path in a child ModuleLayer (enables targeted --enable-native-access)
    • META-INF/maven/module-access descriptor — classpath plugins can declare add-exports/add-opens/add-reads against named modules declaratively

Across the codebase

  • Replace external plexus-classworlds dependency with maven-classworlds across all modules
  • Remove classWorldsVersion property from root pom.xml

Scope

This PR intentionally excludes:

  • mvn, mvn.cmd, m2.conf changes (PR B — JLine on module-path)
  • createModularPluginRealm, <modular>true</modular>, ModuleLayerCreationException (PR C — per-plugin modular realms)
  • Public API surface for classworlds (deferred per review feedback)

Note on org.codehaus.classworlds compat package

The org.codehaus.classworlds backward-compat package is intentionally kept in impl/maven-classworlds for now. Dropping it requires that eclipse-sisu/sisu-project#280 be merged first — three classes in org.eclipse.sisu.plexus still hold compiled references to the legacy package. Once that Sisu PR lands and a new Sisu release is available, the compat layer can be removed.

Testing

impl/maven-classworlds and impl/maven-core compile and the classworlds unit tests pass.

Note: impl/maven-cli has pre-existing compilation issues from master changes not yet integrated into this branch; they will resolve on rebase.

Supersedes #11029

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three issues worth fixing: a missing artifact export that will cause ClassCastException at runtime in plugins, a JUL handler leak when Maven runs embedded (regression from the removed restoreRootLoggerHandlers()), and two behavioral changes bundled into the compat layer that should not be there.

The internalization itself is sound — the API module is clean, the implementation bridge is correct, and the cast proliferation in MavenCli is an acceptable transitional state given the narrowed API surface.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet gnodet added enhancement New feature or request mvn4 labels Oct 14, 2026
@gnodet
gnodet force-pushed the feature/maven-internalize-classworlds branch from 699bd80 to 28b3a87 Compare October 14, 2026 07:17

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — 3 of the 4 issues have been addressed.

  • ✅ maven-api-classworlds added to <exportedArtifacts> in extension.xml (lines 154–155) — ClassCastException risk eliminated.
  • ✅ installEmbeddedTerminal() and dumb-terminal color detection restored in MavenCli.java — embedded-terminal regression fixed.
  • ✅ applyExportOrOpen() dead-code concern resolved — the module-access wiring is now a proper pipeline: m2.conf parser → ConfigurationHandler → Configurator → ClassWorld.addExports/addOpens/addReads. Well done.

Still open — JUL handler leak (impl/maven-cli/…/LookupInvoker.java):

activateLogging() calls SLF4JBridgeHandler.install() (guarded by isInstalled()), but SLF4JBridgeHandler.uninstall() is never called — not in the finally block, and not in the closeables list. When Maven runs embedded (IDE, CI tooling, Verifier), the handler remains on the JVM's root java.util.logging logger after Maven exits. The next JUL event in the host process routes through the closed Maven classloader → NoClassDefFoundError: org/slf4j/Logger.

The finally block currently:

        } finally {
            Thread.currentThread().setContextClassLoader(oldCL);
            System.setProperties(oldProps);
        }

Should be:

        } finally {
            Thread.currentThread().setContextClassLoader(oldCL);
            System.setProperties(oldProps);
            SLF4JBridgeHandler.uninstall();
        }

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet
gnodet force-pushed the feature/maven-internalize-classworlds branch from 28b3a87 to 5e281fc Compare October 14, 2026 07:22
@gnodet
gnodet dismissed gnodet-bot’s stale review October 14, 2026 07:22

Retracting: the JUL handler leak was already fixed on master (restoreRootLoggerHandlers, commit 05b8933). This PR branch predates the fix but is not the cause.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — all 3 original issues have been addressed.

  • ✅ maven-api-classworlds added to <exportedArtifacts> in extension.xml (lines 154–155) — ClassCastException risk eliminated.
  • ✅ installEmbeddedTerminal() and dumb-terminal color detection restored in MavenCli.java — embedded-terminal regression fixed.
  • ✅ applyExportOrOpen() dead-code concern resolved — the module-access wiring is now a proper pipeline: m2.conf parser → ConfigurationHandler → Configurator → ClassWorld.addExports/addOpens/addReads.

The JUL handler leak I raised in the dismissed review was a false positive — LookupInvoker.java is not changed by this PR, and restoreRootLoggerHandlers() was already added to master (commit 05b8933) before this branch was last rebased. It will be included on the next rebase.

LGTM.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet
gnodet force-pushed the feature/maven-internalize-classworlds branch 2 times, most recently from 3ff1535 to c14913f Compare October 14, 2026 07:47

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new @Experimental API interfaces use getXxx() naming where Maven 4 API conventions require noun-style no-arg accessors (xxx()). This is a standing project rule for all @Experimental interfaces in maven-api-* modules.

The exception classes (ClassWorldException, NoSuchRealmException, DuplicateRealmException) are in the api module and are part of the public contract — they should follow the same convention.

For ClassWorld.getRealm(id) / getClassRealm(id), the methods take an argument so the no-arg accessor rule doesn't strictly apply; however realm(id) / classRealm(id) would still be more consistent with the rest of the API style.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — the previous CHANGES_REQUESTED is withdrawn.

The noun-style accessor convention (id() vs getId()) applies to @Immutable value types only (e.g. Artifact, ArtifactCoordinates). ClassRealm and ClassWorld are mutable objects — they have mutating methods (addURL(), importFrom(), newRealm(), disposeRealm()) and are not annotated @Immutable. Standard JavaBeans getXxx() accessors are correct for mutable types. The counter-argument was accurate; that review was wrong.

New commit 58296b58 is correct: the 4 boot JAR glob references (plexus-classworlds-* → maven-classworlds-*) are consistent with component.xml which ships org.apache.maven:maven-classworlds in boot/. LAUNCHER_CLASS correctly retains org.codehaus.plexus.classworlds.launcher.Launcher — the internalised module preserves the original package structure for backward compatibility. No remaining source-level plexus-classworlds launcher-path references found.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — 3 new commits need attention.

The boot classpath addition (47265078) and the Launcher.getEnhancedMainMethod() dual-candidate approach (ca6b40c4) are both correct. However the companion commit (64f5d4ca) that changed delegateMain() in MavenCling to look up the API ClassWorld type breaks three existing sub-commands.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — the delegateMain() fix is correct.

The dual-candidate lookup in delegateMain() (MavenCling.java) now mirrors Launcher.getEnhancedMainMethod() exactly: it tries org.codehaus.plexus.classworlds.ClassWorld first (matching MavenEncCling, MavenShellCling, MavenUpCling), then org.apache.maven.api.classworlds.ClassWorld (matching MavenValCling). The method.invoke(null, args, world) call is safe for both paths because the impl ClassWorld implements the API ClassWorld interface — passing the impl instance where the API type is expected is a valid widening reference conversion.

LGTM.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@rmannibucau rmannibucau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we should take time to refine the API, we dont need all that nor all the concepts (world, realm, strategy). Maybe something closer to classloader would benefit the api on the long run

@gnodet

gnodet commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the input, @rmannibucau.

The API is explicitly @Experimental, so refinement is expected and welcome. That said, the world/realm model is intentional here rather than inherited clutter:

  1. Realm isolation is the core invariant — a bare ClassLoader has no notion of a named, managed realm with controlled import/export relationships. Extensions already depend on realm identity (they call ClassRealmManager to look up realms by ID, import from specific realms, etc.). Exposing this through a simpler ClassLoader-alike would either lose those semantics or push the complexity somewhere else.

  2. Strategy is an extension point — it controls load-order (self-first vs. import-first). Hiding it would make the API less powerful without reducing implementation complexity.

  3. Primary goal of this PR is internalization, not API design — the API surface is the minimum needed to type-safely bridge the internalised impl to callers. It deliberately mirrors the existing classworlds contracts so extensions don't break. A redesign of the model itself is a separate, larger conversation.

Happy to iterate on the API shape in a follow-up once the internalization lands. Is there a specific concept you'd drop or collapse? That would make the design conversation more concrete.

@rmannibucau

Copy link
Copy Markdown
Contributor

@gnodet didnt yet fully defined it but feel like it could just be exposing a MavenClassLoader or alike and not split that much concepts. integration can then be with other custom classloaders since it is what the abstractions are about most of the time and classloader are better defined than legacy classworld concept for java dev but it might need jpms careness with the work you do in parallel. So (maven)classloader+modulelayer sounds like the way to move forward for me but it is just a first feedback from my past interactions with plexus-classworld and OSGi/EE.

@gnodet
gnodet force-pushed the feature/maven-internalize-classworlds branch 2 times, most recently from 2b3866e to 30c8eac Compare October 15, 2026 14:06

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — previous findings all addressed, but two regressions introduced by the second new commit (30c8eac8).

Boot launcher mismatch (Maven won't start)

component.xml correctly places maven-classworlds-<version>.jar and maven-api-classworlds-<version>.jar in boot/. However mvn and mvn.cmd still use the old plexus-classworlds-*.jar glob — that pattern matches nothing in the assembled distribution and Maven fails immediately at launch (ClassWorld Launcher is never loaded). This commit must also update the glob in both launchers.

MavenValCling broken by launcher revert

The dual-candidate lookup in delegateMain() and getEnhancedMainMethod() was the correct fix approved in the previous review. This commit reverts both back to a single-type lookup on org.codehaus.plexus.classworlds.ClassWorld. MavenValCling.main(String[], ClassWorld) uses org.apache.maven.api.classworlds.ClassWorld (the API type) — the narrowed method lookup will throw NoSuchMethodException at runtime whenever maven.mainClass=org.apache.maven.cling.MavenValCling is set. The dual-candidate approach must be restored.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Comment thread apache-maven/src/assembly/component.xml Resolved
@gnodet

gnodet commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @rmannibucau.

The goal here is to internalize plexus-classworlds as an Apache Maven artifact and expose a minimal, stable API for the concepts that plugin authors genuinely need today (mostly realm introspection). The API surface is already quite small — ClassWorld, ClassRealm, and Strategy are the three things plugins interact with.

That said, I agree the longer-term direction is worth discussing. The Strategy abstraction in particular could arguably be flattened. I'd propose keeping this PR focused on the internalization (replacing the external dependency) and tracking API refinement in a follow-up issue where the design can be discussed with more context. Would that work for you?

@gnodet

gnodet commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@rmannibucau Thanks for the feedback. The API is marked @Experimental precisely to allow refinement based on real usage — so this is the right time to raise concerns.

A few points on the current design choices:

  • ClassWorld and ClassRealm mirror the plexus-classworlds concepts that the Maven container already uses internally. Exposing them under the @Experimental API makes the existing Maven extension/plugin contract explicit rather than hiding it behind a raw ClassLoader. Plugins and extensions already deal with realms (e.g. DefaultClassRealmManager).

  • Strategy — fair point. It's a lower-level concern and could arguably be omitted from the initial API surface. If there's no concrete use case for it in the maven-api layer yet, we can defer it.

  • Simpler ClassLoader-centric API — the concern is that a plain ClassLoader view loses the isolation semantics (realm-to-realm imports, exports) that Maven's classloading model relies on. Exposing those semantics explicitly, even if under @Experimental, lets us document and stabilize the contract rather than letting plugins rely on implementation internals.

That said, if you have a concrete proposal for a slimmer API surface (e.g. just expose the import/export operations and drop Strategy from the public API), I'm open to discussion. The @Experimental annotation means we can iterate. Could you sketch what you have in mind?

@gnodet
gnodet force-pushed the feature/maven-internalize-classworlds branch from 30c8eac to 4942bbf Compare October 15, 2026 14:23
@rmannibucau

Copy link
Copy Markdown
Contributor

two open questions:

  1. do we want to preserve the jar name in the distro for backward compat? (I'm keen we do it)
  2. do we want to drop the src/test/**/*.jar and generate them in test programmatically to avoid to have binaries in the sources?

rest LGTM

@gnodet

gnodet commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @rmannibucau for the final pair of questions.

1. Preserve the jar name in the distro for backward compat?

Yes, strongly agreed. The assembled distribution currently ships boot/maven-classworlds-<version>.jar (and mvn/mvn.cmd glob on that name). Any custom wrapper script, CI provisioning script, or tooling that greps or globs plexus-classworlds-*.jar in boot/ will silently break.

The assembly plugin supports <outputFileNameMapping> on a <dependencySet> to rename the artifact in the assembled directory independently of its Maven coordinates. We can keep the file named plexus-classworlds-<version>.jar in boot/ without touching the groupId/artifactId:

<dependencySet>
  <useProjectArtifact>false</useProjectArtifact>
  <outputDirectory>boot</outputDirectory>
  <includes>
    <include>org.apache.maven:maven-classworlds</include>
  </includes>
  <outputFileNameMapping>plexus-classworlds-${artifact.version}.jar</outputFileNameMapping>
</dependencySet>

mvn/mvn.cmd then keep their existing plexus-classworlds-*.jar glob and need no change either. Will apply this before merging.

2. Drop the src/test/test-data/ binary jars and generate them programmatically?

The jars (a.jar, b.jar, component0-1.0.jar, deadlock.jar, …) are compiled class fixtures that have been binary files in plexus-classworlds since its initial commit — they contain simple stub classes (a.A, a.Aa, deadlock.A/B/C/D, etc.) that the classloading tests load across realm boundaries.

Generating them at test time would require either: (a) a separate Maven sub-module that compiles them and produces JARs before the main module's tests run, or (b) an in-test bytecode generation approach (e.g. ASM). Both are significantly more complex than static fixtures and would themselves need sources tracked in git — just Java source files instead of class files.

My preference is to leave them as binary test fixtures in this PR (it faithfully copies the plexus-classworlds approach) and track the replacement as a follow-up if the project wants it. Keeping the scope of this internalization PR minimal makes review easier.

Does that work for you, or would you prefer we tackle the jar generation in this PR?

Claude Code on behalf of Guillaume Nodet

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — the backward-compatibility fix is correct.

The approach of renaming maven-classworlds-<version>.jar → plexus-classworlds-<version>.jar in boot/ via <outputFileNameMapping> in component.xml is sound: wrapper scripts, CI tooling, and IDEs that glob boot/plexus-classworlds-*.jar continue to work without change. The launcher globs in mvn and mvn.cmd are now consistent with the renamed boot artifact, and the test stubs in both shell test scripts have been updated accordingly.

LGTM.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@rmannibucau

Copy link
Copy Markdown
Contributor

for the jar asm or subproject "fixture" would work I think, i dont care much while we reach a stage we dont trust binaries like that (and not blaming know it was there)

gnodet and others added 9 commits October 19, 2026 16:58
…che#11028)

Fork plexus-classworlds 2.x into impl/maven-classworlds and expose a
stable public API via api/maven-api-classworlds under the
org.apache.maven.api.classworlds package.

New modules:
- api/maven-api-classworlds: ClassWorld, ClassRealm, Strategy,
  ClassWorldListener, exceptions under org.apache.maven.api.classworlds
- impl/maven-classworlds: fork of plexus-classworlds with the existing
  org.codehaus.plexus.classworlds implementation plus backward-compat
  adapters under org.codehaus.classworlds
…aunchers)

Replace the external plexus-classworlds dependency with maven-classworlds
across the codebase and update the boot classpath in the launchers.

- Replace plexus-classworlds dependency with maven-classworlds in all
  affected module poms (maven-core, maven-cli, maven-compat, maven-plugin-api,
  maven-resolver-provider, apache-maven)
- Update assembly component.xml: swap boot entry to maven-classworlds +
  maven-api-classworlds, exclude both from lib
- Update all import sites to org.codehaus.plexus.classworlds.*
- Add maven-classworlds and maven-api-classworlds to exportedArtifacts
  in extension.xml (prevents ClassCastException in plugins)
- Remove classWorldsVersion property from root pom.xml
- Update LAUNCHER_JAR glob in mvn/mvn.cmd to maven-classworlds-*.jar,
  add maven-api-classworlds-*.jar to boot classpath, use cygpath --path
  for the compound path on Cygwin/MinGW
- Update test scripts for new jar names
- Update Launcher.getEnhancedMainMethod() and delegateMain() to handle
  both impl and API ClassWorld types for backward compatibility
Per review feedback from @rmannibucau, demote the public API surface:
remove the api/maven-api-classworlds module and revert all consumer
code to use the plexus-classworlds implementation types directly.

The internalization of plexus-classworlds as impl/maven-classworlds
is preserved. A stable public API can be designed and introduced in
a follow-up once the internalization has settled.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Now that the API interfaces are removed, the fully-qualified names
that were needed to disambiguate API vs impl types can be simplified.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Now that the API interfaces are removed, the fully-qualified names
and casts that were needed to disambiguate or downcast from API to
impl types are no longer necessary.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…tibility

The assembled distribution renames maven-classworlds-*.jar back to
plexus-classworlds-*.jar via outputFileNameMapping in component.xml.
This keeps existing wrapper scripts, CI tooling, and IDEs that glob
boot/plexus-classworlds-*.jar working without any change.

mvn, mvn.cmd, and test stubs are updated to match.

Requested by @rmannibucau in review.
@gnodet
gnodet force-pushed the feature/maven-internalize-classworlds branch from 40b45d9 to fa168cb Compare October 19, 2026 16:59
Replace 17 committed binary test fixture JARs with a TestJarGenerator
that compiles Java sources and assembles JARs at test time using the
JDK's javax.tools.JavaCompiler and JarOutputStream APIs.

All JARs are written to target/test-jars/ before tests run via a
@BeforeAll hook in AbstractClassWorldsTestCase. Conf files updated to
reference target/test-jars/ instead of src/test/test-data/.

No binary blobs remain in the repository; every fixture is fully
auditable from its Java source.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — previous findings all addressed. One nit in the new commit.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — the Javadoc nit is addressed.

The corrected description now accurately matches the implementation: it states that existing JARs are overwritten on each run and that stale JARs (from a previous run whose names are no longer generated) are not deleted. That is precise and actionable for anyone who hits a stale-artifact issue.

All previous findings across this PR are now fully resolved. LGTM.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

…d parent contexts activate POM-property conditions

Commit 267e65f (backport of PR apache#13545) introduced a dedicated
interpolationProperties field to prevent POM-declared properties from
self-activating profiles via start(Map). However, it incorrectly dropped
the model.withProperties(interpolationProperties) call that makes those
properties accessible via getModelProperty() in non-sandboxed (project
parent) contexts.

The 4.0.x implementation keeps both:
- model.withProperties(map) so getModelProperty() works for project parents
- interpolationProperties stored separately for path interpolation

The sandbox (withoutUserPropertiesAndFilesystem()) overrides getModelProperty()
to return null, which is the guard against POM property self-activation in
dependency/external builds (apache#13390). Non-sandboxed project parent builds
should still be able to activate condition-based profiles that reference
POM-declared properties.

Fixes testResolvedDependencyParentCacheDoesNotShareActivationWithProjectParent
at line 380: assertEquals("activated", profile.pom.condition)

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — all previous findings are addressed. One new commit needs attention.

New commit (651d7a58) — fix: restore model.withProperties() in start(Map)

The fix is correct and matches master behavior. Before the fix, start(Map<String, String> interpolationProperties) passed the original model (built with Model.newInstance() in the test helper, which has no <properties>) to the constructor, leaving getModelProperty() returning null for POM-declared keys. The sandbox's withoutUserPropertiesAndFilesystem() override (which unconditionally returns null from getModelProperty()) is the actual guard against self-activation in dependency parent contexts — so restoring model.withProperties(interpolationProperties) for the outer context is safe.

One minor observation on the updated interpolatePath logic: after this fix, interpolationProperties and model.getProperties() contain the same map, so the interpolationProperties-first check inside interpolate() is now redundant for the non-sandbox path. That's not a bug — the behavior is correct — but the comment still describes the check as preventing self-activation, which is now handled by the sandbox override rather than by this ordering. A follow-up cleanup of the interpolate() comment would improve clarity, but it's not a blocker.

The Javadoc update is accurate and clearly documents the sandbox contract.

Pre-fix validation: the assertion at line 380 (assertEquals("activated", projectParentModel.getProperties().get("profile.pom.condition"))) was failing before this commit — getModelProperty() returned null for pom.declared.prop because the context was constructed with Model.newInstance() (no properties). After the fix it returns "hello", the condition ${pom.declared.prop} == 'hello' fires, and the profile activates. ✅

LGTM.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

…nalize-classworlds

# Conflicts:
#	impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultProfileActivationContext.java
…es it

Commit 651d7a5 (in this branch) restored model.withProperties(interpolationProperties)
in start(Map) so that POM-property conditions could fire in project-parent paths.

This is now incorrect: PR apache#1774 (Cascading profile activation, commit 9e7a17e)
landed in master and provides the proper mechanism: POM properties from activated
profiles flow through getCascadedProfileProperty(), not getModelProperty().

The cascading PR also updated testResolvedDependencyParentCacheDoesNotShareActivationWithProjectParent
to assert that profile.pom.condition must NOT self-activate even in the project-parent
path (assertNull at line 381-383), which conflicts with what 651d7a5 introduced.

Revert start(Map) to pass the original model (not model.withProperties(...)).
Path interpolation is unaffected — interpolationProperties is still passed separately
and used exclusively inside interpolate() for placeholder resolution (see apache#10375).
The fix for apache#13390 remains intact.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — the previous findings are all addressed, and the new commit correctly reverts the start(Map) model override.

  • ✅ Revert is correct: commit 651d7a58 restored model.withProperties(interpolationProperties) in start(Map) to enable condition-based profile activation for project-parent paths. This is superseded by PR #1774 (cascading activation, commit 9e7a17eb8b), which introduced getCascadedProfileProperty() as the proper mechanism for that use case. The cascading PR also updated testResolvedDependencyParentCacheDoesNotShareActivationWithProjectParent to assertNull on profile.pom.condition in the project-parent path — which directly conflicts with what 651d7a58 introduced.
  • ✅ Javadoc is accurate: "for path interpolation only / model's properties are NOT overridden" correctly describes the post-revert behaviour. interpolationProperties is only consumed in interpolate() (line 553), never by profile activators.
  • ✅ interpolate() comment is still correct: the check-interpolationProperties-first remark ("without being exposed through getModelProperty() and thus without being able to self-activate profiles") is accurate again — the two maps are distinct after the revert.
  • ✅ No test changes needed: the assertNull assertion at line 381–383 of DefaultModelBuilderTest (merged from master via PR #13555) already exercises and validates this code path.

My earlier observation about the interpolate() check being "redundant for the non-sandbox path" (from the 651d7a58 review) is now moot — the maps are distinct again, so the check is correct.

LGTM.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet gnodet added this to the 4.2.0 milestone Oct 23, 2026
@gnodet
gnodet merged commit 6399a8e into apache:master Oct 23, 2026
24 checks passed
@gnodet
gnodet deleted the feature/maven-internalize-classworlds branch October 26, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request mvn4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants