From dd5c319fd302e80866269a2ff752e9552fa12a18 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 30 Aug 2024 16:48:49 +0200 Subject: [PATCH] [MNG-7255] Infer groupId for dependencies --- .../maven/internal/impl/model/BuildModelTransformer.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/BuildModelTransformer.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/BuildModelTransformer.java index c1ff4d8efab5..abd91f2d92f3 100644 --- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/BuildModelTransformer.java +++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/BuildModelTransformer.java @@ -89,7 +89,15 @@ void handleCiFriendlyVersion(ModelTransformerContext context, Model model, Path void handleReactorDependencies(ModelTransformerContext context, Model model, Path pomFile, Model.Builder builder) { List newDeps = new ArrayList<>(); boolean modified = false; + String groupId = model.getGroupId(); + if (groupId == null) { + groupId = model.getParent().getGroupId(); + } for (Dependency dep : model.getDependencies()) { + if (dep.getGroupId() == null) { + dep = dep.withGroupId(groupId); + modified = true; + } if (dep.getVersion() == null) { Model depModel = context.getRawModel(model.getPomFile(), dep.getGroupId(), dep.getArtifactId()); if (depModel != null) {