maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r737812 - in /maven/components/trunk: maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java pom.xml
Date Mon, 26 Jan 2009 20:22:20 GMT
Author: sisbell
Date: Mon Jan 26 20:22:20 2009
New Revision: 737812

URL: http://svn.apache.org/viewvc?rev=737812&view=rev
Log:
Fixed various ordering of element problems during plugin management joins.

Modified:
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java
    maven/components/trunk/pom.xml

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java?rev=737812&r1=737811&r2=737812&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
Mon Jan 26 20:22:20 2009
@@ -177,7 +177,7 @@
             }
         }
 
-        boolean joinedContainer = false;
+        List<ModelProperty> joinedContainers = new ArrayList<ModelProperty>();
         for ( ModelContainer pluginContainer : source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri
) )
         {
             for ( ModelContainer managementContainer : source.queryFor( ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri
) )
@@ -230,7 +230,6 @@
 
                 if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE
) )
                 {
-                    joinedContainer = true;
                     ModelDataSource pluginDatasource = new DefaultModelDataSource(  pluginContainer.getProperties(),
PomTransformer.MODEL_CONTAINER_FACTORIES );
                     ModelDataSource managementDatasource = new DefaultModelDataSource( managementContainer.getProperties(),
PomTransformer.MODEL_CONTAINER_FACTORIES );
 
@@ -241,7 +240,7 @@
                         managementPropertiesWithoutExecutions.removeAll(a.getProperties());
                     }
                     //THIS JOIN REVERSES ORDER
-                    source.join( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions)
);
+                    source.joinWithOriginalOrder( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions)
);
 
                     List<ModelContainer> pluginExecutionContainers = pluginDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
                     List<ModelContainer> joinedExecutionContainers = new ArrayList<ModelContainer>();
@@ -266,13 +265,19 @@
                     	
                         for(ModelContainer b : pluginExecutionContainers)
                         {
-                            if(b.containerAction(c).equals(ModelContainerAction.JOIN)) //----
+                            if(b.containerAction(c).equals(ModelContainerAction.JOIN))
                             {
                                 //MNG-3995 - property lost here
-                                source.join(b, c);
+                                joinedContainers.addAll(source.join(b, c).getProperties());
+              // ExecutionRule rule = new ExecutionRule();
+               // List<ModelProperty> x = rule.execute(d.getProperties());
+               // List<ModelProperty> x = (!joinedContainer) ? rule.execute(es.getProperties())
:
+               //         ModelTransformerContext.sort(rule.execute(es.getProperties()),
+               //                 ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
+
+             //   source.replace(d, d.createNewInstance(x));
                                 //REVERSE ORDER HERE
-                                joinedExecutionContainers.add(a);//-----
-                     //           Collections.reverse(joinedExecutionContainers);
+                                joinedExecutionContainers.add(a);
                             }
                         }
                     }
@@ -363,17 +368,17 @@
                                     new AlwaysJoinModelContainerFactory()));
             for(ModelContainer es : executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri
)) {
                 ExecutionRule rule = new ExecutionRule();
-                List<ModelProperty> x = rule.execute(es.getProperties());
-               // List<ModelProperty> x = (!joinedContainer) ? rule.execute(es.getProperties())
:
-               //         ModelTransformerContext.sort(rule.execute(es.getProperties()),
-               //                 ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
+               // List<ModelProperty> x = rule.execute(es.getProperties());
+                List<ModelProperty> x = !aContainsAnyOfB(es.getProperties(), joinedContainers)
? rule.execute(es.getProperties()) :
+                        ModelTransformerContext.sort(rule.execute(es.getProperties()),
+                                ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
                 
                 dataSource.replace(es, es.createNewInstance(x));
             }
         }
 
-        props = joinedContainer ? ModelTransformerContext.sort(dataSource.getModelProperties(),
ProjectUri.baseUri)
-                : dataSource.getModelProperties();
+        props =// false ? ModelTransformerContext.sort(dataSource.getModelProperties(), ProjectUri.baseUri)
+                dataSource.getModelProperties();
        
         for(ModelEventListener listener : eventListeners)
         {
@@ -411,6 +416,20 @@
         return factory.createDomainModel( p );
     }
 
+    private static boolean aContainsAnyOfB(List<ModelProperty> a, List<ModelProperty>
b) {
+        for(ModelProperty mpA : a )
+        {
+            for(ModelProperty mpB : b)
+            {
+                if(mpA.equals(mpB))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     private static List<ModelProperty> transformDependencyManagement( List<ModelProperty>
modelProperties )
     {
         List<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java?rev=737812&r1=737811&r2=737812&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java
(original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java
Mon Jan 26 20:22:20 2009
@@ -81,6 +81,14 @@
         assertModelEquals( tester, "child-descriptor", "build/plugins[1]/executions[1]/goals[1]"
);
     }
 
+    public void testPluginOrder()
+        throws Exception
+    {
+        PomTestWrapper pom = buildPom( "plugin-order" );
+        assertEquals( "plexus-component-metadata", pom.getValue( "build/plugins[1]/artifactId"
) );
+        assertEquals( "maven-surefire-plugin", pom.getValue( "build/plugins[2]/artifactId"
) );
+    }
+
     public void testErroneousJoiningOfDifferentPluginsWithEqualDependencies()
         throws Exception
     {

Modified: maven/components/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/pom.xml?rev=737812&r1=737811&r2=737812&view=diff
==============================================================================
--- maven/components/trunk/pom.xml (original)
+++ maven/components/trunk/pom.xml Mon Jan 26 20:22:20 2009
@@ -55,7 +55,7 @@
     <plexusPluginManagerVersion>1.0-alpha-1</plexusPluginManagerVersion>
     <plexusUtilsVersion>1.5.6</plexusUtilsVersion>
     <wagonVersion>1.0-beta-4</wagonVersion>
-    <modelBuilderVersion>1.2</modelBuilderVersion>
+    <modelBuilderVersion>1.3</modelBuilderVersion>
     <mercuryVersion>1.0.0-alpha-2</mercuryVersion>
     <woodstoxVersion>3.2.6</woodstoxVersion>
     <modelloVersion>1.0-alpha-22</modelloVersion>



Mime
View raw message