slachiewicz opened a new issue, #13448:
URL: https://github.com/apache/maven/issues/13448

   ### Affected version
   
   4.0.x and master (`impl/maven-impl` tests)
   
   ### Bug description
   
   Model builder tests that run on an `ApiRunner` session build Maven's own 
reactor before the POM under test. A profile added to the root `pom.xml` of 
this repository can then fail tests that never reference it.
   
   `ApiRunner`'s session throws `IllegalStateException` from 
`getRootDirectory()`. `DefaultModelBuilder.buildBuildPom()` then falls back to 
`RootLocator.findMandatoryRoot(top)`, which walks up from the test POM (for 
example `src/test/resources/poms/factory/complex.xml`) to the first `.mvn` 
directory: the root of the checkout. `loadFromRoot()` reads that `pom.xml` and 
every subproject, activates their profiles with the request's system properties 
only, and throws if any of them reports an error, before it finds that the test 
POM is not in that reactor.
   
   #13442 hit this: a `<jdk>[27,)</jdk>` activation in the root POM failed 
`ComplexActivationTest`, because the request carries only `myproperty` and 
`JdkVersionProfileActivator` reports a missing `java.version` as an ERROR:
   
   ```
   [ERROR] ComplexActivationTest.testAndConditionInActivation:63 ยป ModelBuilder 
1 problem was  for test:test:pom:0.1-SNAPSHOT
       - [ERROR] Failed to determine Java version for profile 
jdk27-skip-spotless @ line 998, column 9
   ```
   
   The location is in the root `pom.xml`, but the problem is reported against 
`test:test`. The call stacks are in 
https://github.com/apache/maven/pull/13442#issuecomment-6132760193.
   
   #### Scope
   
   JDK activation is the trigger seen so far, but not the only one. Any ERROR 
problem while reading or activating any POM of this repository fails these 
tests. Among the activators:
   
   - `JdkVersionProfileActivator`: error when `java.version` is missing, which 
it always is in these requests.
   - `PropertyProfileActivator`: error for an empty property name.
   - `ConditionProfileActivator`: error when a condition fails to parse or 
evaluate.
   - `FileProfileActivator`: error when the file check throws.
   - `OperatingSystemProfileActivator` falls back to the JVM's `os.*` values, 
so an OS-activated root profile is evaluated against the host that runs the 
tests.
   
   The tests also depend on the reactor's layout: a subproject that is missing 
or fails to parse in the checkout breaks them.
   
   Counted on `maven-4.0.x` with a temporary print in `loadFilePom`, `mvn test 
-pl impl/maven-impl` (613 tests):
   
   | Test class | Root POM loads | POM loads in total |
   |---|---|---|
   | `DefaultModelBuilderTest` | 35 | 1501 |
   | `ComplexActivationTest` | 2 | 78 |
   | `TestApiStandalone` | 1 | 38 |
   | `RequestTraceTest` | 1 | 38 |
   
   Each `ComplexActivationTest` method reads the 39 POMs of this repository to 
build one test POM.
   
   #### Possible fixes
   
   - Give the test sessions a root directory (the test resources directory), so 
`buildBuildPom()` does not fall back to `RootLocator`.
   - Or put a `.mvn` marker next to the test POMs, so `RootLocator` stops there.
   
   #13442 and #13439 worked around it by activating the profile through 
`java.specification.version`, which is inactive rather than an error when the 
property is missing.
   


-- 
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]

Reply via email to