Repository navigation
Description
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 #13442 (comment).
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 whenjava.versionis 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.OperatingSystemProfileActivatorfalls back to the JVM'sos.*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 toRootLocator. - Or put a
.mvnmarker next to the test POMs, soRootLocatorstops 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.
Activity
Fix apache#13448: isolate model builder test roots
Fix #13448: isolate model builder test roots (#13506)