Author: bentmann
Date: Mon Nov 22 12:17:29 2010
New Revision: 1037689
URL: http://svn.apache.org/viewvc?rev=1037689&view=rev
Log:
[MNG-4909] Emit warning when dependency with scope import but inproper type is
declared
Added:
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml
(with props)
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml
(with props)
Modified:
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
Modified:
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java?rev=1037689&r1=1037688&r2=1037689&view=diff
==============================================================================
---
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
(original)
+++
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
Mon Nov 22 12:17:29 2010
@@ -356,11 +356,18 @@ public class DefaultModelValidator
{
String key = dependency.getManagementKey();
- if ( "pom".equals( dependency.getType() ) && "import".equals(
dependency.getScope() )
- && StringUtils.isNotEmpty( dependency.getClassifier() ) )
+ if ( "import".equals( dependency.getScope() ) )
{
- addViolation( problems, errOn30, prefix + ".classifier", key,
- "must be empty, imported POM cannot have a
classifier.", dependency );
+ if ( !"pom".equals( dependency.getType() ) )
+ {
+ addViolation( problems, Severity.WARNING, prefix +
".type", key,
+ "must be 'pom' to import the managed
dependencies.", dependency );
+ }
+ else if ( StringUtils.isNotEmpty( dependency.getClassifier() )
)
+ {
+ addViolation( problems, errOn30, prefix + ".classifier",
key,
+ "must be empty, imported POM cannot have a
classifier.", dependency );
+ }
}
else if ( "system".equals( dependency.getScope() ) )
{
Modified:
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java?rev=1037689&r1=1037688&r2=1037689&view=diff
==============================================================================
---
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
(original)
+++
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
Mon Nov 22 12:17:29 2010
@@ -561,4 +561,26 @@ public class DefaultModelValidatorTest
"'dependencies.dependency.exclusions.exclusion.artifactId' for gid:aid:jar is
missing" );
}
+ public void testBadImportScopeType()
+ throws Exception
+ {
+ SimpleProblemCollector result = validateRaw(
"bad-import-scope-type.xml" );
+
+ assertViolations( result, 0, 0, 1 );
+
+ assertContains( result.getWarnings().get( 0 ),
+ "'dependencyManagement.dependencies.dependency.type'
for test:a:jar must be 'pom'" );
+ }
+
+ public void testBadImportScopeClassifier()
+ throws Exception
+ {
+ SimpleProblemCollector result = validateRaw(
"bad-import-scope-classifier.xml" );
+
+ assertViolations( result, 0, 1, 0 );
+
+ assertContains( result.getErrors().get( 0 ),
+
"'dependencyManagement.dependencies.dependency.classifier' for test:a:pom:cls
must be empty" );
+ }
+
}
Added:
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml?rev=1037689&view=auto
==============================================================================
---
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml
(added)
+++
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml
Mon Nov 22 12:17:29 2010
@@ -0,0 +1,38 @@
+<!--
+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>aid</artifactId>
+ <groupId>gid</groupId>
+ <version>0.1</version>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>test</groupId>
+ <artifactId>a</artifactId>
+ <version>0.1</version>
+ <scope>import</scope>
+ <type>pom</type>
+ <classifier>cls</classifier>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
Propchange:
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-classifier.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml?rev=1037689&view=auto
==============================================================================
---
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml
(added)
+++
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml
Mon Nov 22 12:17:29 2010
@@ -0,0 +1,37 @@
+<!--
+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>aid</artifactId>
+ <groupId>gid</groupId>
+ <version>0.1</version>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>test</groupId>
+ <artifactId>a</artifactId>
+ <version>0.1</version>
+ <scope>import</scope>
+ <!-- missing type=pom -->
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
Propchange:
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/bad-import-scope-type.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision