mirror of https://github.com/apache/maven.git
[MNG-4466] Plugin Metaversion Compatibility
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@883537 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a8f2a0dd49
commit
6de5f3f3de
|
@ -264,7 +264,7 @@ public class DefaultModelValidator
|
||||||
validateStringNotEmpty( "build.plugins.plugin.version", problems, errOn31, p.getVersion(),
|
validateStringNotEmpty( "build.plugins.plugin.version", problems, errOn31, p.getVersion(),
|
||||||
p.getKey() );
|
p.getKey() );
|
||||||
|
|
||||||
validateVersion( "build.plugins.plugin.version", problems, errOn30, p.getVersion(), p.getKey() );
|
validatePluginVersion( "build.plugins.plugin.version", problems, errOn30, p.getVersion(), p.getKey() );
|
||||||
|
|
||||||
validateBoolean( "build.plugins.plugin.inherited", problems, errOn30, p.getInherited(),
|
validateBoolean( "build.plugins.plugin.inherited", problems, errOn30, p.getInherited(),
|
||||||
p.getKey() );
|
p.getKey() );
|
||||||
|
@ -655,6 +655,32 @@ public class DefaultModelValidator
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean validatePluginVersion( String fieldName, ModelProblemCollector problems, Severity severity, String string,
|
||||||
|
String sourceHint )
|
||||||
|
{
|
||||||
|
if ( string == null || string.length() <= 0 )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !hasExpression( string ) && !"RELEASE".equals( string ) && !"LATEST".equals( string ) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( sourceHint != null )
|
||||||
|
{
|
||||||
|
addViolation( problems, severity, "'" + fieldName + "' must be a valid version for " + sourceHint
|
||||||
|
+ " but is '" + string + "'." );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addViolation( problems, severity, "'" + fieldName + "' must be a valid version but is '" + string + "'." );
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static void addViolation( ModelProblemCollector problems, Severity severity, String message )
|
private static void addViolation( ModelProblemCollector problems, Severity severity, String message )
|
||||||
{
|
{
|
||||||
problems.add( severity, message, null );
|
problems.add( severity, message, null );
|
||||||
|
|
|
@ -376,9 +376,11 @@ public class DefaultModelValidatorTest
|
||||||
{
|
{
|
||||||
SimpleProblemCollector result = validate( "bad-plugin-version.xml" );
|
SimpleProblemCollector result = validate( "bad-plugin-version.xml" );
|
||||||
|
|
||||||
assertViolations( result, 0, 1, 0 );
|
assertViolations( result, 0, 3, 0 );
|
||||||
|
|
||||||
assertTrue( result.getErrors().get( 0 ).contains( "test:mip" ) );
|
assertTrue( result.getErrors().get( 0 ).contains( "test:mip" ) );
|
||||||
|
assertTrue( result.getErrors().get( 1 ).contains( "test:rmv" ) );
|
||||||
|
assertTrue( result.getErrors().get( 2 ).contains( "test:lmv" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDistributionManagementStatus()
|
public void testDistributionManagementStatus()
|
||||||
|
|
|
@ -25,11 +25,26 @@ under the License.
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>test</groupId>
|
||||||
|
<artifactId>good</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>test</groupId>
|
<groupId>test</groupId>
|
||||||
<artifactId>mip</artifactId>
|
<artifactId>mip</artifactId>
|
||||||
<version>${missing.property}</version>
|
<version>${missing.property}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>test</groupId>
|
||||||
|
<artifactId>rmv</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>test</groupId>
|
||||||
|
<artifactId>lmv</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue