maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r733637 - in /maven/components/trunk: maven-mercury/src/main/java/org/apache/maven/mercury/ maven-project-builder/src/main/java/org/apache/maven/project/builder/ maven-project-builder/src/test/java/org/apache/maven/project/builder/ maven-pr...
Date Mon, 12 Jan 2009 07:00:09 GMT
Author: sisbell
Date: Sun Jan 11 23:00:09 2009
New Revision: 733637

URL: http://svn.apache.org/viewvc?rev=733637&view=rev
Log:
Fix: Different types of ID Model containers were being joined if their ids matched. Now we
have one ID model container factory instance per type.

Modified:
    maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
    maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PluginSpecTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java

Modified: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java?rev=733637&r1=733636&r2=733637&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
(original)
+++ maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
Sun Jan 11 23:00:09 2009
@@ -120,8 +120,7 @@
 
         PomTransformer transformer = new PomTransformer( new MavenDomainModelFactory() );
         ModelTransformerContext ctx =
-            new ModelTransformerContext( Arrays.asList( new ArtifactModelContainerFactory(),
-                                                        new IdModelContainerFactory() ) );
+            new ModelTransformerContext( PomTransformer.MODEL_CONTAINER_FACTORIES );
 
         try
         {

Modified: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java?rev=733637&r1=733636&r2=733637&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
(original)
+++ maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
Sun Jan 11 23:00:09 2009
@@ -112,8 +112,7 @@
         List<ArtifactBasicMetadata> metadatas = new ArrayList<ArtifactBasicMetadata>();
 
         ModelDataSource source = new DefaultModelDataSource();
-        source.init( modelProperties,
-                     Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory()
) );
+        source.init( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES  );
 
         for ( ModelContainer modelContainer : source.queryFor( ProjectUri.Dependencies.Dependency.xUri
) )
         {
@@ -127,8 +126,7 @@
         throws DataSourceException
     {
         ModelDataSource dataSource = new DefaultModelDataSource();
-        dataSource.init( modelProperties, Arrays.asList( new ArtifactModelContainerFactory(),
-                                                         new IdModelContainerFactory() )
);
+        dataSource.init( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES );
         return new ProfileContext( dataSource, properties ).getActiveProfiles();
     }
 

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java?rev=733637&r1=733636&r2=733637&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java
Sun Jan 11 23:00:09 2009
@@ -34,16 +34,27 @@
     implements ModelContainerFactory
 {
 
-    private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
-        ProjectUri.PluginRepositories.PluginRepository.xUri,
-        ProjectUri.Repositories.Repository.xUri,
-        ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri,
-        ProjectUri.Profiles.Profile.xUri,
-        ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri ) );
-
+	private String uri;
+	
+	public IdModelContainerFactory(String uri) 
+	{
+		if(uri == null)
+		{
+			throw new IllegalArgumentException("uri: null");
+		}
+		this.uri = uri;
+	}
+	
+    public static final List<IdModelContainerFactory> ID_CONTAINER_FACTORIES = 
+    	Collections.unmodifiableList(Arrays.asList(new IdModelContainerFactory(ProjectUri.PluginRepositories.PluginRepository.xUri),
+    			new IdModelContainerFactory(ProjectUri.Repositories.Repository.xUri),
+    			new IdModelContainerFactory(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri),
+    			new IdModelContainerFactory(ProjectUri.Profiles.Profile.xUri),
+    			new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri)));
+	
     public Collection<String> getUris()
     {
-        return uris;
+        return Collections.unmodifiableList(Arrays.asList(uri));
     }
 
     public ModelContainer create( List<ModelProperty> modelProperties )

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=733637&r1=733636&r2=733637&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
Sun Jan 11 23:00:09 2009
@@ -35,6 +35,7 @@
 import org.apache.maven.shared.model.InterpolatorProperty;
 import org.apache.maven.shared.model.ModelContainer;
 import org.apache.maven.shared.model.ModelContainerAction;
+import org.apache.maven.shared.model.ModelContainerFactory;
 import org.apache.maven.shared.model.ModelDataSource;
 import org.apache.maven.shared.model.ModelEventListener;
 import org.apache.maven.shared.model.ModelProperty;
@@ -55,6 +56,14 @@
     {
         this.factory = factory;
     }
