maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r770454 - /maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Date Thu, 30 Apr 2009 21:32:50 GMT
Author: sisbell
Date: Thu Apr 30 21:32:48 2009
New Revision: 770454

URL: http://svn.apache.org/viewvc?rev=770454&view=rev
Log:
Need to override lifecycle plugin versions if there is a pluginMng entry for it.

Modified:
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=770454&r1=770453&r2=770454&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Thu Apr 30 21:32:48 2009
@@ -180,7 +180,7 @@
 			addPluginsToModel(model, plugins);			
 							
 			ProcessorContext.processManagementNodes(model);
-			
+		 					
 			project = this.fromDomainModelToMavenProject(model, domainModel.getParentFile(), configuration,
pomFile);
  			
 			ArrayList<Plugin> pln = new ArrayList<Plugin>();
@@ -194,13 +194,9 @@
 			Set<Plugin> pl = lifecycle.populateDefaultConfigurationForPlugins(new HashSet<Plugin>(pln),

 				project, configuration.getLocalRepository());
 			/*
-    		if(model.getArtifactId() != null &&
-    				model.getArtifactId().equals("maven-model"))
-    			{
-    			System.out.println(new DomainModel(project.getModel()).asString());
-    			} 			
+		
 			*/
-    		
+		   		
 			for (Plugin buildPlugin : pl) {
 				Xpp3Dom dom = (Xpp3Dom) buildPlugin.getConfiguration();
 				Plugin x = containsPlugin(buildPlugin, project.getModel()
@@ -224,8 +220,14 @@
 				}
 
 			}    		
-			project.getModel().getBuild().setPlugins(new ArrayList<Plugin>(pl));	
-
+			project.getModel().getBuild().setPlugins(new ArrayList<Plugin>(pl));
+			/*
+	 		if(model.getArtifactId() != null &&
+    				model.getArtifactId().equals("maven-model"))
+    			{
+    			System.out.println(new DomainModel(project.getModel()).asString());
+    			} 
+    			*/
 		} 
 		catch (IOException e) 
 		{
@@ -277,24 +279,35 @@
     
     public static void addPluginsToModel(Model target, Set<Plugin> plugins)
     {
-    	List<Plugin> mPlugins = new ArrayList<Plugin>(target.getBuild().getPlugins());
+    	List<Plugin> mngPlugins = (target.getBuild().getPluginManagement() != null)
+    		? target.getBuild().getPluginManagement().getPlugins() : new ArrayList<Plugin>();
+    		
+    	List<Plugin> pomPlugins = new ArrayList<Plugin>(target.getBuild().getPlugins());
     	
     	List<Plugin> lifecyclePlugins = new ArrayList<Plugin>();
     	
     	for( Plugin p : plugins )
     	{
-    		Plugin mPlugin = containsPlugin( p, mPlugins);
-    		if( mPlugin == null)
+    		//Go ahead and add version if exists in pluginManagement - don't use default version
+    		Plugin mngPlugin = containsPlugin(p, mngPlugins);
+    		if(mngPlugin != null && mngPlugin.getVersion() != null)
+    		{
+    			//System.out.println("Set version:" + p.getVersion() + ": To = " + mngPlugin.getVersion());
+    			p.setVersion(mngPlugin.getVersion());
+    		}
+    		
+    		Plugin pomPlugin = containsPlugin( p, pomPlugins);
+    		if( pomPlugin == null)
     		{
     			lifecyclePlugins.add(p);
     		}
     		else if(p.getConfiguration() != null)
     		{
-    			System.out.println(Xpp3Dom.mergeXpp3Dom((Xpp3Dom) p.getConfiguration(), (Xpp3Dom)
mPlugin.getConfiguration()));
+    			System.out.println(Xpp3Dom.mergeXpp3Dom((Xpp3Dom) p.getConfiguration(), (Xpp3Dom)
pomPlugin.getConfiguration()));
     		}
     	}
-    	mPlugins.addAll(lifecyclePlugins);
-    	target.getBuild().setPlugins(mPlugins);
+    	pomPlugins.addAll(lifecyclePlugins);
+    	target.getBuild().setPlugins(pomPlugins);
 
     }
     
@@ -310,7 +323,7 @@
     	
     	return null;
     }    
-        
+	    
     public MavenProject buildFromRepository(Artifact artifact, ProjectBuilderConfiguration
configuration )
     	throws ProjectBuildingException
     {



Mime
View raw message