mirror of https://github.com/apache/maven.git
PR: MNG-1471
Submitted By: Edwin Punzalan Reviewed By: John Casey Applied patch, with small logic fix. This patch will validate that if a systemPath is specified for a dependency, it is absolute. It's possible to use expressions in this path, but by the time it's validated in this step, those expressions will have been resolved. My change was to add the same validation to managed dependencies. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@354635 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4097d7ae0f
commit
c54202821e
|
@ -29,6 +29,7 @@ import org.apache.maven.model.Repository;
|
|||
import org.apache.maven.model.Resource;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -86,11 +87,24 @@ public class DefaultModelValidator
|
|||
|
||||
validateStringNotEmpty( "dependencies.dependency.version", result, d.getVersion(), dependencySourceHint( d ) );
|
||||
|
||||
if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && StringUtils.isEmpty( d.getSystemPath() ) )
|
||||
if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) )
|
||||
{
|
||||
String systemPath = d.getSystemPath();
|
||||
|
||||
if ( StringUtils.isEmpty( systemPath ) )
|
||||
{
|
||||
result.addMessage( "For dependency " + d + ": system-scoped dependency must specify systemPath." );
|
||||
}
|
||||
else if ( !Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && StringUtils.isNotEmpty( d.getSystemPath() ) )
|
||||
else
|
||||
{
|
||||
if ( ! new File( systemPath ).isAbsolute() )
|
||||
{
|
||||
result.addMessage( "For dependency " + d + ": system-scoped dependency must " +
|
||||
"specify an absolute path systemPath." );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( StringUtils.isNotEmpty( d.getSystemPath() ) )
|
||||
{
|
||||
result.addMessage(
|
||||
"For dependency " + d + ": only dependency with system scope can specify systemPath." );
|
||||
|
@ -110,12 +124,24 @@ public class DefaultModelValidator
|
|||
validateSubElementStringNotEmpty( d, "dependencyManagement.dependencies.dependency.groupId", result,
|
||||
d.getGroupId() );
|
||||
|
||||
if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && StringUtils.isEmpty( d.getSystemPath() ) )
|
||||
if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) )
|
||||
{
|
||||
result.addMessage(
|
||||
"For managed dependency " + d + ": system-scoped dependency must specify systemPath." );
|
||||
String systemPath = d.getSystemPath();
|
||||
|
||||
if ( StringUtils.isEmpty( systemPath ) )
|
||||
{
|
||||
result.addMessage( "For managed dependency " + d + ": system-scoped dependency must specify systemPath." );
|
||||
}
|
||||
else if ( !Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && StringUtils.isNotEmpty( d.getSystemPath() ) )
|
||||
else
|
||||
{
|
||||
if ( ! new File( systemPath ).isAbsolute() )
|
||||
{
|
||||
result.addMessage( "For managed dependency " + d + ": system-scoped dependency must " +
|
||||
"specify an absolute path systemPath." );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( StringUtils.isNotEmpty( d.getSystemPath() ) )
|
||||
{
|
||||
result.addMessage(
|
||||
"For managed dependency " + d + ": only dependency with system scope can specify systemPath." );
|
||||
|
|
Loading…
Reference in New Issue