gnodet opened a new issue, #13004:
URL: https://github.com/apache/maven/issues/13004
## 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`:
```java
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:
```xml
<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:
```xml
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>${swt.artifactId}</artifactId>
<version>${org.eclipse.platform.version}</version>
</dependency>
```
Steps:
1. Clone `apache/hop`
2. Run `mvnup apply` then `mvn clean package -DskipTests` with Maven
4.0.0-rc-5+ and JDK 21
3. `hop-ui` compiles successfully but fails during
`installIntoProjectLocalRepository`
## Expected Behavior
The consumer POM builder should resolve profile-activated properties before
coordinate validation. The project builds correctly with Maven 3.
## Possible Fixes
1. Re-activate deterministic profiles (OS, JDK) in the `BUILD_CONSUMER`
model builder path
2. Skip coordinate validation on values that are `${...}` patterns (they'll
be interpolated by consumers)
3. Ensure user properties are properly interpolated in all fields (not just
versions) before validation
## Related
- #12981 / #12982 — same consumer POM builder area, different property
source (extension `PropertyContributor` vs. profile activation)
## Context
Data from [maven4-testing](https://github.com/gnodet/maven4-testing) run
testing `maven-4.0.x` against Apache projects.
--
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]