o Refactored code

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@934381 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-04-15 12:04:02 +00:00
parent effd92055c
commit a315a9dac3
1 changed files with 15 additions and 29 deletions

View File

@ -34,6 +34,7 @@ import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Profile;
import org.apache.maven.model.ReportPlugin;
@ -71,7 +72,8 @@ public class DefaultModelValidator
if ( equals( parent.getGroupId(), model.getGroupId() )
&& equals( parent.getArtifactId(), model.getArtifactId() ) )
{
addViolation( problems, Severity.FATAL, "The parent element cannot have the same ID as the project." );
addViolation( problems, Severity.FATAL, "parent.artifactId", null, "must be changed"
+ ", the parent element cannot have the same groupId:artifactId as the project." );
}
}
@ -161,6 +163,18 @@ public class DefaultModelValidator
{
index.put( key, plugin );
}
Set<String> executionIds = new HashSet<String>();
for ( PluginExecution exec : plugin.getExecutions() )
{
if ( !executionIds.add( exec.getId() ) )
{
addViolation( problems, Severity.ERROR, "build.plugins.plugin[" + plugin.getKey()
+ "].executions.execution.id", null, "must be unique but found duplicate execution with id "
+ exec.getId() );
}
}
}
}
@ -266,8 +280,6 @@ public class DefaultModelValidator
}
}
forcePluginExecutionIdCollision( model, problems );
for ( Repository repository : model.getRepositories() )
{
validateRepository( problems, repository, "repositories.repository", request );
@ -487,32 +499,6 @@ public class DefaultModelValidator
}
}
private void forcePluginExecutionIdCollision( Model model, ModelProblemCollector problems )
{
Build build = model.getBuild();
if ( build != null )
{
List<Plugin> plugins = build.getPlugins();
if ( plugins != null )
{
for ( Plugin plugin : plugins )
{
// this will force an IllegalStateException, even if we don't have to do inheritance assembly.
try
{
plugin.getExecutionsAsMap();
}
catch ( IllegalStateException collisionException )
{
addViolation( problems, Severity.ERROR, collisionException.getMessage() );
}
}
}
}
}
// ----------------------------------------------------------------------
// Field validation
// ----------------------------------------------------------------------