gnodet opened a new pull request, #13112: URL: https://github.com/apache/maven/pull/13112
## Problem The fix in f599020f blocked file- and property-activated profiles in external (repository-resolved) model builds by pre-filtering the profile list before activation. This correctly stopped consumer `-D` flags from activating dependency profiles, but had a correctness gap: - It blocked **all** property-activated profiles, including those conditioned on the model's own `<properties>` section — which are part of the artifact's **published identity**, not the consumer's build environment. - `#13095` partially addressed this by allowing negated-property profiles (`!foo`), but missed the symmetric case: a publisher who declares `<properties><foo>bar</foo></properties>` and conditions a profile on `<property><name>foo</name></property>` would still be broken. ## Solution Replace the type-based profile pre-filter with a **sandboxed `ProfileActivationContext`** for external model builds. All profiles are passed to the selector; the sandbox restricts *what inputs they see*: | Input | External model | Rationale | |---|---|---| | System properties (`java.version`, `os.name`, …) | ✅ Preserved | Platform facts — JDK/OS activation must work | | Model `<properties>` | ✅ Preserved | Part of the artifact's published identity | | User properties (`-D` flags) | ❌ Emptied | Consumer didn't set these for the dependency | | File existence | ❌ Disabled | Publisher paths don't exist on the consumer's machine | This gives correct results in all cases: - `<property><name>foo</name></property>` where `foo=bar` in `<properties>` → **fires** ✅ - `<property><name>!foo</name></property>` (absent from sandbox) → **fires** ✅ (default-on preserved) - `<property><name>flag</name></property>` where `flag` is only in consumer `-D` → **suppressed** ✅ - `<jdk>`, `<os>`, `activeByDefault` → **always fire** ✅ - File activation → **suppressed** ✅ ## Changes **Both stacks** (compat `maven-model-builder` and new `impl/maven-impl`): - `DefaultModelBuilder`: replace pre-filter with sandboxed context for the `externalOrigin` / `VALIDATION_LEVEL_MINIMAL` branch - `PropertyProfileActivator`: add model/project `<properties>` as third fallback in lookup chain (user → system → model) - `DefaultProfileActivationContext` (new stack): add `withoutUserPropertiesAndFilesystem()` returning a sandboxed context view - `ProfileActivationContext` interfaces: updated Javadoc on `getUserProperties()`/`getUserProperty()` and `getProjectProperties()`/`getModelProperty()` to document the external-model contract **Tests**: `ExternalModelProfileActivationTest` rewritten with 8 focused cases covering each activation type separately. ## Supersedes Supersedes #13095 (which is a narrower workaround for the negated-property case only). Fixes #13084. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
