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 12:28:10 UTC
[2/3] 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 (ration
[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/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/mvn-3.5.1/MNG-6174
Commit: 12d6471337c7ad067b7762d44050a079829ea26c
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: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()