Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-6207] display deprecation build warning for dependencies with scope 'system' declaration #123

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ else if ( StringUtils.isNotEmpty( dependency.getClassifier() ) )
}
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 ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,20 @@ public void testHardCodedSystemPath()

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()
Expand Down Expand Up @@ -611,10 +624,23 @@ public void testSystemPathRefersToProjectBasedir()

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()
Expand Down