You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2017/06/11 11:27:33 UTC

maven git commit: [MNG-6207] Create WARNINGs in case of using system scope o display deprecation build warning for dependencies with scope 'system' declaration o Note about tests: existing 'systemPath' related tests are reused/expanded (rationale: s

Repository: maven
Updated Branches:
  refs/heads/MNG-6207 [created] 1081fa1c4


[MNG-6207] Create WARNINGs in case of using system scope
 o display deprecation build warning for dependencies with scope 'system' declaration
 o Note about tests: existing 'systemPath' related tests are reused/expanded
   (rationale: scope 'system' and 'systemPath' are mutually dependent)

Signed-off-by: Karl Heinz Marbaise <kh...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/1081fa1c
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/1081fa1c
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/1081fa1c

Branch: refs/heads/MNG-6207
Commit: 1081fa1c46e6ca9ddc35f522574d3f6560d8cf1c
Parents: 707cff6
Author: dejan2609 <de...@gmail.com>
Authored: Sat May 20 15:42:43 2017 +0200
Committer: Karl Heinz Marbaise <kh...@apache.org>
Committed: Sun Jun 11 13:26:45 2017 +0200

----------------------------------------------------------------------
 .../model/validation/DefaultModelValidator.java |  6 ++++
 .../validation/DefaultModelValidatorTest.java   | 36 +++++++++++++++++---
 2 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/1081fa1c/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
----------------------------------------------------------------------
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 f46be0e..a5b636f 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
@@ -467,6 +467,12 @@ public class DefaultModelValidator
             }
             else if ( "system".equals( dependency.getScope() ) )
             {
+
+                if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ) {
+                    addViolation( problems, Severity.WARNING, Version.V31, prefix + ".scope", key,
+                            "declares usage of deprecated 'system' scope ", dependency );
+                }
+
                 String sysPath = dependency.getSystemPath();
                 if ( StringUtils.isNotEmpty( sysPath ) )
                 {

http://git-wip-us.apache.org/repos/asf/maven/blob/1081fa1c/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
----------------------------------------------------------------------
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 bb99be9..4da3c87 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
@@ -418,7 +418,20 @@ public class DefaultModelValidatorTest
 
         assertViolations( result, 0, 0, 1 );
 
-        assertTrue( result.getWarnings().get( 0 ).contains( "test:a:jar" ) );
+        assertContains( result.getWarnings().get( 0 ),
+                "'dependencies.dependency.systemPath' for test:a:jar should use a variable instead of a hard-coded path" );
+
+        SimpleProblemCollector result_31 = validateRaw( "hard-coded-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 );
+
+        assertViolations( result_31, 0, 0, 3 );
+
+        assertContains( result_31.getWarnings().get( 0 ),
+                "'dependencies.dependency.scope' for test:a:jar declares usage of deprecated 'system' scope" );
+        assertContains( result_31.getWarnings().get( 1 ),
+                "'dependencies.dependency.systemPath' for test:a:jar should use a variable instead of a hard-coded path" );
+        assertContains( result_31.getWarnings().get( 2 ),
+                "'dependencies.dependency.scope' for test:b:jar declares usage of deprecated 'system' scope" );
+
     }
 
     public void testEmptyModule()
@@ -611,10 +624,23 @@ public class DefaultModelValidatorTest
 
         assertViolations( result, 0, 0, 2 );
 
-        assertContains( result.getWarnings().get( 0 ), "'dependencies.dependency.systemPath' for test:a:jar "
-            + "should not point at files within the project directory" );
-        assertContains( result.getWarnings().get( 1 ), "'dependencies.dependency.systemPath' for test:b:jar "
-            + "should not point at files within the project directory" );
+        assertContains( result.getWarnings().get( 0 ),
+                "'dependencies.dependency.systemPath' for test:a:jar should not point at files within the project directory" );
+        assertContains( result.getWarnings().get( 1 ),
+                "'dependencies.dependency.systemPath' for test:b:jar should not point at files within the project directory" );
+
+        SimpleProblemCollector result_31 = validateRaw( "basedir-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 );
+
+        assertViolations( result_31, 0, 0, 4 );
+
+        assertContains( result_31.getWarnings().get( 0 ),
+                "'dependencies.dependency.scope' for test:a:jar declares usage of deprecated 'system' scope" );
+        assertContains( result_31.getWarnings().get( 1 ),
+                "'dependencies.dependency.systemPath' for test:a:jar should not point at files within the project directory" );
+        assertContains( result_31.getWarnings().get( 2 ),
+                "'dependencies.dependency.scope' for test:b:jar declares usage of deprecated 'system' scope" );
+        assertContains( result_31.getWarnings().get( 3 ),
+                "'dependencies.dependency.systemPath' for test:b:jar should not point at files within the project directory" );
     }
 
     public void testInvalidVersionInPluginManagement()