Utkarsh-rwt opened a new pull request, #13401:
URL: https://github.com/apache/maven/pull/13401
## Summary
Note : copilot helped me to write this pr
Fixes #13390.
This change prevents properties declared in a dependency POM from activating
property-based profiles in that same POM during external model building.
## Background
Maven 3.10.0 introduced external dependency-POM profile hardening through
the changes for #13084, implemented in #13112 and backported through #13114.
That change introduced an external `ProfileActivationContext` which
suppressed consumer user properties and merged the dependency model's project
properties into the system-property lookup.
The merge caused a dependency POM such as:
```xml
<properties>
<example.enable.extra>true</example.enable.extra>
</properties>
```
to activate its own property-based profile:
```xml
<activation>
<property>
<name>example.enable.extra</name>
</property>
</activation>
```
POM-defined properties should not act as profile activation properties for
the same dependency POM.
## Scope
This PR addresses the POM-local property activation bug from #13390.
It does not change the intentional external-model hardening for file-based
profiles, and it does not address the separate compatibility question from
#13347 regarding whether `-Dmaven.model.dependencyInterpolation.full=true`
should restore user-property profile activation.
## Changes
- Removed dependency POM-local properties from the external system-property
lookup.
- Preserved activation based on actual system properties, including platform
properties such as `java.version` and `os.name`.
- Continued suppressing consumer user properties (`-D`) when evaluating
dependency POM profiles.
- Preserved negated-property/default-on profiles, such as RESTEasy's
`!resteasy.dependencies.eap` pattern.
- Applied the fix consistently to:
- `compat/maven-model-builder`
- `impl/maven-impl`
## Tests
Updated and added regression coverage in both model-building implementations.
### Compat model builder
Updated:
`compat/maven-model-builder/src/test/java/org/apache/maven/model/building/ExternalModelProfileActivationTest.java`
The tests verify that:
- A positive property profile backed by the dependency POM's own
`<properties>` remains inactive.
- System-property profile activation still works.
- Consumer user-property activation remains suppressed.
- File-based activation remains suppressed.
- JDK activation still works.
- Negated-property/default-on activation still works.
### Maven implementation model builder
Updated:
`impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultModelBuilderTest.java`
Added an assertion that a dependency POM's declared property does not
activate its own profile.
Updated:
`impl/maven-impl/src/test/resources/poms/factory/resolved-model-with-profiles.xml`
Added a POM-local property and a profile activated by that property to
reproduce #13390.
## Validation
The full reactor command was executed:
```bash
mvn -DdistributionTargetDir="$PWD/target/apache-maven-test-dist" clean verify
```
The full reactor reached `maven-core`, but failed in four unrelated existing
`ProjectModelResolverTest` cases because the test repository returned no
matching versions for ranges such as `(,2.0)` and `[1,)`.
The affected tests were run independently:
```bash
mvn -pl compat/maven-model-builder,impl/maven-impl \
-Dtest=ExternalModelProfileActivationTest,DefaultModelBuilderTest \
-Dsurefire.failIfNoSpecifiedTests=false test
```
Result:
- `impl/maven-impl`: `DefaultModelBuilderTest` — 40 passed
- `compat/maven-model-builder`: `DefaultModelBuilderTest` — 3 passed
- `compat/maven-model-builder`: `ExternalModelProfileActivationTest` — 10
passed
- Total affected tests: **53 passed, 0 failures, 0 errors**
```
--
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]