Author: bentmann
Date: Thu Apr 15 12:04:02 2010
New Revision: 934381
URL: http://svn.apache.org/viewvc?rev=934381&view=rev
Log:
o Refactored code
Modified:
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
Modified:
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java?rev=934381&r1=934380&r2=934381&view=diff
==============================================================================
---
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
(original)
+++
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
Thu Apr 15 12:04:02 2010
@@ -34,6 +34,7 @@ import org.apache.maven.model.Distributi
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
// ----------------------------------------------------------------------