mirror of https://github.com/apache/maven.git
[MNG-4297] Disallow use of properties in the project coordinates
o For Maven 3.0, started to produce a warning git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@803995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b3611a4fdd
commit
f2946af284
|
@ -322,7 +322,7 @@ public class DefaultMaven
|
|||
logger.warn( "It is highly recommended to fix these problems"
|
||||
+ " because they threaten the stability of your build." );
|
||||
logger.warn( "" );
|
||||
logger.warn( "For this reason, future Maven versions will no"
|
||||
logger.warn( "For this reason, future Maven versions might no"
|
||||
+ " longer support building such malformed projects." );
|
||||
logger.warn( "" );
|
||||
}
|
||||
|
|
|
@ -289,6 +289,7 @@ public class DefaultModelBuilder
|
|||
|
||||
model.setPomFile( pomFile );
|
||||
|
||||
problems.setSourceHint( model );
|
||||
modelValidator.validateRawModel( model, request, problems );
|
||||
|
||||
return model;
|
||||
|
|
|
@ -71,6 +71,10 @@ public class DefaultModelValidator
|
|||
|
||||
if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
|
||||
{
|
||||
validateStringNoExpression( "groupId", problems, true, model.getGroupId() );
|
||||
validateStringNoExpression( "artifactId", problems, true, model.getArtifactId() );
|
||||
validateStringNoExpression( "version", problems, true, model.getVersion() );
|
||||
|
||||
validateDependencies( problems, model.getDependencies(), "dependencies.dependency", request );
|
||||
|
||||
if ( model.getDependencyManagement() != null )
|
||||
|
@ -385,6 +389,24 @@ public class DefaultModelValidator
|
|||
// Field validation
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private boolean validateStringNoExpression( String fieldName, ModelProblemCollector problems, boolean warning,
|
||||
String string )
|
||||
{
|
||||
if ( !hasExpression( string ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
addViolation( problems, warning, "'" + fieldName + "' contains an expression but should be a constant." );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasExpression( String value )
|
||||
{
|
||||
return value != null && value.indexOf( "${" ) >= 0;
|
||||
}
|
||||
|
||||
private boolean validateStringNotEmpty( String fieldName, ModelProblemCollector problems, boolean warning, String string )
|
||||
{
|
||||
return validateStringNotEmpty( fieldName, problems, warning, string, null );
|
||||
|
|
Loading…
Reference in New Issue