Skip to content

Commit

Permalink
Enforce no expression in GAV and parent GAV (null is allowed for infe…
Browse files Browse the repository at this point in the history
…rence)fork
  • Loading branch information
gnodet committed Sep 30, 2024
1 parent 4805dbe commit d39dae9
Showing 1 changed file with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,33 @@ public void validateFileModel(
validateModelVersion(problems, m.getModelVersion(), m, VALID_MODEL_VERSIONS);
}

validateStringNoExpression("groupId", problems, Severity.WARNING, Version.V20, m.getGroupId(), m);
if (parent == null) {
validateStringNotEmpty("groupId", problems, Severity.FATAL, Version.V20, m.getGroupId(), m);
}
boolean isModelVersion41OrMore = !Objects.equals(ModelBuilder.MODEL_VERSION_4_0_0, m.getModelVersion());
if (isModelVersion41OrMore) {
validateStringNoExpression("groupId", problems, Severity.FATAL, Version.V41, m.getGroupId(), m);
validateStringNotEmpty("artifactId", problems, Severity.FATAL, Version.V20, m.getArtifactId(), m);
validateStringNoExpression("artifactId", problems, Severity.FATAL, Version.V20, m.getArtifactId(), m);
validateVersionNoExpression("version", problems, Severity.FATAL, Version.V41, m.getVersion(), m);
if (parent != null) {
validateStringNoExpression(
"groupId", problems, Severity.FATAL, Version.V41, parent.getGroupId(), m);
validateStringNoExpression(
"artifactId", problems, Severity.FATAL, Version.V41, parent.getArtifactId(), m);
validateVersionNoExpression(
"version", problems, Severity.FATAL, Version.V41, parent.getVersion(), m);
}
} else {
validateStringNoExpression("groupId", problems, Severity.WARNING, Version.V20, m.getGroupId(), m);
if (parent == null) {
validateStringNotEmpty("groupId", problems, Severity.FATAL, Version.V20, m.getGroupId(), m);
}

validateStringNoExpression("artifactId", problems, Severity.WARNING, Version.V20, m.getArtifactId(), m);
validateStringNotEmpty("artifactId", problems, Severity.FATAL, Version.V20, m.getArtifactId(), m);
validateStringNoExpression("artifactId", problems, Severity.WARNING, Version.V20, m.getArtifactId(), m);
validateStringNotEmpty("artifactId", problems, Severity.FATAL, Version.V20, m.getArtifactId(), m);

validateVersionNoExpression("version", problems, Severity.WARNING, Version.V20, m.getVersion(), m);
if (parent == null) {
validateStringNotEmpty("version", problems, Severity.FATAL, Version.V20, m.getVersion(), m);
validateVersionNoExpression("version", problems, Severity.WARNING, Version.V20, m.getVersion(), m);
if (parent == null) {
validateStringNotEmpty("version", problems, Severity.FATAL, Version.V20, m.getVersion(), m);
}
}

validate20RawDependencies(
Expand Down

0 comments on commit d39dae9

Please sign in to comment.