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._
<!-- reviewer: gnodet-bot -->
--
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]