From 87dc3a9e1608adadd9fea25d9d45caecdd478b0c Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Tue, 1 Nov 2005 07:37:57 +0000 Subject: [PATCH] PR: MNG-764 Submitted by: Edwin Punzalan validation error if aggregator containing modules is not of the right packaging git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@330003 13f79535-47bb-0310-9956-ffa450edef68 --- .../project/validation/DefaultModelValidator.java | 6 ++++++ .../project/validation/DefaultModelValidatorTest.java | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/maven-project/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java b/maven-project/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java index d4da2fc1ff..34e38b70aa 100644 --- a/maven-project/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java +++ b/maven-project/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java @@ -54,6 +54,12 @@ public class DefaultModelValidator validateId( "artifactId", result, model.getArtifactId() ); validateStringNotEmpty( "packaging", result, model.getPackaging() ); + + if ( !model.getModules().isEmpty() && !"pom".equals( model.getPackaging() ) ) + { + result.addMessage( "Packaging '" + model.getPackaging() + "' is invalid. Aggregator projects " + + "require 'pom' as packaging." ); + } validateStringNotEmpty( "version", result, model.getVersion() ); diff --git a/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java b/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java index 3f07ae46cb..87de0ff8e2 100644 --- a/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java @@ -96,6 +96,16 @@ public class DefaultModelValidatorTest assertEquals( "'version' is missing.", result.getMessage( 0 ) ); } + + public void testInvalidAggregatorPackaging() + throws Exception + { + ModelValidationResult result = validate( "invalid-aggregator-packaging-pom.xml" ); + + assertEquals( 1, result.getMessageCount() ); + + assertTrue( result.getMessage( 0 ).indexOf( "Aggregator projects require 'pom' as packaging." ) > -1 ); + } public void testMissingDependencyArtifactId() throws Exception