maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r690856 - /maven/components/branches/sisbell-maven-2.1-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
Date Mon, 01 Sep 2008 06:19:14 GMT
Author: sisbell
Date: Sun Aug 31 23:19:13 2008
New Revision: 690856

URL: http://svn.apache.org/viewvc?rev=690856&view=rev
Log:
Rule: Do not join plugin executions without ids

Modified:
    maven/components/branches/sisbell-maven-2.1-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java

Modified: maven/components/branches/sisbell-maven-2.1-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-2.1-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java?rev=690856&r1=690855&r2=690856&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-2.1-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
(original)
+++ maven/components/branches/sisbell-maven-2.1-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
Sun Aug 31 23:19:13 2008
@@ -453,7 +453,48 @@
             }
                        */
         }
-       return modelProperties;
+
+       //Rule: Do not join plugin executions without ids
+       List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
+       ModelDataSource source = new DefaultModelDataSource();
+       source.init( modelProperties, Arrays.asList( new ArtifactModelContainerFactory(),
new IdModelContainerFactory() ) );
+       List<ModelContainer> containers =  source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri
);
+        for (ModelContainer pluginContainer : containers) {
+            ModelDataSource executionSource = new DefaultModelDataSource();
+            executionSource.init( pluginContainer.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(),
+                    new IdModelContainerFactory() ) );
+            List<ModelContainer> executionContainers =
+                    source.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri
 );
+            if(executionContainers.size() < 2)
+            {
+                break;
+            }
+            boolean hasAtLeastOneWithoutId = true;
+            for (ModelContainer executionContainer : executionContainers) {
+                if(hasAtLeastOneWithoutId)
+                {
+                    hasAtLeastOneWithoutId = hasExecutionId(executionContainer);
+                }
+                if(!hasAtLeastOneWithoutId && !hasExecutionId(executionContainer)
&& executionContainers.indexOf(executionContainer) > 0)
+                {
+                    removeProperties.addAll(executionContainer.getProperties());
+                }
+            }           
+        }
+        modelProperties.removeAll(removeProperties);
+        return modelProperties;
+    }
+
+    private static boolean hasExecutionId(ModelContainer executionContainer)
+    {
+        for(ModelProperty mp : executionContainer.getProperties() )
+        {
+            if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.id))
+            {
+                return true;
+            }
+        }
+        return false;
     }
 
     /**



Mime
View raw message