mirror of https://github.com/apache/maven.git
[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:
parent
b16942f162
commit
0a5b7985f6
|
@ -153,51 +153,51 @@ public class DefaultModelValidator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Build build = model.getBuild();
|
if ( !lenient )
|
||||||
if ( build != null )
|
|
||||||
{
|
{
|
||||||
for ( Plugin p : build.getPlugins() )
|
Build build = model.getBuild();
|
||||||
|
if ( build != null )
|
||||||
{
|
{
|
||||||
validateStringNotEmpty( "build.plugins.plugin.artifactId", result, p.getArtifactId() );
|
for ( Plugin p : build.getPlugins() )
|
||||||
|
{
|
||||||
|
validateStringNotEmpty( "build.plugins.plugin.artifactId", result, p.getArtifactId() );
|
||||||
|
|
||||||
validateStringNotEmpty( "build.plugins.plugin.groupId", result, p.getGroupId() );
|
validateStringNotEmpty( "build.plugins.plugin.groupId", result, p.getGroupId() );
|
||||||
|
|
||||||
/*
|
validateStringNotEmpty( "build.plugins.plugin.version", result, p.getVersion(), p.getKey() );
|
||||||
* 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
|
for ( Resource r : build.getResources() )
|
||||||
* completely for the metadata source.
|
{
|
||||||
*/
|
validateStringNotEmpty( "build.resources.resource.directory", result, r.getDirectory() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Resource r : build.getTestResources() )
|
||||||
|
{
|
||||||
|
validateStringNotEmpty( "build.testResources.testResource.directory", result, r.getDirectory() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Resource r : build.getResources() )
|
Reporting reporting = model.getReporting();
|
||||||
|
if ( reporting != null )
|
||||||
{
|
{
|
||||||
validateStringNotEmpty( "build.resources.resource.directory", result, r.getDirectory() );
|
for ( ReportPlugin p : reporting.getPlugins() )
|
||||||
|
{
|
||||||
|
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() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Resource r : build.getTestResources() )
|
validateRepositories( result, model.getRepositories(), "repositories.repository" );
|
||||||
{
|
|
||||||
validateStringNotEmpty( "build.testResources.testResource.directory", result, r.getDirectory() );
|
// validateRepositories( result, model.getPluginRepositories(), "pluginRepositories.pluginRepository" );
|
||||||
}
|
|
||||||
|
forcePluginExecutionIdCollision( model, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
Reporting reporting = model.getReporting();
|
|
||||||
if ( reporting != null )
|
|
||||||
{
|
|
||||||
for ( ReportPlugin p : reporting.getPlugins())
|
|
||||||
{
|
|
||||||
validateStringNotEmpty( "reporting.plugins.plugin.artifactId", result, p.getArtifactId() );
|
|
||||||
|
|
||||||
validateStringNotEmpty( "reporting.plugins.plugin.groupId", result, p.getGroupId() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
validateRepositories( result, model.getRepositories(), "repositories.repository" );
|
|
||||||
|
|
||||||
// validateRepositories( result, model.getPluginRepositories(), "pluginRepositories.pluginRepository" );
|
|
||||||
|
|
||||||
forcePluginExecutionIdCollision( model, result );
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,17 @@ public class DefaultModelValidatorTest
|
||||||
assertEquals( "'build.plugins.plugin.artifactId' is missing.", result.getMessage( 0 ) );
|
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()
|
public void testMissingRepositoryId()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -37,6 +37,7 @@ under the License.
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
<artifactId>maven-it-plugin-configuration</artifactId>
|
<artifactId>maven-it-plugin-configuration</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<stringParams>
|
<stringParams>
|
||||||
<stringParam>one</stringParam>
|
<stringParam>one</stringParam>
|
||||||
|
|
|
@ -37,6 +37,7 @@ under the License.
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
<artifactId>maven-it-plugin-configuration</artifactId>
|
<artifactId>maven-it-plugin-configuration</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>validate</phase>
|
<phase>validate</phase>
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.4.3</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
@ -42,6 +43,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly2-plugin</artifactId>
|
<artifactId>maven-assembly2-plugin</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
@ -26,7 +26,7 @@ under the License.
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
<version>1.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue