[MNG-4173] Remove automatic version resolution for POM plugins

o Strengthended model validator to bark with a nice error message before down stream code bubbles up with ugly exceptions. The new validation step applies only to local builds and not to dependency resolution via the metadata source to accept existing POMs

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@778426 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-05-25 14:27:46 +00:00
parent b16942f162
commit 0a5b7985f6
8 changed files with 85 additions and 36 deletions

View File

@ -153,6 +153,8 @@ public class DefaultModelValidator
}
}
if ( !lenient )
{
Build build = model.getBuild();
if ( build != null )
{
@ -162,12 +164,7 @@ public class DefaultModelValidator
validateStringNotEmpty( "build.plugins.plugin.groupId", result, p.getGroupId() );
/*
* FIXME: Enforce the existence of a version, no more guessing but reproducibility. We can't do this
* right now as it would affect dependency resolution via the metadata source. As a prerequisite, we
* need to tell the validator which level of strictness we want or alternatively disable validation
* completely for the metadata source.
*/
validateStringNotEmpty( "build.plugins.plugin.version", result, p.getVersion(), p.getKey() );
}
for ( Resource r : build.getResources() )
@ -189,6 +186,8 @@ public class DefaultModelValidator
validateStringNotEmpty( "reporting.plugins.plugin.artifactId", result, p.getArtifactId() );
validateStringNotEmpty( "reporting.plugins.plugin.groupId", result, p.getGroupId() );
validateStringNotEmpty( "reporting.plugins.plugin.version", result, p.getVersion(), p.getKey() );
}
}
@ -197,6 +196,7 @@ public class DefaultModelValidator
// validateRepositories( result, model.getPluginRepositories(), "pluginRepositories.pluginRepository" );
forcePluginExecutionIdCollision( model, result );
}
return result;
}

View File

@ -188,6 +188,17 @@ public class DefaultModelValidatorTest
assertEquals( "'build.plugins.plugin.artifactId' is missing.", result.getMessage( 0 ) );
}
public void testMissingPluginVersion()
throws Exception
{
ModelValidationResult result = validate( "missing-plugin-version-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( "'build.plugins.plugin.version' is missing for org.apache.maven.plugins:maven-it-plugin",
result.getMessage( 0 ) );
}
public void testMissingRepositoryId()
throws Exception
{

View File

@ -12,6 +12,7 @@
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<goals>

View File

@ -37,6 +37,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>1.0</version>
<configuration>
<stringParams>
<stringParam>one</stringParam>

View File

@ -37,6 +37,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>validate</phase>

View File

@ -27,6 +27,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
</plugin>
</plugins>
</build>
@ -42,6 +43,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly2-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</build>

View File

@ -26,7 +26,7 @@ under the License.
<build>
<plugins>
<plugin>
<version>1.0</version>
</plugin>
</plugins>
</build>

View File

@ -0,0 +1,33 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>foo</artifactId>
<groupId>foo</groupId>
<version>99.44</version>
<packaging>bleh</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-it-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>