Author: bentmann Date: Mon May 25 14:27:46 2009 New Revision: 778426 URL: http://svn.apache.org/viewvc?rev=778426&view=rev Log: [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 Added: maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-version-pom.xml - copied, changed from r778306, maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/execution-configuration-subcollections/pom.xml maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-config-order/wo-plugin-mngt/pom.xml maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-config-order/wo-plugin-mngt/pom.xml maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/profile-plugins/pom.xml maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java?rev=778426&r1=778425&r2=778426&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java Mon May 25 14:27:46 2009 @@ -153,50 +153,50 @@ } } - Build build = model.getBuild(); - if ( build != null ) + if ( !lenient ) { - 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() ); - - /* - * 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.groupId", result, p.getGroupId() ); - for ( Resource r : build.getResources() ) - { - validateStringNotEmpty( "build.resources.resource.directory", result, r.getDirectory() ); - } + validateStringNotEmpty( "build.plugins.plugin.version", result, p.getVersion(), p.getKey() ); + } - for ( Resource r : build.getTestResources() ) - { - validateStringNotEmpty( "build.testResources.testResource.directory", result, r.getDirectory() ); + for ( Resource r : build.getResources() ) + { + validateStringNotEmpty( "build.resources.resource.directory", result, r.getDirectory() ); + } + + for ( Resource r : build.getTestResources() ) + { + validateStringNotEmpty( "build.testResources.testResource.directory", result, r.getDirectory() ); + } } - } - Reporting reporting = model.getReporting(); - if ( reporting != null ) - { - for ( ReportPlugin p : reporting.getPlugins()) + Reporting reporting = model.getReporting(); + if ( reporting != null ) { - validateStringNotEmpty( "reporting.plugins.plugin.artifactId", result, p.getArtifactId() ); + 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.groupId", result, p.getGroupId() ); + validateStringNotEmpty( "reporting.plugins.plugin.version", result, p.getVersion(), p.getKey() ); + } } - } - validateRepositories( result, model.getRepositories(), "repositories.repository" ); + validateRepositories( result, model.getRepositories(), "repositories.repository" ); -// validateRepositories( result, model.getPluginRepositories(), "pluginRepositories.pluginRepository" ); + // validateRepositories( result, model.getPluginRepositories(), "pluginRepositories.pluginRepository" ); - forcePluginExecutionIdCollision( model, result ); + forcePluginExecutionIdCollision( model, result ); + } return result; } Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java?rev=778426&r1=778425&r2=778426&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java Mon May 25 14:27:46 2009 @@ -188,6 +188,17 @@ 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 { Modified: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/execution-configuration-subcollections/pom.xml URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/execution-configuration-subcollections/pom.xml?rev=778426&r1=778425&r2=778426&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/execution-configuration-subcollections/pom.xml (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/execution-configuration-subcollections/pom.xml Mon May 25 14:27:46 2009 @@ -12,6 +12,7 @@ <plugins> <plugin> <artifactId>maven-enforcer-plugin</artifactId> + <version>1.0</version> <executions> <execution> <goals> Modified: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-config-order/wo-plugin-mngt/pom.xml URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-config-order/wo-plugin-mngt/pom.xml?rev=778426&r1=778425&r2=778426&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-config-order/wo-plugin-mngt/pom.xml (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-config-order/wo-plugin-mngt/pom.xml Mon May 25 14:27:46 2009 @@ -37,6 +37,7 @@ <plugin> <groupId>org.apache.maven.its.plugins</groupId> <artifactId>maven-it-plugin-configuration</artifactId> + <version>1.0</version> <configuration> <stringParams> <stringParam>one</stringParam> Modified: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-config-order/wo-plugin-mngt/pom.xml URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-config-order/wo-plugin-mngt/pom.xml?rev=778426&r1=778425&r2=778426&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-config-order/wo-plugin-mngt/pom.xml (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-config-order/wo-plugin-mngt/pom.xml Mon May 25 14:27:46 2009 @@ -37,6 +37,7 @@ <plugin> <groupId>org.apache.maven.its.plugins</groupId> <artifactId>maven-it-plugin-configuration</artifactId> + <version>1.0</version> <executions> <execution> <phase>validate</phase> Modified: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/profile-plugins/pom.xml URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/profile-plugins/pom.xml?rev=778426&r1=778425&r2=778426&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/profile-plugins/pom.xml (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/profile-plugins/pom.xml Mon May 25 14:27:46 2009 @@ -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> Modified: maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml?rev=778426&r1=778425&r2=778426&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml Mon May 25 14:27:46 2009 @@ -26,7 +26,7 @@ <build> <plugins> <plugin> - + <version>1.0</version> </plugin> </plugins> </build> Copied: maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-version-pom.xml (from r778306, maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml) URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-version-pom.xml?p2=maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-version-pom.xml&p1=maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml&r1=778306&r2=778426&rev=778426&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources/validation/missing-plugin-version-pom.xml Mon May 25 14:27:46 2009 @@ -26,7 +26,7 @@ <build> <plugins> <plugin> - + <artifactId>maven-it-plugin</artifactId> </plugin> </plugins> </build>