Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
goutamadwant commented on code in PR #13081:
URL: https://github.com/apache/maven/pull/13081#discussion_r4090310714
##
compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:
##
@@ -1187,136 +1182,227 @@ private void importDependencyManagement(
it.remove();
-String groupId = dependency.getGroupId();
-String artifactId = dependency.getArtifactId();
-String version = dependency.getVersion();
-
-if (groupId == null || groupId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.groupId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (artifactId == null || artifactId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.artifactId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (version == null || version.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.version' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
+DependencyManagement importedManagement =
+loadDependencyManagement(dependency, model, request,
problems, importIds);
+if (importedManagement != null) {
+if (importedManagements == null) {
+importedManagements = new ArrayList<>();
+}
+importedManagements.add(importedManagement);
}
+}
-String imported = groupId + ':' + artifactId + ':' + version;
+importIds.remove(importing);
-if (importIds.contains(imported)) {
-StringBuilder message =
-new StringBuilder("The dependencies of type=pom and
with scope=import form a cycle: ");
-for (String modelId : importIds) {
-message.append(modelId);
-message.append(" -> ");
-}
-message.append(imported);
-problems.add(
-new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE).setMessage(message.toString()));
+dependencyManagementImporter.importManagement(model,
importedManagements, request, problems);
+}
-continue;
+private DependencyManagement loadDependencyManagement(
Review Comment:
Addressed. The compat builder retains its previous BOM-import behavior. Only
the workspace-miss guard for a missing fallback ModelResolver remains, with
focused tests for workspace hits, misses, fallback, resolver failure, and
unchanged relocation 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
goutamadwant commented on code in PR #13081:
URL: https://github.com/apache/maven/pull/13081#discussion_r4090309188
##
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java:
##
@@ -2505,21 +2493,115 @@ private DependencyManagement
loadDependencyManagement(Dependency dependency, Col
.build();
}
+private Model loadImportModel(Dependency dependency, ImportContext
context) {
+Collection importIds = context.importIds;
+String groupId = dependency.getGroupId();
+String artifactId = dependency.getArtifactId();
+String version = dependency.getVersion();
+String imported = groupId + ':' + artifactId + ':' + version;
+
+if (importIds.contains(imported)) {
+StringBuilder message = new StringBuilder("The import POMs
form a cycle: ");
+for (String modelId : importIds) {
+message.append(modelId).append(" -> ");
+}
+message.append(imported);
+if (context.cycleIncludesRelocation(imported)) {
+context.reportRelocationProblem(message.toString(),
dependency.getLocation(""), null);
+} else {
+add(Severity.ERROR, Version.BASE, message.toString());
+}
+return null;
+}
+
+ImportModelCacheEntry cached =
+cache(repositories, groupId, artifactId, version, null,
IMPORT, ImportModelCacheEntry::new);
+ImportedModel importedModel = cached.model;
+if (importedModel == null) {
+boolean locked = cached.lock.tryLock();
+if (!locked && context.relocationSources.isEmpty()) {
+cached.lock.lock();
+locked = true;
+}
+try {
+importedModel = cached.model;
+if (importedModel == null) {
+// A relocation may lead back to an import being built
by another thread.
+// Only these paths avoid waiting; ordinary imports
still share one in-flight build.
+importedModel = doLoadDependencyManagement(dependency,
groupId, artifactId, version, context);
+if (locked && importedModel != null) {
+cached.model = importedModel;
+}
+}
+} finally {
+if (locked) {
+cached.lock.unlock();
+}
+}
+}
+if (importedModel == null) {
+return null;
+}
+
+Model importModel = importedModel.model();
+Relocation relocation = importModel.getDistributionManagement() !=
null
+? importModel.getDistributionManagement().getRelocation()
+: null;
+if (relocation != null) {
+if (!validateRelocationCoordinate(relocation.getGroupId(),
"groupId", dependency, context)
+||
!validateRelocationCoordinate(relocation.getArtifactId(), "artifactId",
dependency, context)
+||
!validateRelocationCoordinate(relocation.getVersion(), "version", dependency,
context)) {
+return null;
+}
+Dependency.Builder relocated =
Dependency.newBuilder(dependency).version(importedModel.version());
+if (relocation.getGroupId() != null &&
!relocation.getGroupId().isEmpty()) {
+relocated.groupId(relocation.getGroupId());
+}
+if (relocation.getArtifactId() != null
+&& !relocation.getArtifactId().isEmpty()) {
+relocated.artifactId(relocation.getArtifactId());
+}
+if (relocation.getVersion() != null &&
!relocation.getVersion().isEmpty()) {
+relocated.version(relocation.getVersion());
+}
+Dependency relocatedDependency = relocated.build();
+String message = "The import POM " + imported + " has been
relocated to "
++ relocatedDependency.getGroupId() + ':' +
relocatedDependency.getArtifactId() + ':'
++ relocatedDependency.getVersion();
+if (relocation.getMessage() != null) {
+message += ": " + relocation.getMessage();
+}
+add(Severity.WARNING, Version.BASE, message,
dependency.getLocation(""));
Review Comment:
Addressed. A direct import relocation remains a WARNING at the declaration
location. Later hops and relocations encountered while building another BOM are
DEBUG. The partial-chain regression asserts that only the direct hop warns.
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
goutamadwant commented on PR #13081: URL: https://github.com/apache/maven/pull/13081#issuecomment-5808383854 @gnodet Addressed the non-actionable warnings. The Maven 4 builder now warns only for a direct BOM import; later relocation hops and relocations inside imported BOMs are DEBUG. I also removed relocation handling from the deprecated compat builder, retaining only the workspace-miss resolver guard. The warning and concurrent-cycle regressions pass, as do `mvn verify` and the MNG-5527 Core IT. Please take another look. -- 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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
gnodet commented on PR #13081: URL: https://github.com/apache/maven/pull/13081#issuecomment-5802145862 @elharo > Bot reviews like this one seem useful, but I'm not OK with them requiring changes. In that very case, the bot did approve the PR. After me reviewing the PR, I instructed the bot to actually request changes for the non actionable warnings. Dismissing the review, given it seems we both agree sounds a bit too much imho. I don't mind people replying and argument to the review and actually disregarding it, that's fine, but dismissing the correct review because it has been raised by a bot is wrong imho. -- 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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
gnodet-bot commented on code in PR #13081:
URL: https://github.com/apache/maven/pull/13081#discussion_r4069556526
##
compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:
##
@@ -1187,136 +1182,227 @@ private void importDependencyManagement(
it.remove();
-String groupId = dependency.getGroupId();
-String artifactId = dependency.getArtifactId();
-String version = dependency.getVersion();
-
-if (groupId == null || groupId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.groupId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (artifactId == null || artifactId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.artifactId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (version == null || version.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.version' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
+DependencyManagement importedManagement =
+loadDependencyManagement(dependency, model, request,
problems, importIds);
+if (importedManagement != null) {
+if (importedManagements == null) {
+importedManagements = new ArrayList<>();
+}
+importedManagements.add(importedManagement);
}
+}
-String imported = groupId + ':' + artifactId + ':' + version;
+importIds.remove(importing);
-if (importIds.contains(imported)) {
-StringBuilder message =
-new StringBuilder("The dependencies of type=pom and
with scope=import form a cycle: ");
-for (String modelId : importIds) {
-message.append(modelId);
-message.append(" -> ");
-}
-message.append(imported);
-problems.add(
-new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE).setMessage(message.toString()));
+dependencyManagementImporter.importManagement(model,
importedManagements, request, problems);
+}
-continue;
+private DependencyManagement loadDependencyManagement(
Review Comment:
The compat `DefaultModelBuilder` is `@Deprecated(since = "4.0.0")`. The goal
of the compat module is to keep existing Maven 3 embedders working without
surprises — not to gain new behaviour. Maven 3 never followed BOM relocations
during import, so embedders using this path have no expectation of it.
The changes here go well beyond the minimum needed to fix the NPE /
null-resolver gap: they add full relocation-following
(`loadDependencyManagement`, `resolveImportModel`,
`validateRelocationCoordinate`), new cycle-detection logic, and a relocation
warning — all new behaviour in a deprecated class.
Please revert the compat builder to the minimal change needed (e.g. just the
null-resolver guard from the last commit if needed for correctness), and keep
the BOM relocation feature in the impl builder only. The compat builder should
not follow relocations at all.
_This review was generated by an AI agent, Hermès on behalf of @gnodet._
--
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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
gnodet-bot commented on code in PR #13081:
URL: https://github.com/apache/maven/pull/13081#discussion_r4069495884
##
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java:
##
@@ -2505,21 +2493,115 @@ private DependencyManagement
loadDependencyManagement(Dependency dependency, Col
.build();
}
+private Model loadImportModel(Dependency dependency, ImportContext
context) {
+Collection importIds = context.importIds;
+String groupId = dependency.getGroupId();
+String artifactId = dependency.getArtifactId();
+String version = dependency.getVersion();
+String imported = groupId + ':' + artifactId + ':' + version;
+
+if (importIds.contains(imported)) {
+StringBuilder message = new StringBuilder("The import POMs
form a cycle: ");
+for (String modelId : importIds) {
+message.append(modelId).append(" -> ");
+}
+message.append(imported);
+if (context.cycleIncludesRelocation(imported)) {
+context.reportRelocationProblem(message.toString(),
dependency.getLocation(""), null);
+} else {
+add(Severity.ERROR, Version.BASE, message.toString());
+}
+return null;
+}
+
+ImportModelCacheEntry cached =
+cache(repositories, groupId, artifactId, version, null,
IMPORT, ImportModelCacheEntry::new);
+ImportedModel importedModel = cached.model;
+if (importedModel == null) {
+boolean locked = cached.lock.tryLock();
+if (!locked && context.relocationSources.isEmpty()) {
+cached.lock.lock();
+locked = true;
+}
+try {
+importedModel = cached.model;
+if (importedModel == null) {
+// A relocation may lead back to an import being built
by another thread.
+// Only these paths avoid waiting; ordinary imports
still share one in-flight build.
+importedModel = doLoadDependencyManagement(dependency,
groupId, artifactId, version, context);
+if (locked && importedModel != null) {
+cached.model = importedModel;
+}
+}
+} finally {
+if (locked) {
+cached.lock.unlock();
+}
+}
+}
+if (importedModel == null) {
+return null;
+}
+
+Model importModel = importedModel.model();
+Relocation relocation = importModel.getDistributionManagement() !=
null
+? importModel.getDistributionManagement().getRelocation()
+: null;
+if (relocation != null) {
+if (!validateRelocationCoordinate(relocation.getGroupId(),
"groupId", dependency, context)
+||
!validateRelocationCoordinate(relocation.getArtifactId(), "artifactId",
dependency, context)
+||
!validateRelocationCoordinate(relocation.getVersion(), "version", dependency,
context)) {
+return null;
+}
+Dependency.Builder relocated =
Dependency.newBuilder(dependency).version(importedModel.version());
+if (relocation.getGroupId() != null &&
!relocation.getGroupId().isEmpty()) {
+relocated.groupId(relocation.getGroupId());
+}
+if (relocation.getArtifactId() != null
+&& !relocation.getArtifactId().isEmpty()) {
+relocated.artifactId(relocation.getArtifactId());
+}
+if (relocation.getVersion() != null &&
!relocation.getVersion().isEmpty()) {
+relocated.version(relocation.getVersion());
+}
+Dependency relocatedDependency = relocated.build();
+String message = "The import POM " + imported + " has been
relocated to "
++ relocatedDependency.getGroupId() + ':' +
relocatedDependency.getArtifactId() + ':'
++ relocatedDependency.getVersion();
+if (relocation.getMessage() != null) {
+message += ": " + relocation.getMessage();
+}
+add(Severity.WARNING, Version.BASE, message,
dependency.getLocation(""));
Review Comment:
Same issue as in the compat builder: the WARNING is emitted unconditionally,
including for transitive relocation hops. `ImportContext.relocationSources` is
already the right signal — it is non-empty exactly when we are inside a
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
goutamadwant commented on PR #13081: URL: https://github.com/apache/maven/pull/13081#issuecomment-5693151410 @gnodet-bot @gnodet Fixed. A workspace miss without a fallback ModelResolver now reports a normal model-building error with the missing BOM coordinates and import location. thanks! -- 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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
gnodet commented on PR #13081:
URL: https://github.com/apache/maven/pull/13081#issuecomment-5614564542
CI has been approved and is running. Status so far:
- **All 9 full-build jobs**: ✅ passed (all platforms, JDK 17/21/25)
- **integration-tests (ubuntu 21, 25)**: ✅ passed
- **integration-tests (macos 17)**: ❌ infra failure ("Set up JDK 17" step
failed — not related to this PR)
- **Remaining integration-tests**: still in progress
The second commit addresses all review feedback cleanly:
1. Variable renames (`depMgmt` → `dependencyManagement`, etc.)
2. `resolveImportModel()` extracted, removing the `@SuppressWarnings`
3. `importResult` declaration moved inside the try block
4. Cycle diagnostic updated to "The import POMs form a cycle"
5. New cycle-detection tests in both builders
Looks good. I'll re-check once the remaining integration tests complete.
_This comment was generated by an AI agent, Hermès on behalf of @gnodet._
--
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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
goutamadwant commented on PR #13081: URL: https://github.com/apache/maven/pull/13081#issuecomment-5614202893 > Maven 4 already has a relocation SPI: `MavenArtifactRelocationSource` (`distributionManagement`, `userProperties`), walked with cycle detection in `DefaultArtifactDescriptorReader.loadPom`. This adds a second walker for `distributionManagement` only, and imports resolve via `DefaultModelResolver`, which never consults those sources, so `maven.relocations.entries` cannot reach an imported BOM. Intended? > > Also a relocation-only loop reports "dependencies of type=pom and with scope=import form a cycle" though one import is declared; `loadPom` words it "Artifact relocations form a cycle". Yes, this fix is limited to distributionManagement relocations in imported BOMs. Imports use ModelResolver rather than the artifact-descriptor relocation SPI; extending maven.relocations.entries to BOM imports would be a separate change. Changed the diagnostic to “The import POMs form a cycle”, covering ordinary imports, relocations, and mixed cycles. Both model builders now assert the message and cycle path. @gnodet, could you approve the new CI run? -- 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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
goutamadwant commented on code in PR #13081:
URL: https://github.com/apache/maven/pull/13081#discussion_r3976172783
##
compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:
##
@@ -1187,136 +1182,210 @@ private void importDependencyManagement(
it.remove();
-String groupId = dependency.getGroupId();
-String artifactId = dependency.getArtifactId();
-String version = dependency.getVersion();
-
-if (groupId == null || groupId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.groupId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (artifactId == null || artifactId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.artifactId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (version == null || version.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.version' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
+DependencyManagement importMgmt =
loadDependencyManagement(dependency, model, request, problems, importIds);
+if (importMgmt != null) {
+if (importMgmts == null) {
+importMgmts = new ArrayList<>();
+}
+importMgmts.add(importMgmt);
}
+}
-String imported = groupId + ':' + artifactId + ':' + version;
+importIds.remove(importing);
-if (importIds.contains(imported)) {
-StringBuilder message =
-new StringBuilder("The dependencies of type=pom and
with scope=import form a cycle: ");
-for (String modelId : importIds) {
-message.append(modelId);
-message.append(" -> ");
-}
-message.append(imported);
-problems.add(
-new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE).setMessage(message.toString()));
+dependencyManagementImporter.importManagement(model, importMgmts,
request, problems);
+}
-continue;
+@SuppressWarnings("checkstyle:methodlength")
+private DependencyManagement loadDependencyManagement(
+Dependency dependency,
+Model model,
+ModelBuildingRequest request,
+DefaultModelProblemCollector problems,
+Collection importIds) {
+final WorkspaceModelResolver workspaceResolver =
request.getWorkspaceModelResolver();
+final ModelResolver modelResolver = request.getModelResolver();
+
+String groupId = dependency.getGroupId();
+String artifactId = dependency.getArtifactId();
+String version = dependency.getVersion();
+
+if (groupId == null || groupId.length() <= 0) {
+problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
+
.setMessage("'dependencyManagement.dependencies.dependency.groupId' for "
++ dependency.getManagementKey() + " is missing.")
+.setLocation(dependency.getLocation("")));
+return null;
+}
+if (artifactId == null || artifactId.length() <= 0) {
+problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
+
.setMessage("'dependencyManagement.dependencies.dependency.artifactId' for "
++ dependency.getManagementKey() + " is missing.")
+.setLocation(dependency.getLocation("")));
+return null;
+}
+if (version == null || version.length() <= 0) {
+problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
+
.setMessage("'dependencyManagement.dependencies.dependency.version' for "
++ dependency.getManagementKey() + " is missing.")
+.setLocation(dependency.getLocation("")));
+return null;
+}
+
+String imported = groupId + ':' + artifactId + ':' +
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
goutamadwant commented on code in PR #13081:
URL: https://github.com/apache/maven/pull/13081#discussion_r3976169522
##
compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:
##
@@ -1187,136 +1182,210 @@ private void importDependencyManagement(
it.remove();
-String groupId = dependency.getGroupId();
-String artifactId = dependency.getArtifactId();
-String version = dependency.getVersion();
-
-if (groupId == null || groupId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.groupId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (artifactId == null || artifactId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.artifactId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (version == null || version.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.version' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
+DependencyManagement importMgmt =
loadDependencyManagement(dependency, model, request, problems, importIds);
+if (importMgmt != null) {
+if (importMgmts == null) {
+importMgmts = new ArrayList<>();
+}
+importMgmts.add(importMgmt);
}
+}
-String imported = groupId + ':' + artifactId + ':' + version;
+importIds.remove(importing);
-if (importIds.contains(imported)) {
-StringBuilder message =
-new StringBuilder("The dependencies of type=pom and
with scope=import form a cycle: ");
-for (String modelId : importIds) {
-message.append(modelId);
-message.append(" -> ");
-}
-message.append(imported);
-problems.add(
-new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE).setMessage(message.toString()));
+dependencyManagementImporter.importManagement(model, importMgmts,
request, problems);
+}
-continue;
+@SuppressWarnings("checkstyle:methodlength")
Review Comment:
Done.
--
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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
goutamadwant commented on code in PR #13081:
URL: https://github.com/apache/maven/pull/13081#discussion_r3976164842
##
compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:
##
@@ -1187,136 +1182,210 @@ private void importDependencyManagement(
it.remove();
-String groupId = dependency.getGroupId();
-String artifactId = dependency.getArtifactId();
-String version = dependency.getVersion();
-
-if (groupId == null || groupId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.groupId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (artifactId == null || artifactId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.artifactId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (version == null || version.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.version' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
+DependencyManagement importMgmt =
loadDependencyManagement(dependency, model, request, problems, importIds);
Review Comment:
renamed the variables to use full names.
--
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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
gnodet-bot commented on PR #13081: URL: https://github.com/apache/maven/pull/13081#issuecomment-5601623386 Good observations @renechoi. Two distinct points here: **1. Relationship with `MavenArtifactRelocationSource` / `DefaultArtifactDescriptorReader.loadPom`** These operate at different layers: - **`DefaultArtifactDescriptorReader.loadPom`** (resolver layer) — handles relocations during **dependency resolution**, when the resolver reads an artifact descriptor. It walks relocations via `MavenArtifactRelocationSource` (which includes `DistributionManagementArtifactRelocationSource` and `UserPropertiesArtifactRelocationSource`). This path is used when resolving regular dependencies. - **`DefaultModelBuilder.importDependencyManagement`** (model builder layer) — handles BOM imports (`import`) during **model building**. This path resolves the imported POM directly via `ModelResolver`, builds its effective model, and extracts ``. It never goes through `DefaultArtifactDescriptorReader`, so the relocation SPI is never consulted. Before this PR, if a BOM declared ``, the model builder would silently ignore it and import nothing (or the wrong thing). This PR adds relocation-following specifically to the model builder's import path. Regarding `maven.relocations.entries` (user-properties-based relocations): correct, those cannot currently reach an imported BOM through this path. That's by design for this fix — the scope is limited to `distributionManagement` relocations, which is the mechanism actually used in published POMs. Extending user-properties relocations to BOM imports would be a separate enhancement. **2. Error message wording for relocation-only cycles** Valid point. When a cycle involves only relocation hops (no actual `scope=import` dependencies form the cycle), the message "The dependencies of type=pom and with scope=import form a cycle" is misleading. The PR does distinguish between relocation cycles and import cycles internally (see `cycleIncludesRelocation` in the Maven 4 model builder), but the error message template is reused. This could be improved with a more specific message like "The import POM relocation chain forms a cycle" when the cycle includes a relocation hop. _This review was generated by an AI agent, Hermès on behalf of @gnodet._ -- 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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
renechoi commented on PR #13081: URL: https://github.com/apache/maven/pull/13081#issuecomment-5601557357 Maven 4 already has a relocation SPI: `MavenArtifactRelocationSource` (`distributionManagement`, `userProperties`), walked with cycle detection in `DefaultArtifactDescriptorReader.loadPom`. This adds a second walker for `distributionManagement` only, and imports resolve via `DefaultModelResolver`, which never consults those sources, so `maven.relocations.entries` cannot reach an imported BOM. Intended? Also a relocation-only loop reports "dependencies of type=pom and with scope=import form a cycle" though one import is declared; `loadPom` words it "Artifact relocations form a cycle". -- 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]
Re: [PR] [MNG-5527] Honor BOM relocation during dependency management import [maven]
elharo commented on code in PR #13081:
URL: https://github.com/apache/maven/pull/13081#discussion_r3967670482
##
compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:
##
@@ -1187,136 +1182,210 @@ private void importDependencyManagement(
it.remove();
-String groupId = dependency.getGroupId();
-String artifactId = dependency.getArtifactId();
-String version = dependency.getVersion();
-
-if (groupId == null || groupId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.groupId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (artifactId == null || artifactId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.artifactId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (version == null || version.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.version' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
+DependencyManagement importMgmt =
loadDependencyManagement(dependency, model, request, problems, importIds);
+if (importMgmt != null) {
+if (importMgmts == null) {
+importMgmts = new ArrayList<>();
+}
+importMgmts.add(importMgmt);
}
+}
-String imported = groupId + ':' + artifactId + ':' + version;
+importIds.remove(importing);
-if (importIds.contains(imported)) {
-StringBuilder message =
-new StringBuilder("The dependencies of type=pom and
with scope=import form a cycle: ");
-for (String modelId : importIds) {
-message.append(modelId);
-message.append(" -> ");
-}
-message.append(imported);
-problems.add(
-new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE).setMessage(message.toString()));
+dependencyManagementImporter.importManagement(model, importMgmts,
request, problems);
+}
-continue;
+@SuppressWarnings("checkstyle:methodlength")
Review Comment:
maybe you should break this method up
##
compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:
##
@@ -1187,136 +1182,210 @@ private void importDependencyManagement(
it.remove();
-String groupId = dependency.getGroupId();
-String artifactId = dependency.getArtifactId();
-String version = dependency.getVersion();
-
-if (groupId == null || groupId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.groupId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (artifactId == null || artifactId.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.artifactId' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
-}
-if (version == null || version.length() <= 0) {
-problems.add(new ModelProblemCollectorRequest(Severity.ERROR,
Version.BASE)
-
.setMessage("'dependencyManagement.dependencies.dependency.version' for "
-+ dependency.getManagementKey() + " is
missing.")
-.setLocation(dependency.getLocation("")));
-continue;
+DependencyManagement importMgmt =
loadDependencyManagement(dependency, model, request, problems, importIds);
+if
