Repository navigation
Description
Problem
When a project uses OS-activated profiles to set properties that are referenced in dependency <artifactId> fields, the Maven 4 consumer POM builder fails with a coordinate validation error:
ModelBuilderException: 1 problem was for org.apache.hop:hop-ui:jar:2.20.0-SNAPSHOT
- [ERROR] 'dependencies.dependency.artifactId' for groupId='org.eclipse.platform',
artifactId='${swt.artifactId}', type='jar' with value '${swt.artifactId}'
does not match a valid coordinate id pattern. @ line 64, column 13
The project builds successfully up to and including compilation of the affected module — the error occurs when ReactorReaderSpy triggers installIntoProjectLocalRepository, which calls ConsumerPomArtifactTransformer.transform() to build the consumer POM.
Root Cause
In DefaultModelBuilder, isBuildRequestWithActivation() explicitly returns false for BUILD_CONSUMER:
boolean isBuildRequestWithActivation() {
return request.getRequestType() != ModelBuilderRequest.RequestType.BUILD_CONSUMER;
}This causes getActiveProfiles() to return an empty list for consumer POM builds, so OS-activated profiles are never applied. The DefaultConsumerPomBuilder.buildModel() compensates by passing active profile properties as user properties (line 364-367), but this only feeds interpolation — it doesn't merge the profile's dependencies or dependency management sections into the model. The coordinate validator then sees the raw ${swt.artifactId} and rejects it.
Reproducer
Apache Hop (apache/hop) — root POM uses OS-activated profiles:
<profile>
<id>swt-unix</id>
<activation>
<os><name>Linux</name><family>unix</family></os>
</activation>
<properties>
<swt.artifactId>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>${swt.artifactId}</artifactId>
...The hop-ui submodule then uses this property in a dependency:
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>${swt.artifactId}</artifactId>
<version>${org.eclipse.platform.version}</version>
</dependency>Steps:
- Clone
apache/hop - Run
mvnup applythenmvn clean package -DskipTestswith Maven 4.0.0-rc-5+ and JDK 21 hop-uicompiles successfully but fails duringinstallIntoProjectLocalRepository
Expected Behavior
The consumer POM builder should resolve profile-activated properties before coordinate validation. The project builds correctly with Maven 3.
Possible Fixes
- Re-activate deterministic profiles (OS, JDK) in the
BUILD_CONSUMERmodel builder path - Skip coordinate validation on values that are
${...}patterns (they'll be interpolated by consumers) - Ensure user properties are properly interpolated in all fields (not just versions) before validation
Related
- Consumer POM leaves extension-contributed user properties uninterpolated in POM-packaged projects #12981 / Fix consumer POM leaving extension-contributed user properties uninterpolated #12982 — same consumer POM builder area, different property source (extension
PropertyContributorvs. profile activation)
Context
Data from maven4-testing run testing maven-4.0.x against Apache projects.
Activity
Add tests for GH-13004: consumer POM profile-activated property in ar…
Fix #13004: enable deterministic profile activation for BUILD_CONSUMER
Add tests for GH-13004: consumer POM profile-activated property in ar…
Fix #13004: enable deterministic profile activation for BUILD_CONSUMER
Fix apache#13004: enable deterministic profile activation for BUILD_C…
[MNG-8602] Fix #13004: enable deterministic profile activation for BU…