maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject 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 [Forced Update!]
Date Sun, 11 Jun 2017 11:59:15 GMT
Repository: maven
Updated Branches:
  refs/heads/MNG-6207 1081fa1c4 -> 12d647133 (forced update)


[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 <khmarbaise@apache.org>


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

Branch: refs/heads/MNG-6207
Commit: 12d6471337c7ad067b7762d44050a079829ea26c
Parents: 707cff6
Author: dejan2609 <dejan2609@gmail.com>
Authored: Sat May 20 15:42:43 2017 +0200
Committer: Karl Heinz Marbaise <khmarbaise@apache.org>
Committed: Sun Jun 11 13:55:07 2017 +0200

----------------------------------------------------------------------
 .../model/validation/DefaultModelValidator.java | 14 +++++---
 .../validation/DefaultModelValidatorTest.java   | 36 +++++++++++++++++---
 2 files changed, 41 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/12d64713/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..2e7985f 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,13 @@ 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 ) )
                 {
@@ -488,7 +495,7 @@ public class DefaultModelValidator
             if ( equals( "LATEST", dependency.getVersion() ) || equals( "RELEASE", dependency.getVersion()
) )
             {
                 addViolation( problems, Severity.WARNING, Version.BASE, prefix + ".version",
key,
-                        "is either LATEST or RELEASE (both of them are being deprecated)",
dependency );
+                              "is either LATEST or RELEASE (both of them are being deprecated)",
dependency );
             }
 
             Dependency existing = index.get( key );
@@ -1034,9 +1041,8 @@ public class DefaultModelValidator
         buffer.append( ' ' ).append( message );
 
         // CHECKSTYLE_OFF: LineLength
-        problems.add( new ModelProblemCollectorRequest( severity,
-                                                        version ).setMessage( buffer.toString()
).setLocation( getLocation( fieldName,
-                                                                                        
                                   tracker ) ) );
+        problems.add( new ModelProblemCollectorRequest( severity, version ).setMessage(
+                                                                                        buffer.toString()
).setLocation( getLocation( fieldName, tracker ) ) );
         // CHECKSTYLE_ON: LineLength
     }
 

http://git-wip-us.apache.org/repos/asf/maven/blob/12d64713/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()


Mime
View raw message