gnodet commented on code in PR #1651: URL: https://github.com/apache/maven/pull/1651#discussion_r1720832850
########## maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelValidator.java: ########## @@ -360,6 +360,61 @@ public void validateFileModel(Model m, ModelBuilderRequest request, ModelProblem m.getLocation("modules")); } } + String modelVersion = m.getModelVersion(); + if (modelVersion == null) { + String namespace = m.getNamespaceUri(); + if (namespace != null && namespace.startsWith(NAMESPACE_PREFIX)) { + modelVersion = namespace.substring(NAMESPACE_PREFIX.length()); + } + } + if (Objects.equals(modelVersion, ModelBuilder.MODEL_VERSION_4_0_0)) { + if (!m.getSubprojects().isEmpty()) { + addViolation( + problems, + Severity.ERROR, + Version.V40, + "subprojects", + null, + "unexpected subprojects element", + m.getLocation("subprojects")); + } + } else { + Set<String> subprojects = new HashSet<>(); + for (int i = 0, n = m.getSubprojects().size(); i < n; i++) { + String subproject = m.getSubprojects().get(i); + if (!subprojects.add(subproject)) { + addViolation( + problems, + Severity.ERROR, + Version.V41, + "subprojects.subproject[" + i + "]", + null, + "specifies duplicate subproject " + subproject, + m.getLocation("subprojects")); + } + } + if (!modules.isEmpty()) { + if (subprojects.isEmpty()) { + addViolation( + problems, + Severity.WARNING, + Version.V41, + "modules", + null, + "deprecated modules element, use subprojects instead", + m.getLocation("modules")); + } else { + addViolation( + problems, + Severity.WARNING, Review Comment: Good catch ! -- 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-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org