You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "rbygrave (via GitHub)" <gi...@apache.org> on 2026/04/08 06:10:18 UTC
[PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
rbygrave opened a new pull request, #11904:
URL: https://github.com/apache/maven/pull/11904
Based on design discussion on Issue #11500, the proposal is to support `groupId:artifactId:version` format for Dependency, Exclusion and Mixin.
This means that we can define dependencies in the form:
```xml
<dependency id="groupId:artifactId:version" />
```
Examples:
```xml
<dependency id="org.slf4j:slf4j-api:2.0.17"/>
```
```xml
<dependency id="org.postgresql:postgresql:42.7.3">
<exclusions>
<exclusion id="*:*"/>
</exclusions>
</dependency>
```
```xml
<mixin id="com.example.mixins:java-mixin:1.0.0" />
```
<!--
Please open pull requests against one of the following branches:
- master — default target for all changes (new features + bug fixes).
If the change should also go to maven-4.0.x, request a backport in the PR.
- maven-3.10.x — target for 3.x changes (new features + bug fixes).
If the change should also go to maven-3.9.x, request a backport in the PR.
maven-3.9.x should receive only serious bug fixes, as it is approaching EOL.
Backports are typically handled by maintainers;
however, after agreement you may open a separate backport PR to the target maintenance branch.
-->
Following this checklist to help us incorporate your
contribution quickly and easily:
- [ ] Your pull request should address just one issue, without pulling in other changes.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
Note that commits might be squashed by a maintainer on merge.
- [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
This may not always be possible but is a best-practice.
- [ ] Run `mvn verify` to make sure basic checks pass.
A more thorough check will be performed on your pull request automatically.
- [ ] You have run the [Core IT][core-its] successfully.
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
[core-its]: https://maven.apache.org/core-its/core-it-suite/
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #11904:
URL: https://github.com/apache/maven/pull/11904#issuecomment-5609674687
Fix pushed in `4632bb8c13`: harmonized type-check in consumer POM builder to use `isNullOrEmptyOrDefault()` matching the normalizer, as flagged in the review.
Also addresses the observation about duplicated `isNullOrEmpty` — the consumer POM builder now has its own `isNullOrEmptyOrDefault()` private helper, consistent with the normalizer's approach.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #11904:
URL: https://github.com/apache/maven/pull/11904#discussion_r4329353851
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -1307,6 +1371,182 @@ private void validate20RawDependencies(
}
}
+ private void validateDependencyIdAttribute(ModelProblemCollector problems, Dependency dependency, String prefix) {
+ String id = dependency.getId();
+ if (id == null || id.isEmpty()) {
+ return;
+ }
+
+ String remaining = id;
+ boolean hasOptionalMarker = false;
+ if (remaining.endsWith("?")) {
+ hasOptionalMarker = true;
+ remaining = remaining.substring(0, remaining.length() - 1);
+ }
+
+ boolean hasScopeMarker = false;
+ int atIndex = remaining.lastIndexOf('@');
+ if (atIndex >= 0) {
+ hasScopeMarker = true;
+ remaining = remaining.substring(0, atIndex);
+ }
+
+ int colonCount = remaining.length() - remaining.replace(":", "").length();
+ if (colonCount < 1 || colonCount > 4) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "id",
+ null,
+ "has invalid format '" + id + "', must be 'groupId:artifactId[:]', "
+ + "'groupId:artifactId:version', "
+ + "'groupId:artifactId:type:[version]', or "
+ + "'groupId:artifactId:type:classifier:[version]'. "
+ + "An optional '@scope' suffix and/or trailing '?' may be appended.",
+ dependency);
+ return;
+ }
+ if (!isNullOrEmpty(dependency.getGroupId())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "groupId",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (!isNullOrEmpty(dependency.getArtifactId())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "artifactId",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (!isNullOrEmpty(dependency.getVersion())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "version",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ String[] parts = remaining.split(":", -1);
+ if (parts.length >= 3
+ && !parts[2].isEmpty()
+ && !isNullOrEmpty(dependency.getType())
Review Comment:
**Off-by-one in threshold: `>= 3` should be `>= 4`.**
The `id` format is:
- 3-part: `g:a:version` — position 2 is **version**, not type
- 4-part: `g:a:type:[version]` — position 2 is **type**
- 5-part: `g:a:type:classifier:[version]`
With `parts.length >= 3`, any 3-part id (`g:a:1.0`) will trigger this check: `parts[2]="1.0"` is non-empty and the id does **not** include a type — so the error `"type must not be specified when 'id' attribute includes type"` fires incorrectly when the user adds `<type>pom</type>` to a 3-part id.
The old `colonCount >= 3` was correct because `colonCount` equalled `parts.length - 1`, so `colonCount >= 3` ↔ `parts.length >= 4`.
```suggestion
if (parts.length >= 4
```
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -1307,6 +1371,182 @@ private void validate20RawDependencies(
}
}
+ private void validateDependencyIdAttribute(ModelProblemCollector problems, Dependency dependency, String prefix) {
+ String id = dependency.getId();
+ if (id == null || id.isEmpty()) {
+ return;
+ }
+
+ String remaining = id;
+ boolean hasOptionalMarker = false;
+ if (remaining.endsWith("?")) {
+ hasOptionalMarker = true;
+ remaining = remaining.substring(0, remaining.length() - 1);
+ }
+
+ boolean hasScopeMarker = false;
+ int atIndex = remaining.lastIndexOf('@');
+ if (atIndex >= 0) {
+ hasScopeMarker = true;
+ remaining = remaining.substring(0, atIndex);
+ }
+
+ int colonCount = remaining.length() - remaining.replace(":", "").length();
+ if (colonCount < 1 || colonCount > 4) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "id",
+ null,
+ "has invalid format '" + id + "', must be 'groupId:artifactId[:]', "
+ + "'groupId:artifactId:version', "
+ + "'groupId:artifactId:type:[version]', or "
+ + "'groupId:artifactId:type:classifier:[version]'. "
+ + "An optional '@scope' suffix and/or trailing '?' may be appended.",
+ dependency);
+ return;
+ }
+ if (!isNullOrEmpty(dependency.getGroupId())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "groupId",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (!isNullOrEmpty(dependency.getArtifactId())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "artifactId",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (!isNullOrEmpty(dependency.getVersion())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "version",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ String[] parts = remaining.split(":", -1);
+ if (parts.length >= 3
+ && !parts[2].isEmpty()
+ && !isNullOrEmpty(dependency.getType())
+ && !"jar".equals(dependency.getType())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "type",
+ null,
+ "must not be specified when 'id' attribute includes type.",
+ dependency);
+ }
+ if (parts.length >= 4 && !parts[3].isEmpty() && !isNullOrEmpty(dependency.getClassifier())) {
Review Comment:
**Off-by-one in threshold: `>= 4` should be `>= 5`.**
A classifier appears at position 3 only in the 5-part format `g:a:type:classifier:[version]`. In the 4-part format `g:a:type:version`, position 3 is the **version**.
With `parts.length >= 4`, a 4-part id like `g:a:war:1.0` sets `parts[3]="1.0"` (version) as non-empty, and the check fires: the user gets `"classifier must not be specified when 'id' attribute includes classifier"` even though the id has **no classifier** in it. The old `colonCount >= 4` was correct for the same reason as above (`colonCount` = `parts.length - 1`).
```suggestion
if (parts.length >= 5 && !parts[3].isEmpty() && !isNullOrEmpty(dependency.getClassifier())) {
```
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11904:
URL: https://github.com/apache/maven/pull/11904#issuecomment-6180148593
<!-- license-declaration-check -->
### ⚠️ License declaration missing
The pull request description must contain at least one of the following lines with a **checked** box (`[x]`):
```markdown
- [ ] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
```
This comment will be hidden automatically once the description is fixed.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11904:
URL: https://github.com/apache/maven/pull/11904#discussion_r4329179117
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -1190,7 +1239,22 @@ private void validate20RawDependencies(
Map<String, Dependency> index = new HashMap<>();
for (Dependency dependency : dependencies) {
- String key = dependency.getManagementKey();
+ // When 'id' attribute is set, extract the GAV portion (stripping @scope and ?)
+ // for deduplication, since normalization has not yet run
+ String key;
+ if (dependency.getId() != null && !dependency.getId().isEmpty()) {
+ key = stripScopeAndOptional(dependency.getId());
+ } else {
+ key = dependency.getManagementKey();
+ }
Review Comment:
Using `stripScopeAndOptional(id)` as the deduplication key changes semantics compared to `dependency.getManagementKey()` because it retains the version portion (and any other id-encoded data) instead of computing the management key fields (typically excluding version). This can cause duplicates that should be detected/merged (same management key but different versions) to be missed for `id`-based dependencies. Fix by deriving a management-key-equivalent from the `id` (strip `@scope` / `?`, split into parts, then build the same key shape as `getManagementKey()` would—e.g., groupId/artifactId/type/classifier with default type handling—instead of using the raw id string).
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/DependencyIdStrategy.java:
##########
@@ -0,0 +1,302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.cling.invoker.mvnup.goals;
+
+import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import eu.maveniverse.domtrip.Document;
+import eu.maveniverse.domtrip.Element;
+import org.apache.maven.api.cli.mvnup.UpgradeOptions;
+import org.apache.maven.api.di.Named;
+import org.apache.maven.api.di.Priority;
+import org.apache.maven.api.di.Singleton;
+import org.apache.maven.cling.invoker.mvnup.UpgradeContext;
+
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.ARTIFACT_ID;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.BUILD;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.CLASSIFIER;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCIES;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCY;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCY_MANAGEMENT;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.EXCLUSION;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.EXCLUSIONS;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.GROUP_ID;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PLUGIN;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PLUGINS;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PROFILE;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PROFILES;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.TYPE;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.VERSION;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.ModelVersions.MODEL_VERSION_4_2_0;
+
+/**
+ * Strategy for collapsing dependency coordinate child elements into compact {@code id} attributes.
+ * Only applies to POMs at model version 4.2.0 or higher.
+ *
+ * <p>Transforms verbose dependency declarations:
+ * <pre>{@code
+ * <dependency>
+ * <groupId>org.example</groupId>
+ * <artifactId>lib</artifactId>
+ * <version>1.0</version>
+ * </dependency>
+ * }</pre>
+ * into compact form:
+ * <pre>{@code
+ * <dependency id="org.example:lib:1.0"/>
+ * }</pre>
+ *
+ * <p>Supported formats (trailing {@code :} means version is managed):
+ * <ul>
+ * <li>{@code g:a} — version managed</li>
+ * <li>{@code g:a:v} — default type "jar"</li>
+ * <li>{@code g:a:type:} — non-default type, version managed</li>
+ * <li>{@code g:a:type:v} — non-default type</li>
+ * <li>{@code g:a:type:classifier:} — with classifier, version managed</li>
+ * <li>{@code g:a:type:classifier:v} — with classifier</li>
+ * </ul>
+ *
+ * <p>Also collapses exclusions from {@code <groupId>}/{@code <artifactId>} into {@code id="g:a"}.
+ */
+@Named
+@Singleton
+@Priority(25)
+public class DependencyIdStrategy extends AbstractUpgradeStrategy {
+
+ private static final String DEFAULT_TYPE = "jar";
+
+ @Override
+ public boolean isApplicable(UpgradeContext context) {
Review Comment:
The class-level Javadoc says this strategy applies to “model version 4.2.0 or higher”, but `isApplicable` currently checks equality with `4.2.0` only. Please either (a) update the Javadoc to say “only 4.2.0” or (b) change applicability logic to treat versions >= 4.2.0 as eligible (if the CLI has a version comparison helper, using that would avoid string-based comparisons).
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/DependencyIdStrategy.java:
##########
@@ -0,0 +1,302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.cling.invoker.mvnup.goals;
+
+import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import eu.maveniverse.domtrip.Document;
+import eu.maveniverse.domtrip.Element;
+import org.apache.maven.api.cli.mvnup.UpgradeOptions;
+import org.apache.maven.api.di.Named;
+import org.apache.maven.api.di.Priority;
+import org.apache.maven.api.di.Singleton;
+import org.apache.maven.cling.invoker.mvnup.UpgradeContext;
+
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.ARTIFACT_ID;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.BUILD;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.CLASSIFIER;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCIES;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCY;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCY_MANAGEMENT;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.EXCLUSION;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.EXCLUSIONS;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.GROUP_ID;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PLUGIN;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PLUGINS;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PROFILE;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PROFILES;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.TYPE;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.VERSION;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.ModelVersions.MODEL_VERSION_4_2_0;
+
+/**
+ * Strategy for collapsing dependency coordinate child elements into compact {@code id} attributes.
+ * Only applies to POMs at model version 4.2.0 or higher.
+ *
Review Comment:
The class-level Javadoc says this strategy applies to “model version 4.2.0 or higher”, but `isApplicable` currently checks equality with `4.2.0` only. Please either (a) update the Javadoc to say “only 4.2.0” or (b) change applicability logic to treat versions >= 4.2.0 as eligible (if the CLI has a version comparison helper, using that would avoid string-based comparisons).
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -1307,6 +1371,165 @@ private void validate20RawDependencies(
}
}
+ private void validateDependencyIdAttribute(ModelProblemCollector problems, Dependency dependency, String prefix) {
+ String id = dependency.getId();
+ if (id == null || id.isEmpty()) {
+ return;
+ }
+
+ String remaining = id;
+ boolean hasOptionalMarker = false;
+ if (remaining.endsWith("?")) {
+ hasOptionalMarker = true;
+ remaining = remaining.substring(0, remaining.length() - 1);
+ }
+
+ boolean hasScopeMarker = false;
+ int atIndex = remaining.lastIndexOf('@');
+ if (atIndex >= 0) {
+ hasScopeMarker = true;
+ remaining = remaining.substring(0, atIndex);
+ }
+
+ int colonCount = remaining.length() - remaining.replace(":", "").length();
+ if (colonCount < 1 || colonCount > 4) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "id",
+ null,
+ "has invalid format '" + id + "', must be 'groupId:artifactId[:]', "
+ + "'groupId:artifactId:version', "
+ + "'groupId:artifactId:type:[version]', or "
+ + "'groupId:artifactId:type:classifier:[version]'. "
+ + "An optional '@scope' suffix and/or trailing '?' may be appended.",
+ dependency);
+ return;
+ }
+ if (!isNullOrEmpty(dependency.getGroupId())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "groupId",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (!isNullOrEmpty(dependency.getArtifactId())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "artifactId",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (!isNullOrEmpty(dependency.getVersion())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "version",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (colonCount >= 3 && !isNullOrEmpty(dependency.getType()) && !"jar".equals(dependency.getType())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "type",
+ null,
+ "must not be specified when 'id' attribute includes type.",
+ dependency);
+ }
+ if (colonCount >= 4 && !isNullOrEmpty(dependency.getClassifier())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "classifier",
+ null,
+ "must not be specified when 'id' attribute includes classifier.",
+ dependency);
+ }
Review Comment:
The conflict checks for `<type>` and `<classifier>` rely only on colon count, which incorrectly flags cases where those *segments are present but empty* (e.g. `org.example:lib::1.0` or `org.example:lib:jar::1.0`). Per the PR description, empty segments mean “not encoded” and should not forbid specifying that field via child elements. Fix by parsing the `id` into parts (e.g., `split(":", -1)` after stripping `@scope` / `?`) and only treating `type`/`classifier` as encoded when the corresponding part exists *and is non-empty* (and for type, only if the id is 4/5-part and `parts[2]` is non-empty; for classifier, only if 5-part and `parts[3]` is non-empty).
##########
impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java:
##########
@@ -800,6 +807,201 @@ private static void warnNotDowngraded(MavenProject project) {
+ "attribute on the <project> element of your POM.");
}
+ /**
+ * Expands {@code id} attributes on {@code <dependency>} and {@code <exclusion>}
+ * elements into their individual GAV fields, then clears the {@code id} attribute.
+ * This mirrors the expansion performed by {@code DefaultModelNormalizer} during
+ * model building and ensures the consumer POM does not contain compact-form
+ * {@code id} attributes that downstream consumers (Maven 3, Gradle) cannot parse.
+ *
+ * @param model the model to expand
+ * @return the model with all dependency/exclusion {@code id} attributes expanded
+ */
+ static Model expandDependencyIds(Model model) {
+ Model.Builder mb = null;
+ List<Dependency> deps = expandDependencyIdList(model.getDependencies());
+ if (deps != null) {
+ mb = Model.newBuilder(model, true);
+ mb.dependencies(deps);
+ }
Review Comment:
The consumer-POM expansion logic duplicates the expansion rules already implemented in `DefaultModelNormalizer` (`expandDependencyId` / `expandExclusionId`) with effectively the same parsing and field-setting behavior. This duplication increases long-term maintenance risk (any future change to id syntax, scope/optional handling, defaults, or inference rules must be updated in two places). Consider extracting the parsing/expansion into a shared utility (or reusing `DefaultModelNormalizer` as a dependency/service) so both code paths stay consistent.
##########
impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java:
##########
@@ -800,6 +807,201 @@ private static void warnNotDowngraded(MavenProject project) {
+ "attribute on the <project> element of your POM.");
}
+ /**
+ * Expands {@code id} attributes on {@code <dependency>} and {@code <exclusion>}
+ * elements into their individual GAV fields, then clears the {@code id} attribute.
+ * This mirrors the expansion performed by {@code DefaultModelNormalizer} during
+ * model building and ensures the consumer POM does not contain compact-form
+ * {@code id} attributes that downstream consumers (Maven 3, Gradle) cannot parse.
+ *
+ * @param model the model to expand
+ * @return the model with all dependency/exclusion {@code id} attributes expanded
+ */
+ static Model expandDependencyIds(Model model) {
+ Model.Builder mb = null;
+ List<Dependency> deps = expandDependencyIdList(model.getDependencies());
+ if (deps != null) {
+ mb = Model.newBuilder(model, true);
+ mb.dependencies(deps);
+ }
+ DependencyManagement mgmt = model.getDependencyManagement();
+ if (mgmt != null) {
+ List<Dependency> mgmtDeps = expandDependencyIdList(mgmt.getDependencies());
+ if (mgmtDeps != null) {
+ if (mb == null) {
+ mb = Model.newBuilder(model, true);
+ }
+ mb.dependencyManagement(DependencyManagement.newBuilder(mgmt, true)
+ .dependencies(mgmtDeps)
+ .build());
+ }
+ }
+ List<Profile> profiles = model.getProfiles();
+ if (!profiles.isEmpty()) {
+ List<Profile> expandedProfiles = null;
+ for (int i = 0; i < profiles.size(); i++) {
+ Profile profile = profiles.get(i);
+ Profile.Builder pb = null;
+ List<Dependency> pdeps = expandDependencyIdList(profile.getDependencies());
+ if (pdeps != null) {
+ pb = Profile.newBuilder(profile, true);
+ pb.dependencies(pdeps);
+ }
+ DependencyManagement pmgmt = profile.getDependencyManagement();
+ if (pmgmt != null) {
+ List<Dependency> pmgmtDeps = expandDependencyIdList(pmgmt.getDependencies());
+ if (pmgmtDeps != null) {
+ if (pb == null) {
+ pb = Profile.newBuilder(profile, true);
+ }
+ pb.dependencyManagement(DependencyManagement.newBuilder(pmgmt, true)
+ .dependencies(pmgmtDeps)
+ .build());
+ }
+ }
+ if (pb != null) {
+ if (expandedProfiles == null) {
+ expandedProfiles = new ArrayList<>(profiles);
+ }
+ expandedProfiles.set(i, pb.build());
+ }
+ }
+ if (expandedProfiles != null) {
+ if (mb == null) {
+ mb = Model.newBuilder(model, true);
+ }
+ mb.profiles(expandedProfiles);
+ }
+ }
+ return mb != null ? mb.build() : model;
+ }
+
+ private static List<Dependency> expandDependencyIdList(List<Dependency> dependencies) {
+ List<Dependency> result = null;
+ for (int i = 0; i < dependencies.size(); i++) {
+ Dependency dep = dependencies.get(i);
+ Dependency expanded = expandSingleDependencyId(dep);
+ if (expanded != dep) {
+ if (result == null) {
+ result = new ArrayList<>(dependencies);
+ }
+ result.set(i, expanded);
+ }
+ }
+ return result;
+ }
+
+ private static Dependency expandSingleDependencyId(Dependency d) {
+ String id = d.getId();
+ if (id == null || id.isEmpty()) {
+ // Still need to check exclusions
+ List<Exclusion> expanded = expandExclusionIdList(d.getExclusions());
+ return expanded != null ? d.withExclusions(expanded) : d;
+ }
Review Comment:
The consumer-POM expansion logic duplicates the expansion rules already implemented in `DefaultModelNormalizer` (`expandDependencyId` / `expandExclusionId`) with effectively the same parsing and field-setting behavior. This duplication increases long-term maintenance risk (any future change to id syntax, scope/optional handling, defaults, or inference rules must be updated in two places). Consider extracting the parsing/expansion into a shared utility (or reusing `DefaultModelNormalizer` as a dependency/service) so both code paths stay consistent.
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -375,6 +376,54 @@ && equals(parent.getArtifactId(), model.getArtifactId())) {
// Validate each mixin
for (Parent mixin : model.getMixins()) {
+ // Validate id/gav attribute format and conflict with child elements
+ if (mixin instanceof Mixin m
+ && m.getGav() != null
+ && !m.getGav().isEmpty()) {
+ String gav = m.getGav();
+ String[] parts = gav.split(":");
+ if (parts.length != 3) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ "mixins.mixin.id",
+ null,
+ "must have the format 'groupId:artifactId:version' but is '" + gav + "'.",
+ mixin);
+ }
Review Comment:
Mixins currently only validate the number of `:` segments, but accept empty segments such as `g::1.0` (artifactId empty) or `:a:1.0` (groupId empty), which then expand into empty/invalid fields. If mixin `id`/`gav` is intended to be strict `groupId:artifactId:version`, validation should also reject empty parts (i.e., require all 3 segments to be non-empty).
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/DependencyIdStrategy.java:
##########
@@ -0,0 +1,302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.cling.invoker.mvnup.goals;
+
+import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import eu.maveniverse.domtrip.Document;
+import eu.maveniverse.domtrip.Element;
+import org.apache.maven.api.cli.mvnup.UpgradeOptions;
+import org.apache.maven.api.di.Named;
+import org.apache.maven.api.di.Priority;
+import org.apache.maven.api.di.Singleton;
+import org.apache.maven.cling.invoker.mvnup.UpgradeContext;
+
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.ARTIFACT_ID;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.BUILD;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.CLASSIFIER;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCIES;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCY;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.DEPENDENCY_MANAGEMENT;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.EXCLUSION;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.EXCLUSIONS;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.GROUP_ID;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PLUGIN;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PLUGINS;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PROFILE;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.PROFILES;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.TYPE;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.Elements.VERSION;
+import static eu.maveniverse.domtrip.maven.MavenPomElements.ModelVersions.MODEL_VERSION_4_2_0;
+
+/**
+ * Strategy for collapsing dependency coordinate child elements into compact {@code id} attributes.
+ * Only applies to POMs at model version 4.2.0 or higher.
+ *
+ * <p>Transforms verbose dependency declarations:
+ * <pre>{@code
+ * <dependency>
+ * <groupId>org.example</groupId>
+ * <artifactId>lib</artifactId>
+ * <version>1.0</version>
+ * </dependency>
+ * }</pre>
+ * into compact form:
+ * <pre>{@code
+ * <dependency id="org.example:lib:1.0"/>
+ * }</pre>
+ *
+ * <p>Supported formats (trailing {@code :} means version is managed):
+ * <ul>
+ * <li>{@code g:a} — version managed</li>
+ * <li>{@code g:a:v} — default type "jar"</li>
+ * <li>{@code g:a:type:} — non-default type, version managed</li>
+ * <li>{@code g:a:type:v} — non-default type</li>
+ * <li>{@code g:a:type:classifier:} — with classifier, version managed</li>
+ * <li>{@code g:a:type:classifier:v} — with classifier</li>
+ * </ul>
+ *
+ * <p>Also collapses exclusions from {@code <groupId>}/{@code <artifactId>} into {@code id="g:a"}.
+ */
+@Named
+@Singleton
+@Priority(25)
+public class DependencyIdStrategy extends AbstractUpgradeStrategy {
+
+ private static final String DEFAULT_TYPE = "jar";
+
+ @Override
+ public boolean isApplicable(UpgradeContext context) {
+ UpgradeOptions options = getOptions(context);
+
+ if (options.all().orElse(false)) {
+ return true;
+ }
+
+ String modelVersion = options.modelVersion().orElse(null);
+ return MODEL_VERSION_4_2_0.equals(modelVersion);
+ }
Review Comment:
The class-level Javadoc says this strategy applies to “model version 4.2.0 or higher”, but `isApplicable` currently checks equality with `4.2.0` only. Please either (a) update the Javadoc to say “only 4.2.0” or (b) change applicability logic to treat versions >= 4.2.0 as eligible (if the CLI has a version comparison helper, using that would avoid string-based comparisons).
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -1307,6 +1371,165 @@ private void validate20RawDependencies(
}
}
+ private void validateDependencyIdAttribute(ModelProblemCollector problems, Dependency dependency, String prefix) {
+ String id = dependency.getId();
+ if (id == null || id.isEmpty()) {
+ return;
+ }
+
+ String remaining = id;
+ boolean hasOptionalMarker = false;
+ if (remaining.endsWith("?")) {
+ hasOptionalMarker = true;
+ remaining = remaining.substring(0, remaining.length() - 1);
+ }
+
+ boolean hasScopeMarker = false;
+ int atIndex = remaining.lastIndexOf('@');
+ if (atIndex >= 0) {
+ hasScopeMarker = true;
+ remaining = remaining.substring(0, atIndex);
+ }
+
+ int colonCount = remaining.length() - remaining.replace(":", "").length();
+ if (colonCount < 1 || colonCount > 4) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "id",
+ null,
+ "has invalid format '" + id + "', must be 'groupId:artifactId[:]', "
+ + "'groupId:artifactId:version', "
+ + "'groupId:artifactId:type:[version]', or "
+ + "'groupId:artifactId:type:classifier:[version]'. "
+ + "An optional '@scope' suffix and/or trailing '?' may be appended.",
+ dependency);
+ return;
+ }
+ if (!isNullOrEmpty(dependency.getGroupId())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "groupId",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (!isNullOrEmpty(dependency.getArtifactId())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "artifactId",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (!isNullOrEmpty(dependency.getVersion())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "version",
+ null,
+ "must not be specified when 'id' attribute is used.",
+ dependency);
+ }
+ if (colonCount >= 3 && !isNullOrEmpty(dependency.getType()) && !"jar".equals(dependency.getType())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "type",
+ null,
+ "must not be specified when 'id' attribute includes type.",
+ dependency);
+ }
+ if (colonCount >= 4 && !isNullOrEmpty(dependency.getClassifier())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "classifier",
+ null,
+ "must not be specified when 'id' attribute includes classifier.",
+ dependency);
+ }
+ if (hasScopeMarker && !isNullOrEmpty(dependency.getScope())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "scope",
+ null,
+ "must not be specified when 'id' attribute contains '@scope'.",
+ dependency);
+ }
+ if (hasOptionalMarker && !isNullOrEmpty(dependency.getOptional())) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "optional",
+ null,
+ "must not be specified when 'id' attribute contains '?'.",
+ dependency);
+ }
+ }
+
+ private static String stripScopeAndOptional(String id) {
+ String remaining = id;
+ if (remaining.endsWith("?")) {
+ remaining = remaining.substring(0, remaining.length() - 1);
+ }
+ int atIndex = remaining.lastIndexOf('@');
+ if (atIndex >= 0) {
+ remaining = remaining.substring(0, atIndex);
+ }
+ return remaining;
+ }
+
+ private void validateExclusionIdAttribute(ModelProblemCollector problems, Exclusion exclusion, String prefix) {
+ String id = exclusion.getId();
+ if (id == null || id.isEmpty()) {
+ return;
+ }
+ int colonCount = id.length() - id.replace(":", "").length();
+ if (colonCount != 1) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ Version.V42,
+ prefix + "exclusions.exclusion.id",
+ null,
+ "has invalid format '" + id + "', must be 'groupId:artifactId'.",
+ exclusion);
+ return;
+ }
Review Comment:
The exclusion `id` validator only checks `colonCount == 1`, which allows invalid values like `:artifactId`, `groupId:`, or `:` (empty segments). Since exclusions are documented as `groupId:artifactId` (and tests already treat “only-one-part” as invalid), the validator should also ensure both segments are non-empty (or explicitly whitelist the wildcard case `*:*` if that’s intended to be valid everywhere).
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #11904:
URL: https://github.com/apache/maven/pull/11904#discussion_r3284342495
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelNormalizer.java:
##########
@@ -76,15 +81,20 @@ public Model mergeDuplicates(Model model, ModelBuilderRequest request, ModelProb
* the way 2.x works. When we're in strict mode, the removal of duplicates just saves other merging steps from
* aftereffects and bogus error messages.
*/
+ // Expand id attributes on dependencies (and their exclusions), then deduplicate
List<Dependency> dependencies = model.getDependencies();
- Map<String, Dependency> normalized = new LinkedHashMap<>(dependencies.size() * 2);
+ List<Dependency> expanded = injectList(dependencies, this::expandDependencyId);
+ if (expanded != null) {
Review Comment:
This only expands `id` on top-level dependencies. Dependency management dependencies (`model.getDependencyManagement().getDependencies()`) and profile-scoped dependencies are also validated for `id` attribute conflicts (see `DefaultModelValidator` lines 536-596), but they won't be expanded here.
Should the expansion also apply to:
- `model.getDependencyManagement().getDependencies()`
- `profile.getDependencies()`
- `profile.getDependencyManagement().getDependencies()`
Without this, a user writing `<dependency id="g:a:v"/>` in `<dependencyManagement>` will pass validation but the GAV fields will never be populated.
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelNormalizer.java:
##########
@@ -144,4 +154,92 @@ private <T> List<T> injectList(List<T> list, UnaryOperator<T> modifer) {
}
return newList;
}
+
+ /**
+ * Expands the {@code id} attribute on a dependency into its component fields.
+ * The id format is {@code groupId:artifactId:version}.
+ */
+ Dependency expandDependencyId(Dependency d) {
+ String id = d.getId();
+ if (id == null || id.isEmpty()) {
+ // No id attribute, but still expand exclusion ids
+ List<Exclusion> expanded = injectList(d.getExclusions(), this::expandExclusionId);
+ return expanded != null ? d.withExclusions(expanded) : d;
+ }
+ String[] parts = id.split(":");
+ if (parts.length != 3) {
+ // Invalid format — will be caught by the validator
+ return d;
+ }
+ Dependency.Builder builder = Dependency.newBuilder(d);
+ if (isBlank(d.getGroupId())) {
+ builder.groupId(parts[0]);
+ }
+ if (isBlank(d.getArtifactId())) {
+ builder.artifactId(parts[1]);
+ }
+ if (isBlank(d.getVersion())) {
+ builder.version(parts[2]);
+ }
+ List<Exclusion> expanded = injectList(d.getExclusions(), this::expandExclusionId);
+ if (expanded != null) {
+ builder.exclusions(expanded);
+ }
+ return builder.build();
+ }
+
+ /**
+ * Expands the {@code id} attribute on an exclusion into its component fields.
+ * The id format is {@code groupId:artifactId}.
+ */
+ Exclusion expandExclusionId(Exclusion e) {
+ String id = e.getId();
+ if (id == null || id.isEmpty()) {
+ return e;
+ }
+ String[] parts = id.split(":");
+ if (parts.length != 2) {
+ // Invalid format — will be caught by the validator
+ return e;
+ }
+ Exclusion.Builder builder = Exclusion.newBuilder(e);
+ if (isBlank(e.getGroupId())) {
+ builder.groupId(parts[0]);
+ }
+ if (isBlank(e.getArtifactId())) {
+ builder.artifactId(parts[1]);
+ }
+ return builder.build();
+ }
+
+ /**
+ * Expands the {@code id} (XML attribute) / {@code gav} (Java field) on a mixin
+ * into its component fields. The format is {@code groupId:artifactId:version}.
+ */
+ Mixin expandMixinGav(Mixin m) {
+ String gav = m.getGav();
+ if (gav == null || gav.isEmpty()) {
+ return m;
+ }
+ String[] parts = gav.split(":");
+ if (parts.length != 3) {
+ // Invalid format — will be caught by the validator
+ return m;
+ }
+ Mixin.Builder builder = Mixin.newBuilder(m);
+ if (isBlank(m.getGroupId())) {
+ builder.groupId(parts[0]);
+ }
+ if (isBlank(m.getArtifactId())) {
+ builder.artifactId(parts[1]);
+ }
+ if (isBlank(m.getVersion())) {
+ builder.version(parts[2]);
+ }
+ return builder.build();
+ }
+
Review Comment:
Nit: this method name is misleading -- `String.isBlank()` in Java checks for whitespace-only strings, but this only checks null/empty. Consider renaming to `isNullOrEmpty` to avoid confusion, or use `s == null || s.isBlank()` to also handle whitespace-only values in coordinates.
```suggestion
private static boolean isNullOrEmpty(String s) {
return s == null || s.isEmpty();
}
```
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelNormalizer.java:
##########
@@ -144,4 +154,92 @@ private <T> List<T> injectList(List<T> list, UnaryOperator<T> modifer) {
}
return newList;
}
+
+ /**
+ * Expands the {@code id} attribute on a dependency into its component fields.
+ * The id format is {@code groupId:artifactId:version}.
+ */
+ Dependency expandDependencyId(Dependency d) {
+ String id = d.getId();
+ if (id == null || id.isEmpty()) {
+ // No id attribute, but still expand exclusion ids
+ List<Exclusion> expanded = injectList(d.getExclusions(), this::expandExclusionId);
+ return expanded != null ? d.withExclusions(expanded) : d;
+ }
+ String[] parts = id.split(":");
Review Comment:
The normalizer silently ignores the `id` when the format is wrong (`parts.length != 3`), deferring to the validator. But if the validator and normalizer both split on `:`, and the user writes `g:a:v:extra`, the split produces 4 parts -- the normalizer skips it, and the validator also rejects it. This is fine.
However, consider that `String.split(":")` has edge cases: trailing empty strings are removed by default. For example, `"g:a:"` splits to `["g", "a"]` (length 2, not 3). This means a dependency `id="g:a:"` would silently fail normalization AND pass the `parts.length != 3` check in the validator -- resulting in a format error, which is correct. Just worth being aware of the edge case.
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -1138,7 +1187,22 @@ private void validate20RawDependencies(
Map<String, Dependency> index = new HashMap<>();
for (Dependency dependency : dependencies) {
- String key = dependency.getManagementKey();
+ // When 'id' attribute is set, use it for the key since groupId/artifactId
+ // have not yet been expanded (normalization runs after validation)
+ String key;
+ if (dependency.getId() != null && !dependency.getId().isEmpty()) {
+ key = dependency.getId();
+ } else {
+ key = dependency.getManagementKey();
Review Comment:
Good approach using `dependency.getId()` as the dedup key when set, since normalization hasn't run yet at this point. However, two dependencies with the same `id` attribute but different scopes/classifiers would collide here (since the key is just the raw `id` string, not the management key). After normalization, they'd have distinct management keys (which includes type and classifier). Is this the intended behavior?
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "rbygrave (via GitHub)" <gi...@apache.org>.
rbygrave commented on code in PR #11904:
URL: https://github.com/apache/maven/pull/11904#discussion_r3049778214
##########
api/maven-api-model/src/main/mdo/maven.mdo:
##########
@@ -1863,6 +1891,20 @@
<version>4.1.0+</version>
<superClass>Parent</superClass>
<fields>
+ <field xml.attribute="true" xml.tagName="id">
+ <name>gav</name>
Review Comment:
Using field name `gav` with attribute name `id` ... in order to avoid the conflict with the existing `Parent.getId()`
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "rmannibucau (via GitHub)" <gi...@apache.org>.
rmannibucau commented on PR #11904:
URL: https://github.com/apache/maven/pull/11904#issuecomment-6294886201
A few note - don't take them all as a "no" but more as what was my expectations on this topic:
* groupId:artifactId:type:classifier:version
* no need of trailing ":" hack, a managed version has no version tag so not an issue
* i wouldnt collapse scope at all, it is harder to read, misleading and not the identity of the dependency at all
* why would exclusions not be inlined?
* never infer groupId, can only lead to issues
* must include extensions, plugins, etc... too
more generally speaking not collapsing anything but keeping 1 value per "field" sounds saner on the long run (ivy style) cause it doesn't imply to create a custom language in another language (xml) which is saner and more tool friendly (i know xslt 3 enables crazy things but let's not need it).
Will also solve the `groupId:artifactId:type:classifier:version` order definition which is very misleading, not normalized and generally enforces to type more info than needed.
So overall I would just move children as attributes and drop the inference for groupId.
That's the best outcome I went with this topic over the last years of discussion.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #11904:
URL: https://github.com/apache/maven/pull/11904#issuecomment-6180184258
The `license-declaration` CI check is failing because of a typo in the PR description.
The description currently reads:
```
- [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
```
The check requires the exact text **"licensed"** (not "licenced"). Please edit the PR description and change `licenced` → `licensed` on that line to unblock CI.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #11904:
URL: https://github.com/apache/maven/pull/11904#issuecomment-6300475510
@linghengqian Not TCP handshakes, just iterative review cycles 😄
Each approval corresponds to a distinct push by the contributor that addressed findings from the previous review pass:
- 1st approval (Sep 10): after the type-check inconsistency between normalizer and consumer POM builder was fixed
- 2nd approval (Sep 24): docs-only push (EXPECT comments on XML fixtures) — no behavior change, previous approval rationale still valid
- 3rd approval (Oct 20): after the off-by-one thresholds in the type/classifier conflict checks and the dedup key semantics were fixed
GitHub dismisses a previous approval when new commits are pushed, so each round of fixes requires a fresh approval to keep the `reviewDecision: APPROVED` state. The bot re-reviews each push and approves again if the findings are resolved. Three pushes addressing findings → three approvals.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #11904:
URL: https://github.com/apache/maven/pull/11904#discussion_r3973616378
##########
impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java:
##########
@@ -800,6 +807,197 @@ private static void warnNotDowngraded(MavenProject project) {
+ "attribute on the <project> element of your POM.");
}
+ /**
+ * Expands {@code id} attributes on {@code <dependency>} and {@code <exclusion>}
+ * elements into their individual GAV fields, then clears the {@code id} attribute.
+ * This mirrors the expansion performed by {@code DefaultModelNormalizer} during
+ * model building and ensures the consumer POM does not contain compact-form
+ * {@code id} attributes that downstream consumers (Maven 3, Gradle) cannot parse.
+ *
+ * @param model the model to expand
+ * @return the model with all dependency/exclusion {@code id} attributes expanded
+ */
+ static Model expandDependencyIds(Model model) {
+ Model.Builder mb = null;
+ List<Dependency> deps = expandDependencyIdList(model.getDependencies());
+ if (deps != null) {
+ mb = Model.newBuilder(model, true);
+ mb.dependencies(deps);
+ }
+ DependencyManagement mgmt = model.getDependencyManagement();
+ if (mgmt != null) {
+ List<Dependency> mgmtDeps = expandDependencyIdList(mgmt.getDependencies());
+ if (mgmtDeps != null) {
+ if (mb == null) {
+ mb = Model.newBuilder(model, true);
+ }
+ mb.dependencyManagement(DependencyManagement.newBuilder(mgmt, true)
+ .dependencies(mgmtDeps)
+ .build());
+ }
+ }
+ List<Profile> profiles = model.getProfiles();
+ if (!profiles.isEmpty()) {
+ List<Profile> expandedProfiles = null;
+ for (int i = 0; i < profiles.size(); i++) {
+ Profile profile = profiles.get(i);
+ Profile.Builder pb = null;
+ List<Dependency> pdeps = expandDependencyIdList(profile.getDependencies());
+ if (pdeps != null) {
+ pb = Profile.newBuilder(profile, true);
+ pb.dependencies(pdeps);
+ }
+ DependencyManagement pmgmt = profile.getDependencyManagement();
+ if (pmgmt != null) {
+ List<Dependency> pmgmtDeps = expandDependencyIdList(pmgmt.getDependencies());
+ if (pmgmtDeps != null) {
+ if (pb == null) {
+ pb = Profile.newBuilder(profile, true);
+ }
+ pb.dependencyManagement(DependencyManagement.newBuilder(pmgmt, true)
+ .dependencies(pmgmtDeps)
+ .build());
+ }
+ }
+ if (pb != null) {
+ if (expandedProfiles == null) {
+ expandedProfiles = new ArrayList<>(profiles);
+ }
+ expandedProfiles.set(i, pb.build());
+ }
+ }
+ if (expandedProfiles != null) {
+ if (mb == null) {
+ mb = Model.newBuilder(model, true);
+ }
+ mb.profiles(expandedProfiles);
+ }
+ }
+ return mb != null ? mb.build() : model;
+ }
+
+ private static List<Dependency> expandDependencyIdList(List<Dependency> dependencies) {
+ List<Dependency> result = null;
+ for (int i = 0; i < dependencies.size(); i++) {
+ Dependency dep = dependencies.get(i);
+ Dependency expanded = expandSingleDependencyId(dep);
+ if (expanded != dep) {
+ if (result == null) {
+ result = new ArrayList<>(dependencies);
+ }
+ result.set(i, expanded);
+ }
+ }
+ return result;
+ }
+
+ private static Dependency expandSingleDependencyId(Dependency d) {
+ String id = d.getId();
+ if (id == null || id.isEmpty()) {
+ // Still need to check exclusions
+ List<Exclusion> expanded = expandExclusionIdList(d.getExclusions());
+ return expanded != null ? d.withExclusions(expanded) : d;
+ }
+
+ String remaining = id;
+ boolean optional = false;
+ if (remaining.endsWith("?")) {
+ optional = true;
+ remaining = remaining.substring(0, remaining.length() - 1);
+ }
+
+ String scope = null;
+ int atIndex = remaining.lastIndexOf('@');
+ if (atIndex >= 0) {
+ scope = remaining.substring(atIndex + 1);
+ remaining = remaining.substring(0, atIndex);
+ }
+
+ String[] parts = remaining.split(":", -1);
+ if (parts.length < 2 || parts.length > 5) {
+ return d;
+ }
+ Dependency.Builder builder = Dependency.newBuilder(d, true);
+ builder.id(null);
+ if (!parts[0].isEmpty() && isNullOrEmpty(d.getGroupId())) {
+ builder.groupId(parts[0]);
+ }
+ if (!parts[1].isEmpty() && isNullOrEmpty(d.getArtifactId())) {
+ builder.artifactId(parts[1]);
+ }
+ switch (parts.length) {
+ case 2:
+ break;
+ case 3:
+ if (!parts[2].isEmpty() && isNullOrEmpty(d.getVersion())) {
+ builder.version(parts[2]);
+ }
+ break;
+ case 4:
+ if (!parts[2].isEmpty() && isNullOrEmpty(d.getType())) {
Review Comment:
Fixed in `4632bb8c13`: both case-4 and case-5 now use `isNullOrEmptyOrDefault(d.getType())`, and the missing `isNullOrEmptyOrDefault` helper is added to the consumer POM builder.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #11904:
URL: https://github.com/apache/maven/pull/11904#discussion_r4090484713
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelNormalizer.java:
##########
@@ -144,4 +154,92 @@ private <T> List<T> injectList(List<T> list, UnaryOperator<T> modifer) {
}
return newList;
}
+
+ /**
+ * Expands the {@code id} attribute on a dependency into its component fields.
+ * The id format is {@code groupId:artifactId:version}.
+ */
+ Dependency expandDependencyId(Dependency d) {
+ String id = d.getId();
+ if (id == null || id.isEmpty()) {
+ // No id attribute, but still expand exclusion ids
+ List<Exclusion> expanded = injectList(d.getExclusions(), this::expandExclusionId);
+ return expanded != null ? d.withExclusions(expanded) : d;
+ }
+ String[] parts = id.split(":");
+ if (parts.length != 3) {
+ // Invalid format — will be caught by the validator
+ return d;
+ }
+ Dependency.Builder builder = Dependency.newBuilder(d);
+ if (isBlank(d.getGroupId())) {
+ builder.groupId(parts[0]);
+ }
+ if (isBlank(d.getArtifactId())) {
+ builder.artifactId(parts[1]);
+ }
+ if (isBlank(d.getVersion())) {
+ builder.version(parts[2]);
+ }
+ List<Exclusion> expanded = injectList(d.getExclusions(), this::expandExclusionId);
+ if (expanded != null) {
+ builder.exclusions(expanded);
+ }
+ return builder.build();
+ }
+
+ /**
+ * Expands the {@code id} attribute on an exclusion into its component fields.
+ * The id format is {@code groupId:artifactId}.
+ */
+ Exclusion expandExclusionId(Exclusion e) {
+ String id = e.getId();
+ if (id == null || id.isEmpty()) {
+ return e;
+ }
+ String[] parts = id.split(":");
+ if (parts.length != 2) {
+ // Invalid format — will be caught by the validator
+ return e;
+ }
+ Exclusion.Builder builder = Exclusion.newBuilder(e);
+ if (isBlank(e.getGroupId())) {
+ builder.groupId(parts[0]);
+ }
+ if (isBlank(e.getArtifactId())) {
+ builder.artifactId(parts[1]);
+ }
+ return builder.build();
+ }
+
+ /**
+ * Expands the {@code id} (XML attribute) / {@code gav} (Java field) on a mixin
+ * into its component fields. The format is {@code groupId:artifactId:version}.
+ */
+ Mixin expandMixinGav(Mixin m) {
+ String gav = m.getGav();
+ if (gav == null || gav.isEmpty()) {
+ return m;
+ }
+ String[] parts = gav.split(":");
+ if (parts.length != 3) {
+ // Invalid format — will be caught by the validator
+ return m;
+ }
+ Mixin.Builder builder = Mixin.newBuilder(m);
+ if (isBlank(m.getGroupId())) {
+ builder.groupId(parts[0]);
+ }
+ if (isBlank(m.getArtifactId())) {
+ builder.artifactId(parts[1]);
+ }
+ if (isBlank(m.getVersion())) {
+ builder.version(parts[2]);
+ }
+ return builder.build();
+ }
+
Review Comment:
Fixed in earlier commit — the method is now named `isNullOrEmpty` throughout.
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -1138,7 +1187,22 @@ private void validate20RawDependencies(
Map<String, Dependency> index = new HashMap<>();
for (Dependency dependency : dependencies) {
- String key = dependency.getManagementKey();
+ // When 'id' attribute is set, use it for the key since groupId/artifactId
+ // have not yet been expanded (normalization runs after validation)
+ String key;
+ if (dependency.getId() != null && !dependency.getId().isEmpty()) {
+ key = dependency.getId();
+ } else {
+ key = dependency.getManagementKey();
Review Comment:
Acknowledged as intentional design — the validator prohibits mixing `id` and explicit child elements (groupId/artifactId/version) on the same dependency, so two deps with the same raw `id` but different scopes/classifiers would be caught before reaching this dedup path. Low practical impact; noted in the latest review.
##########
its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh11904DependencyIdAttributeTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.it;
+
+import java.io.Reader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.apache.maven.api.model.Model;
+import org.apache.maven.model.v4.MavenStaxReader;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Integration test for <a href="https://github.com/apache/maven/pull/11904">GH-11904</a>.
+ * Verifies that dependency {@code id} attributes are expanded into individual
+ * GAV elements in the consumer POM and that no {@code id} attribute remains.
+ */
+class MavenITgh11904DependencyIdAttributeTest extends AbstractMavenIntegrationTestCase {
+
+ MavenITgh11904DependencyIdAttributeTest() {
+ super("[4.0.0-rc-3-SNAPSHOT,)");
Review Comment:
Fixed in `f585904284`: switched to no-arg constructor.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #11904:
URL: https://github.com/apache/maven/pull/11904#discussion_r3973577240
##########
impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java:
##########
@@ -800,6 +807,197 @@ private static void warnNotDowngraded(MavenProject project) {
+ "attribute on the <project> element of your POM.");
}
+ /**
+ * Expands {@code id} attributes on {@code <dependency>} and {@code <exclusion>}
+ * elements into their individual GAV fields, then clears the {@code id} attribute.
+ * This mirrors the expansion performed by {@code DefaultModelNormalizer} during
+ * model building and ensures the consumer POM does not contain compact-form
+ * {@code id} attributes that downstream consumers (Maven 3, Gradle) cannot parse.
+ *
+ * @param model the model to expand
+ * @return the model with all dependency/exclusion {@code id} attributes expanded
+ */
+ static Model expandDependencyIds(Model model) {
+ Model.Builder mb = null;
+ List<Dependency> deps = expandDependencyIdList(model.getDependencies());
+ if (deps != null) {
+ mb = Model.newBuilder(model, true);
+ mb.dependencies(deps);
+ }
+ DependencyManagement mgmt = model.getDependencyManagement();
+ if (mgmt != null) {
+ List<Dependency> mgmtDeps = expandDependencyIdList(mgmt.getDependencies());
+ if (mgmtDeps != null) {
+ if (mb == null) {
+ mb = Model.newBuilder(model, true);
+ }
+ mb.dependencyManagement(DependencyManagement.newBuilder(mgmt, true)
+ .dependencies(mgmtDeps)
+ .build());
+ }
+ }
+ List<Profile> profiles = model.getProfiles();
+ if (!profiles.isEmpty()) {
+ List<Profile> expandedProfiles = null;
+ for (int i = 0; i < profiles.size(); i++) {
+ Profile profile = profiles.get(i);
+ Profile.Builder pb = null;
+ List<Dependency> pdeps = expandDependencyIdList(profile.getDependencies());
+ if (pdeps != null) {
+ pb = Profile.newBuilder(profile, true);
+ pb.dependencies(pdeps);
+ }
+ DependencyManagement pmgmt = profile.getDependencyManagement();
+ if (pmgmt != null) {
+ List<Dependency> pmgmtDeps = expandDependencyIdList(pmgmt.getDependencies());
+ if (pmgmtDeps != null) {
+ if (pb == null) {
+ pb = Profile.newBuilder(profile, true);
+ }
+ pb.dependencyManagement(DependencyManagement.newBuilder(pmgmt, true)
+ .dependencies(pmgmtDeps)
+ .build());
+ }
+ }
+ if (pb != null) {
+ if (expandedProfiles == null) {
+ expandedProfiles = new ArrayList<>(profiles);
+ }
+ expandedProfiles.set(i, pb.build());
+ }
+ }
+ if (expandedProfiles != null) {
+ if (mb == null) {
+ mb = Model.newBuilder(model, true);
+ }
+ mb.profiles(expandedProfiles);
+ }
+ }
+ return mb != null ? mb.build() : model;
+ }
+
+ private static List<Dependency> expandDependencyIdList(List<Dependency> dependencies) {
+ List<Dependency> result = null;
+ for (int i = 0; i < dependencies.size(); i++) {
+ Dependency dep = dependencies.get(i);
+ Dependency expanded = expandSingleDependencyId(dep);
+ if (expanded != dep) {
+ if (result == null) {
+ result = new ArrayList<>(dependencies);
+ }
+ result.set(i, expanded);
+ }
+ }
+ return result;
+ }
+
+ private static Dependency expandSingleDependencyId(Dependency d) {
+ String id = d.getId();
+ if (id == null || id.isEmpty()) {
+ // Still need to check exclusions
+ List<Exclusion> expanded = expandExclusionIdList(d.getExclusions());
+ return expanded != null ? d.withExclusions(expanded) : d;
+ }
+
+ String remaining = id;
+ boolean optional = false;
+ if (remaining.endsWith("?")) {
+ optional = true;
+ remaining = remaining.substring(0, remaining.length() - 1);
+ }
+
+ String scope = null;
+ int atIndex = remaining.lastIndexOf('@');
+ if (atIndex >= 0) {
+ scope = remaining.substring(atIndex + 1);
+ remaining = remaining.substring(0, atIndex);
+ }
+
+ String[] parts = remaining.split(":", -1);
+ if (parts.length < 2 || parts.length > 5) {
+ return d;
+ }
+ Dependency.Builder builder = Dependency.newBuilder(d, true);
+ builder.id(null);
+ if (!parts[0].isEmpty() && isNullOrEmpty(d.getGroupId())) {
+ builder.groupId(parts[0]);
+ }
+ if (!parts[1].isEmpty() && isNullOrEmpty(d.getArtifactId())) {
+ builder.artifactId(parts[1]);
+ }
+ switch (parts.length) {
+ case 2:
+ break;
+ case 3:
+ if (!parts[2].isEmpty() && isNullOrEmpty(d.getVersion())) {
+ builder.version(parts[2]);
+ }
+ break;
+ case 4:
+ if (!parts[2].isEmpty() && isNullOrEmpty(d.getType())) {
Review Comment:
This uses `isNullOrEmpty(d.getType())` but the equivalent code in `DefaultModelNormalizer` (line 264) uses `isNullOrEmptyOrDefault(d.getType())` — which also treats `"jar"` as empty/default. The normalizer version is more correct: if a dependency already has `type="jar"` set explicitly, the normalizer will still set the type from the `id` attribute, but this consumer POM builder code won't. Consider using `isNullOrEmptyOrDefault` here too for consistency, or better yet, extract the shared parsing logic.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feat: Add id attribute (gav) support to Dependency, Exclusion, Mixin [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #11904:
URL: https://github.com/apache/maven/pull/11904#discussion_r3646570512
##########
its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh11904DependencyIdAttributeTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.it;
+
+import java.io.Reader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.apache.maven.api.model.Model;
+import org.apache.maven.model.v4.MavenStaxReader;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Integration test for <a href="https://github.com/apache/maven/pull/11904">GH-11904</a>.
+ * Verifies that dependency {@code id} attributes are expanded into individual
+ * GAV elements in the consumer POM and that no {@code id} attribute remains.
+ */
+class MavenITgh11904DependencyIdAttributeTest extends AbstractMavenIntegrationTestCase {
+
+ MavenITgh11904DependencyIdAttributeTest() {
+ super("[4.0.0-rc-3-SNAPSHOT,)");
Review Comment:
`AbstractMavenIntegrationTestCase` only has a no-arg constructor (the `super(String)` pattern was removed in commit `be9541cb9d`). This causes a compilation error that breaks all 9 integration-test CI jobs.
```suggestion
MavenITgh11904DependencyIdAttributeTest() {}
```
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org