in impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java [833:1017]
public void validateEffectiveModel(Model m, int validationLevel, ModelProblemCollector problems) {
validateStringNotEmpty("modelVersion", problems, Severity.ERROR, Version.BASE, m.getModelVersion(), m);
validateCoordinatesId("groupId", problems, m.getGroupId(), m);
validateCoordinatesId("artifactId", problems, m.getArtifactId(), m);
validateStringNotEmpty("packaging", problems, Severity.ERROR, Version.BASE, m.getPackaging(), m);
if (!m.getModules().isEmpty()) {
if (!"pom".equals(m.getPackaging())) {
addViolation(
problems,
Severity.ERROR,
Version.BASE,
"packaging",
null,
"with value '" + m.getPackaging() + "' is invalid. Aggregator projects "
+ "require 'pom' as packaging.",
m);
}
for (int i = 0, n = m.getModules().size(); i < n; i++) {
String module = m.getModules().get(i);
boolean isBlankModule = true;
if (module != null) {
for (int j = 0; j < module.length(); j++) {
if (!Character.isWhitespace(module.charAt(j))) {
isBlankModule = false;
}
}
}
if (isBlankModule) {
addViolation(
problems,
Severity.ERROR,
Version.BASE,
"modules.module[" + i + "]",
null,
"has been specified without a path to the project directory.",
m.getLocation("modules"));
}
}
}
validateStringNotEmpty("version", problems, Severity.ERROR, Version.BASE, m.getVersion(), m);
Severity errOn30 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_0);
validateEffectiveDependencies(problems, m, m.getDependencies(), false, validationLevel);
DependencyManagement mgmt = m.getDependencyManagement();
if (mgmt != null) {
validateEffectiveDependencies(problems, m, mgmt.getDependencies(), true, validationLevel);
}
if (validationLevel >= ModelValidator.VALIDATION_LEVEL_MAVEN_2_0) {
Severity errOn31 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_1);
validateBannedCharacters(
EMPTY, "version", problems, errOn31, Version.V20, m.getVersion(), null, m, ILLEGAL_VERSION_CHARS);
validate20ProperSnapshotVersion("version", problems, errOn31, Version.V20, m.getVersion(), null, m);
if (hasExpression(m.getVersion())) {
Severity versionExpressionSeverity = Severity.ERROR;
if (m.getProperties() != null
&& Boolean.parseBoolean(
m.getProperties().get(BUILD_ALLOW_EXPRESSION_IN_EFFECTIVE_PROJECT_VERSION))) {
versionExpressionSeverity = Severity.WARNING;
}
addViolation(
problems,
versionExpressionSeverity,
Version.V20,
"version",
null,
"must be a constant version but is '" + m.getVersion() + "'.",
m);
}
Build build = m.getBuild();
if (build != null) {
for (Plugin p : build.getPlugins()) {
validateStringNotEmpty(
"build.plugins.plugin.artifactId",
problems,
Severity.ERROR,
Version.V20,
p.getArtifactId(),
p);
validateStringNotEmpty(
"build.plugins.plugin.groupId", problems, Severity.ERROR, Version.V20, p.getGroupId(), p);
validate20PluginVersion(
"build.plugins.plugin.version",
problems,
p.getVersion(),
SourceHint.pluginKey(p),
p,
validationLevel);
validateBoolean(
"build.plugins.plugin.inherited",
EMPTY,
problems,
errOn30,
Version.V20,
p.getInherited(),
SourceHint.pluginKey(p),
p);
validateBoolean(
"build.plugins.plugin.extensions",
EMPTY,
problems,
errOn30,
Version.V20,
p.getExtensions(),
SourceHint.pluginKey(p),
p);
validate20EffectivePluginDependencies(problems, p, validationLevel);
}
validate20RawResources(problems, build.getResources(), "build.resources.resource.", validationLevel);
validate20RawResources(
problems, build.getTestResources(), "build.testResources.testResource.", validationLevel);
}
Reporting reporting = m.getReporting();
if (reporting != null) {
for (ReportPlugin p : reporting.getPlugins()) {
validateStringNotEmpty(
"reporting.plugins.plugin.artifactId",
problems,
Severity.ERROR,
Version.V20,
p.getArtifactId(),
p);
validateStringNotEmpty(
"reporting.plugins.plugin.groupId",
problems,
Severity.ERROR,
Version.V20,
p.getGroupId(),
p);
}
}
for (Repository repository : m.getRepositories()) {
validate20EffectiveRepository(problems, repository, "repositories.repository.", validationLevel);
}
for (Repository repository : m.getPluginRepositories()) {
validate20EffectiveRepository(
problems, repository, "pluginRepositories.pluginRepository.", validationLevel);
}
DistributionManagement distMgmt = m.getDistributionManagement();
if (distMgmt != null) {
if (distMgmt.getStatus() != null) {
addViolation(
problems,
Severity.ERROR,
Version.V20,
"distributionManagement.status",
null,
"must not be specified.",
distMgmt);
}
validate20EffectiveRepository(
problems, distMgmt.getRepository(), "distributionManagement.repository.", validationLevel);
validate20EffectiveRepository(
problems,
distMgmt.getSnapshotRepository(),
"distributionManagement.snapshotRepository.",
validationLevel);
}
}
}