in impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java [1291:1418]
private void validateEffectiveDependency(
ModelProblemCollector problems, Dependency d, boolean management, String prefix, int validationLevel) {
validateCoordinatesId(
prefix,
"artifactId",
problems,
Severity.ERROR,
Version.BASE,
d.getArtifactId(),
SourceHint.dependencyManagementKey(d),
d);
validateCoordinatesId(
prefix,
"groupId",
problems,
Severity.ERROR,
Version.BASE,
d.getGroupId(),
SourceHint.dependencyManagementKey(d),
d);
if (!management) {
validateStringNotEmpty(
prefix,
"type",
problems,
Severity.ERROR,
Version.BASE,
d.getType(),
SourceHint.dependencyManagementKey(d),
d);
validateDependencyVersion(problems, d, prefix);
}
if ("system".equals(d.getScope())) {
String systemPath = d.getSystemPath();
if (systemPath == null || systemPath.isEmpty()) {
addViolation(
problems,
Severity.ERROR,
Version.BASE,
prefix + "systemPath",
SourceHint.dependencyManagementKey(d),
"is missing.",
d);
} else {
File sysFile = new File(systemPath);
if (!sysFile.isAbsolute()) {
addViolation(
problems,
Severity.ERROR,
Version.BASE,
prefix + "systemPath",
SourceHint.dependencyManagementKey(d),
"must specify an absolute path but is " + systemPath,
d);
} else if (!sysFile.isFile()) {
String msg = "refers to a non-existing file " + sysFile.getAbsolutePath() + ".";
addViolation(
problems,
Severity.WARNING,
Version.BASE,
prefix + "systemPath",
SourceHint.dependencyManagementKey(d),
msg,
d);
}
}
} else if (d.getSystemPath() != null && !d.getSystemPath().isEmpty()) {
addViolation(
problems,
Severity.ERROR,
Version.BASE,
prefix + "systemPath",
SourceHint.dependencyManagementKey(d),
"must be omitted. This field may only be specified for a dependency with system scope.",
d);
}
if (validationLevel >= ModelValidator.VALIDATION_LEVEL_MAVEN_2_0) {
for (Exclusion exclusion : d.getExclusions()) {
if (validationLevel < ModelValidator.VALIDATION_LEVEL_MAVEN_3_0) {
validateCoordinatesId(
prefix,
"exclusions.exclusion.groupId",
problems,
Severity.WARNING,
Version.V20,
exclusion.getGroupId(),
SourceHint.dependencyManagementKey(d),
exclusion);
validateCoordinatesId(
prefix,
"exclusions.exclusion.artifactId",
problems,
Severity.WARNING,
Version.V20,
exclusion.getArtifactId(),
SourceHint.dependencyManagementKey(d),
exclusion);
} else {
validateCoordinatesIdWithWildcards(
prefix,
"exclusions.exclusion.groupId",
problems,
Severity.WARNING,
Version.V30,
exclusion.getGroupId(),
SourceHint.dependencyManagementKey(d),
exclusion);
validateCoordinatesIdWithWildcards(
prefix,
"exclusions.exclusion.artifactId",
problems,
Severity.WARNING,
Version.V30,
exclusion.getArtifactId(),
SourceHint.dependencyManagementKey(d),
exclusion);
}
}
}
}