maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] asfgit closed pull request #131: [MNG-6213] Validate scope in dependencyManagement
Date Sat, 29 Dec 2018 00:12:19 GMT
asfgit closed pull request #131: [MNG-6213] Validate scope in dependencyManagement
URL: https://github.com/apache/maven/pull/131
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
index d97d8f6f6f..a62409c119 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
@@ -583,6 +583,12 @@ private void validateEffectiveDependencies( ModelProblemCollector problems,
Mode
 
                     validateEffectiveModelAgainstDependency( prefix, problems, m, d, request
);
                 }
+                else
+                {
+                    validateEnum( prefix + "scope", problems, Severity.WARNING, Version.V20,
d.getScope(),
+                                  d.getManagementKey(), d, "provided", "compile", "runtime",
"test", "system",
+                                  "import" );
+                }
             }
         }
     }
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
index 5614daf0df..a25ca7f8fe 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
+++ b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
@@ -339,6 +339,16 @@ public void testBadDependencyScope()
         assertTrue( result.getWarnings().get( 1 ).contains( "test:g" ) );
     }
 
+    public void testBadDependencyManagementScope()
+        throws Exception
+    {
+        SimpleProblemCollector result = validate( "bad-dependency-management-scope.xml" );
+
+        assertViolations( result, 0, 0, 1 );
+
+        assertContains( result.getWarnings().get( 0 ), "test:g" );
+    }
+    
     public void testBadDependencyVersion()
         throws Exception
     {
diff --git a/maven-model-builder/src/test/resources/poms/validation/bad-dependency-management-scope.xml
b/maven-model-builder/src/test/resources/poms/validation/bad-dependency-management-scope.xml
new file mode 100644
index 0000000000..c1880f1d0b
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/validation/bad-dependency-management-scope.xml
@@ -0,0 +1,64 @@
+<!-- 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.2</version>
+      </dependency>
+      <dependency>
+        <groupId>test</groupId>
+        <artifactId>b</artifactId>
+        <version>0.2</version>
+        <scope>compile</scope>
+      </dependency>
+      <dependency>
+        <groupId>test</groupId>
+        <artifactId>c</artifactId>
+        <version>0.2</version>
+        <scope>runtime</scope>
+      </dependency>
+      <dependency>
+        <groupId>test</groupId>
+        <artifactId>d</artifactId>
+        <version>0.2</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>test</groupId>
+        <artifactId>e</artifactId>
+        <version>0.2</version>
+        <scope>provided</scope>
+      </dependency>
+      <dependency>
+        <groupId>test</groupId>
+        <artifactId>f</artifactId>
+        <version>0.2</version>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>test</groupId>
+        <artifactId>g</artifactId>
+        <version>1</version>
+        <type>pom</type>
+        <scope>include</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+</project>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message