+
+    public static final List<ModelContainerFactory> MODEL_CONTAINER_FACTORIES = 
+    	Collections.unmodifiableList(Arrays.asList(new ArtifactModelContainerFactory(), 
+    			new IdModelContainerFactory(ProjectUri.PluginRepositories.PluginRepository.xUri),
+    			new IdModelContainerFactory(ProjectUri.Repositories.Repository.xUri),
+    			new IdModelContainerFactory(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri),
+    			new IdModelContainerFactory(ProjectUri.Profiles.Profile.xUri),
+    			new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri)));
     
     /**
      * The URIs this transformer supports
@@ -141,7 +150,7 @@
 
         //dependency management
         ModelDataSource source = new DefaultModelDataSource();
-        source.init( props, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory()
) );
+        source.init( props, PomTransformer.MODEL_CONTAINER_FACTORIES  );
 
         for ( ModelContainer dependencyContainer : source.queryFor( ProjectUri.Dependencies.Dependency.xUri
) )
         {
@@ -211,12 +220,10 @@
                 if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE
) )
                 {
                     ModelDataSource pluginDatasource = new DefaultModelDataSource();
-                    pluginDatasource.init( pluginContainer.getProperties(), Arrays.asList(
new ArtifactModelContainerFactory(),
-                            new IdModelContainerFactory() ) );
+                    pluginDatasource.init( pluginContainer.getProperties(), PomTransformer.MODEL_CONTAINER_FACTORIES
);
 
                     ModelDataSource managementDatasource = new DefaultModelDataSource();
-                    managementDatasource.init( managementContainer.getProperties(), Arrays.asList(
new ArtifactModelContainerFactory(),
-                            new IdModelContainerFactory() ) );
+                    managementDatasource.init( managementContainer.getProperties(), PomTransformer.MODEL_CONTAINER_FACTORIES
);
 
                     List<ModelContainer> managementExecutionContainers = managementDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
                     List<ModelProperty> managementPropertiesWithoutExecutions = new
ArrayList<ModelProperty>(managementContainer.getProperties());
@@ -244,7 +251,7 @@
                     	if(!hasId) {
                     		List<ModelProperty> listWithId = new ArrayList<ModelProperty>(a.getProperties());
                     		listWithId.add(1, new ModelProperty(ProjectUri.Build.Plugins.Plugin.Executions.Execution.id,
"default"));
-                    		c = new IdModelContainerFactory().create(listWithId);
+                    		c = new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri).create(listWithId);
                     	}
                     	
                     	
@@ -300,7 +307,7 @@
         
         ModelDataSource dataSource = new DefaultModelDataSource();
         
-        dataSource.init( props, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory()
) );
+        dataSource.init( props, PomTransformer.MODEL_CONTAINER_FACTORIES );
         
         List<ModelContainer> containers = dataSource.queryFor( ProjectUri.Build.Plugins.Plugin.xUri
);
         
@@ -494,7 +501,7 @@
             {
                 List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
                 ModelDataSource source = new DefaultModelDataSource();
-                source.init( tmp, Arrays.asList( new ArtifactModelContainerFactory(), new
IdModelContainerFactory() ) );
+                source.init( tmp, PomTransformer.MODEL_CONTAINER_FACTORIES );
                 List<ModelContainer> containers = source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri
);
                 for ( ModelContainer container : containers )
                 {
@@ -612,7 +619,7 @@
 
         //Rule: Build plugin config overrides reporting plugin config
         ModelDataSource source = new DefaultModelDataSource();
-        source.init( modelProperties, Arrays.asList( new ArtifactModelContainerFactory(),
new IdModelContainerFactory() ) );
+        source.init( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES );
 
         List<ModelContainer> reportContainers = source.queryFor( ProjectUri.Reporting.Plugins.Plugin.xUri
);
         for ( ModelContainer pluginContainer : source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri
) )

Modified: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java?rev=733637&r1=733636&r2=733637&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java
Sun Jan 11 23:00:09 2009
@@ -44,14 +44,13 @@
         DomainModel childModel = new DefaultDomainModel(mp2);
         DomainModel parentModel = new DefaultDomainModel(mp);
 
-        ModelTransformerContext ctx = new ModelTransformerContext(Arrays.asList(new ArtifactModelContainerFactory(),
-                new IdModelContainerFactory()));
+        ModelTransformerContext ctx = new ModelTransformerContext(PomTransformer.MODEL_CONTAINER_FACTORIES
);
 
         ModelTransformer transformer = new PomTransformer(new DefaultDomainModelFactory());
         DomainModel domainModel = ctx.transform( Arrays.asList(childModel, parentModel),
transformer, transformer );
 
         DefaultModelDataSource source = new DefaultModelDataSource();
-        source.init(domainModel.getModelProperties(), Arrays.asList(new ArtifactModelContainerFactory(),
new IdModelContainerFactory()));
+        source.init(domainModel.getModelProperties(), PomTransformer.MODEL_CONTAINER_FACTORIES
);
         List<ModelContainer> containers = source.queryFor(ProjectUri.Dependencies.Dependency.xUri);
         assertTrue(containers.size() == 2 );
 

Modified: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PluginSpecTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PluginSpecTest.java?rev=733637&r1=733636&r2=733637&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PluginSpecTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PluginSpecTest.java
Sun Jan 11 23:00:09 2009
@@ -50,15 +50,16 @@
 
         DomainModel parentModel = new DefaultDomainModel(mp);
 
-        ModelTransformerContext ctx = new ModelTransformerContext(Arrays.asList(new ArtifactModelContainerFactory(),
-                new IdModelContainerFactory()));
+        ModelTransformerContext ctx = new ModelTransformerContext(PomTransformer.MODEL_CONTAINER_FACTORIES
);
 
         ModelTransformer transformer = new PomTransformer(new DefaultDomainModelFactory());
         DomainModel domainModel = ctx.transform( Arrays.asList(parentModel, new DefaultDomainModel(mp0)),
transformer, transformer );
 
         DefaultModelDataSource source = new DefaultModelDataSource();
-        source.init(domainModel.getModelProperties(), Arrays.asList(new ArtifactModelContainerFactory(),
-                new IdModelContainerFactory(),  new PluginExecutionIdModelContainerFactory()));
+        List<ModelContainerFactory> factories = new ArrayList<ModelContainerFactory>(PomTransformer.MODEL_CONTAINER_FACTORIES);
+        factories.add(new PluginExecutionIdModelContainerFactory());
+        
+        source.init(domainModel.getModelProperties(), factories);
         List<ModelContainer> containers = source.queryFor(ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.Execution.xUri);
         assertTrue(2 == containers.size());
 

Modified: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java?rev=733637&r1=733636&r2=733637&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
Sun Jan 11 23:00:09 2009
@@ -1,6 +1,7 @@
 package org.apache.maven.project.builder.profile;
 
 import org.apache.maven.project.builder.profile.ProfileContext;
+import org.apache.maven.project.builder.PomTransformer;
 import org.apache.maven.project.builder.ProjectUri;
 import org.apache.maven.project.builder.ArtifactModelContainerFactory;
 import org.apache.maven.project.builder.IdModelContainerFactory;
@@ -30,7 +31,7 @@
         modelProperties.add(new ModelProperty(ProjectUri.Profiles.Profile.Activation.Property.value
, "bar"));
 
         DefaultModelDataSource dataSource = new DefaultModelDataSource();
-        dataSource.init(modelProperties, Arrays.asList(new ArtifactModelContainerFactory(),
new IdModelContainerFactory()));
+        dataSource.init(modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES );
 
         List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>();
         interpolatorProperties.add(new InterpolatorProperty( "${foo}", "bar"));

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java?rev=733637&r1=733636&r2=733637&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
Sun Jan 11 23:00:09 2009
@@ -43,6 +43,7 @@
 import org.apache.maven.project.builder.PomClassicDomainModel;
 import org.apache.maven.project.builder.PomClassicDomainModelFactory;
 import org.apache.maven.project.builder.PomClassicTransformer;
+import org.apache.maven.project.builder.PomTransformer;
 import org.apache.maven.project.builder.ProjectBuilder;
 import org.apache.maven.shared.model.DomainModel;
 import org.apache.maven.shared.model.InterpolatorProperty;
@@ -156,8 +157,7 @@
         
         PomClassicTransformer transformer = new PomClassicTransformer( new PomClassicDomainModelFactory()
);
         
-        ModelTransformerContext ctx = new ModelTransformerContext(
-            Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory()
) );
+        ModelTransformerContext ctx = new ModelTransformerContext(PomTransformer.MODEL_CONTAINER_FACTORIES
);
         
         PomClassicDomainModel transformedDomainModel = ( (PomClassicDomainModel) ctx.transform(
domainModels,
                                                                                         
       transformer,



Mime
View raw message