[MNG-4658] Relax validation of repository ids and only warn upon conflict with "local"

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@940790 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-05-04 09:57:46 +00:00
parent 630c059142
commit 90027ef75a
3 changed files with 21 additions and 11 deletions

View File

@ -90,7 +90,9 @@ public class DefaultSettingsValidator
if ( "local".equals( mirror.getId() ) )
{
addError( problems, "'mirrors.mirror.id' must not be 'local', this identifier is reserved." );
addWarn( problems, "'mirrors.mirror.id' must not be 'local'"
+ ", this identifier is reserved for the local repository"
+ ", using it for other repositories will corrupt your repository metadata." );
}
validateStringNotEmpty( problems, "mirrors.mirror.url", mirror.getUrl(), mirror.getId() );
@ -119,7 +121,9 @@ public class DefaultSettingsValidator
if ( "local".equals( repository.getId() ) )
{
addError( problems, "'" + prefix + ".id' must not be 'local', this identifier is reserved." );
addWarn( problems, "'" + prefix + ".id' must not be 'local'"
+ ", this identifier is reserved for the local repository"
+ ", using it for other repositories will corrupt your repository metadata." );
}
validateStringNotEmpty( problems, prefix + ".url", repository.getUrl(), repository.getId() );

View File

@ -500,8 +500,10 @@ public class DefaultModelValidator
{
if ( "local".equals( repository.getId() ) )
{
addViolation( problems, Severity.ERROR, prefix + ".id", null,
"must not be 'local', this identifier is reserved." );
Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 );
addViolation( problems, errOn31, prefix + ".id", null, "must not be 'local'"
+ ", this identifier is reserved for the local repository"
+ ", using it for other repositories will corrupt your repository metadata." );
}
if ( "legacy".equals( repository.getLayout() ) )
{

View File

@ -84,6 +84,11 @@ public class DefaultModelValidatorTest
return problems;
}
private void assertContains( String msg, String substring )
{
assertTrue( "\"" + substring + "\" was not found in: " + msg, msg.contains( substring ) );
}
@Override
protected void setUp()
throws Exception
@ -439,14 +444,13 @@ public class DefaultModelValidatorTest
{
SimpleProblemCollector result = validate( "reserved-repository-id.xml" );
assertViolations( result, 0, 4, 0 );
assertViolations( result, 0, 0, 4 );
assertTrue( result.getErrors().get( 0 ).contains( "'repositories.repository.id' must not be 'local'" ) );
assertTrue( result.getErrors().get( 1 ).contains(
"'pluginRepositories.pluginRepository.id' must not be 'local'" ) );
assertTrue( result.getErrors().get( 2 ).contains( "'distributionManagement.repository.id' must not be 'local'" ) );
assertTrue( result.getErrors().get( 3 ).contains(
"'distributionManagement.snapshotRepository.id' must not be 'local'" ) );
assertContains( result.getWarnings().get( 0 ), "'repositories.repository.id'" + " must not be 'local'" );
assertContains( result.getWarnings().get( 1 ), "'pluginRepositories.pluginRepository.id' must not be 'local'" );
assertContains( result.getWarnings().get( 2 ), "'distributionManagement.repository.id' must not be 'local'" );
assertContains( result.getWarnings().get( 3 ),
"'distributionManagement.snapshotRepository.id' must not be 'local'" );
}
public void testMissingPluginDependencyGroupId()