Skip to content

Fix #13004: enable deterministic profile activation for BUILD_CONSUMER - #13006

Merged
gnodet merged 4 commits into
masterfrom
fix-13004-consumer-pom-builder-fails-on-profile
Sep 2, 2026
Merged

Fix #13004: enable deterministic profile activation for BUILD_CONSUMER#13006
gnodet merged 4 commits into
masterfrom
fix-13004-consumer-pom-builder-fails-on-profile

Conversation

@gnodet

@gnodet gnodet commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Enable activation of deterministic profiles (OS, JDK, activeByDefault) for BUILD_CONSUMER requests, while continuing to skip file-, property-, and condition-activated profiles
  • Repositories from activated profiles are stripped so they do not leak into the published consumer POM
  • Reuses the hasFileOrPropertyOrConditionActivation() filter from PR Restrict what a repository-resolved model contributes to the build #12948 (externalOrigin)

Problem

When a project uses OS-activated profiles to define properties referenced in dependency coordinate fields (e.g. ${swt.artifactId}), the consumer POM builder fails with a coordinate validation error because BUILD_CONSUMER skipped ALL profile activation. This breaks projects like Apache Hop that use platform-specific dependency selection via OS profiles.

Approach

The fix applies the same deterministic-only profile filter to BUILD_CONSUMER that #12948 applies to externalOrigin models — keeping OS/JDK/activeByDefault profiles while excluding file/property/condition-activated ones. This ensures platform-dependent properties are resolved before validation, while keeping the consumer POM reproducible.

Based on PR #12948 — rebased on pr/model-building-master.

Test plan

  • Updated testBuildConsumerActivatesOnlyDeterministicProfiles — JDK profile now activates, file/property/condition profiles still skipped, repositories stripped
  • Existing tests for parent profile property inheritance (artifactId, version, OS profiles) all pass
  • Full impl/maven-impl test suite passes (629 tests)
  • Compat maven-model-builder test suite passes (175 tests)

🤖 Generated with Claude Code

@gnodet
gnodet force-pushed the fix-13004-consumer-pom-builder-fails-on-profile branch from fc32f54 to 1d6cecd Compare September 1, 2026 22:02
@gnodet gnodet changed the title Add tests for GH-13004: consumer POM profile-activated property in artifactId Fix #13004: enable deterministic profile activation for BUILD_CONSUMER Sep 1, 2026
gnodet and others added 2 commits September 2, 2026 07:46
…tifactId

Add unit tests and integration test verifying that the consumer POM
builder correctly handles OS-activated profile properties used in
dependency artifactId coordinates. This scenario (from Apache Hop)
is already handled by the CONSUMER_PARENT request type (#11799)
and the MNG-8709 user-property fix, but had no regression test.

Unit tests cover:
- BUILD_CONSUMER resolving parent profile properties in artifactId
- BUILD_CONSUMER after BUILD_PROJECT (cache hit scenario)
- OS-activated profile properties with full reactor simulation

Integration test covers:
- Multi-module project with OS-activated profiles in parent POM
- Dependency management entries inside profiles using ${...} artifactId
- Non-flattened consumer POM preserving parent and profiles
- Flattened consumer POM fully resolving the property

Closes #13004

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The consumer POM builder previously skipped ALL profile activation for
BUILD_CONSUMER requests, which left platform-dependent properties (e.g.
${swt.artifactId} from an OS-activated profile) unresolved. The coordinate
validator then rejected these as invalid artifact IDs.

Enable activation of deterministic profiles — those triggered by JDK
version, operating system, or activeByDefault — for BUILD_CONSUMER, while
continuing to skip file-, property-, and condition-activated profiles.
This mirrors the filtering already applied to repository-resolved models
in PR #12948 (externalOrigin). Repositories from activated profiles are
stripped so they do not leak into the published consumer POM.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the fix-13004-consumer-pom-builder-fails-on-profile branch from 1d6cecd to 6dc97d4 Compare September 2, 2026 05:50
gnodet and others added 2 commits September 2, 2026 08:10
- DefaultVersionResolver: remove extra blank lines (Spotless)
- DefaultVersionRangeResolver: remove unused IOException import (Spotless)
- DistributionManagementArtifactRelocationSourceTest: add throws clause
  for ArtifactDescriptorException after relocatedTarget signature change

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Packaging-activated profiles are handled separately by the consumer POM
builder's inlinePackagingActivatedProfiles(), which properly filters
non-transitive scoped dependencies. Activating them during model building
would double-merge their contributions, leaking test-scoped dependencies
into the consumer POM.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Sep 2, 2026
@gnodet
gnodet marked this pull request as ready for review September 2, 2026 07:43

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Clean fix for deterministic profile activation in BUILD_CONSUMER model building. The approach of filtering out property/file/condition-activated profiles during consumer builds — while letting inlinePackagingActivatedProfiles() handle packaging activation separately — is well-reasoned and avoids double-merging.

One low-severity suggestion:

Missing edge-case test for mixed activation: The test POMs each use a single activation type (file, property, condition, or JDK). There's no test for a profile combining e.g. OS activation with property activation. hasFileOrPropertyOrConditionActivation() would correctly filter such a profile (since activation.getProperty() != null returns true), but an explicit test would lock down this corner case.

📋 PR Metadata

Aspect Current Suggested
Labels (none) bug
Milestone 4.0.0-rc-7

🔀 Backport Status

⚠️ This bug fix targets master but no backport PR was found for:

  • maven-4.0.x — consumer POMs are a Maven 4 feature, so this bug applies there too

3.9.x and 3.10.x are not affected (no consumer POM support).

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

gnodet added a commit to gnodet/maven that referenced this pull request Sep 2, 2026
@gnodet gnodet added bug Something isn't working mvn4 labels Sep 2, 2026
@gnodet gnodet modified the milestones: 4.0.0-rc-7, 4.1.0 Sep 2, 2026
@gnodet gnodet self-assigned this Sep 2, 2026
@gnodet
gnodet merged commit d96bf89 into master Sep 2, 2026
23 checks passed
@gnodet
gnodet deleted the fix-13004-consumer-pom-builder-fails-on-profile branch September 2, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mvn4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants