maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r769235 - in /maven/components/branches/MNG-2766: maven-core/src/main/java/org/apache/maven/execution/ maven-embedder/src/main/java/org/apache/maven/cli/ maven-embedder/src/main/java/org/apache/maven/embedder/ maven-model-builder/src/main/j...
Date Tue, 28 Apr 2009 04:12:33 GMT
Author: sisbell
Date: Tue Apr 28 04:12:32 2009
New Revision: 769235

URL: http://svn.apache.org/viewvc?rev=769235&view=rev
Log:
Default plugins.

Modified:
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
    maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
    maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
    maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java
    maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java
    maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/Interpolator.java
    maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
    maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
Tue Apr 28 04:12:32 2009
@@ -18,10 +18,13 @@
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.profiles.ProfileActivationContext;
 import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.project.DefaultProjectBuilderConfiguration;
@@ -68,6 +71,8 @@
     private File globalSettingsFile;
 
     private File userToolchainsFile;
+    
+    private Set<Plugin> plugins;
 
     // ----------------------------------------------------------------------------
     // Request
@@ -115,6 +120,8 @@
      * @issue MNG-2681
      */
     private boolean noSnapshotUpdates;
+    
+    public DefaultMavenExecutionRequest() { }
         
     public static MavenExecutionRequest copy( MavenExecutionRequest original )
     {
@@ -149,6 +156,7 @@
         copy.setProfileManager( original.getProfileManager() );
         copy.setRemoteRepositories( original.getRemoteRepositories() );
         copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
+        copy.setPlugins(original.getPlugins());//TODO - deeper copy
         return original;        
     }
    
@@ -697,8 +705,23 @@
             projectBuildingConfiguration.setUserProperties( getUserProperties() );
             projectBuildingConfiguration.setBuildStartTime( getStartTime() );
             projectBuildingConfiguration.setRemoteRepositories( getRemoteRepositories() );
+            projectBuildingConfiguration.setPlugins(getPlugins());
         }
 
         return projectBuildingConfiguration;
     }
+    
+    public void setPlugins(Set<Plugin> plugins)
+    {
+    	this.plugins = plugins;
+    }
+    
+    public Set<Plugin> getPlugins()
+    {
+    	if(plugins == null)
+    	{
+    		plugins = new HashSet<Plugin>();
+    	}
+    	return plugins;
+    }    
 }

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
Tue Apr 28 04:12:32 2009
@@ -23,9 +23,11 @@
 import java.util.Date;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.profiles.ProfileActivationContext;
 import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.project.ProjectBuilderConfiguration;
@@ -211,4 +213,8 @@
     MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
 
     ProjectBuilderConfiguration getProjectBuildingConfiguration();
+    
+    void setPlugins(Set<Plugin> plugins);
+    
+    Set<Plugin> getPlugins();   
 }

Modified: maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
(original)
+++ maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
Tue Apr 28 04:12:32 2009
@@ -34,6 +34,7 @@
 import org.apache.maven.embedder.MavenEmbedderLogger;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionResult;
+import org.apache.maven.lifecycle.LifecycleExecutor;
 import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.classworlds.ClassWorld;
 
@@ -242,7 +243,7 @@
         {
             configuration.setLocalRepository( new File( localRepoProperty ) );
         }
-
+        
         return configuration;
     }
 

Modified: maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
(original)
+++ maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
Tue Apr 28 04:12:32 2009
@@ -33,6 +33,7 @@
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionResult;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.lifecycle.LifecycleExecutor;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
@@ -125,6 +126,8 @@
     private Configuration configuration;
 
     private MavenExecutionRequest request;
+    
+    private LifecycleExecutor lifecycleExecutor;
 
     // ----------------------------------------------------------------------------
     // Constructors
@@ -452,6 +455,8 @@
 
             container.lookup( RepositorySystem.class );
             
+            lifecycleExecutor = container.lookup( LifecycleExecutor.class );
+            
             // This is temporary as we can probably cache a single request and use it for
default values and
             // simply cascade values in from requests used for individual executions.
             request = new DefaultMavenExecutionRequest();
@@ -572,6 +577,8 @@
 
         int oldThreshold = loggerManager.getThreshold();
 
+        request.setPlugins(lifecycleExecutor.lifecyclePlugins("default", "jar"));
+        
         try
         {
             loggerManager.setThresholds( request.getLoggingLevel() );

Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java
(original)
+++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java
Tue Apr 28 04:12:32 2009
@@ -25,6 +25,8 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Set;
+
 import org.apache.maven.model.BuildBase;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DependencyManagement;
@@ -256,10 +258,69 @@
       
     }
     
+    private static void addPlugin(Build build, String id)
+    {	
+    	Plugin p1 = new Plugin();
+    	p1.setArtifactId(id);
+    	build.addPlugin(p1);   	
+    }
+    
+    public static void addPluginsToModel(Model target, Set<Plugin> plugins)
+    {
+    	Build build = target.getBuild();
+    	addPlugin(build, "maven-compiler-plugin");
+    	addPlugin(build, "maven-resources-plugin");
+    	addPlugin(build, "maven-deploy-plugin");
+    	addPlugin(build, "maven-jar-plugin");
+    	addPlugin(build, "maven-compiler-plugin");
+    	addPlugin(build, "maven-surefire-plugin");
+        	
+     /*   	
+        	rg.apache.maven.plugins:maven-jar-plugin
+            [java] PLUGIN: org.apache.maven.plugins:maven-resources-plugin
+            [java] PLUGIN: org.apache.maven.plugins:maven-deploy-plugin
+            [java] PLUGIN: org.apache.maven.plugins:maven-install-plugin
+            [java] PLUGIN: org.apache.maven.plugins:maven-jar-plugin
+            [java] PLUGIN: org.apache.maven.plugins:maven-resources-plugin
+            [java] PLUGIN: org.apache.maven.plugins:maven-surefire-plugin
+            [java] PLUGIN: org.apache.maven.plugins:maven-deploy-plugin
+/*   	
+    	List<Plugin> mPlugins = target.getBuild().getPlugins();
+    	
+    	List<Plugin> lifecyclePlugins = new ArrayList<Plugin>();
+    	
+    	for( Plugin p : plugins )
+    	{
+    		if( !containsPlugin( p, mPlugins) )
+    		{
+    			lifecyclePlugins.add(p);
+    			System.out.println("PLUGIN: " + p.getKey());
+    		}
+    	}
+    	
+    	target.getBuild().getPlugins().addAll(lifecyclePlugins);
+    */	
+    }
+    
+    private static boolean containsPlugin(Plugin plugin, List<Plugin> plugins)
+    {
+    	for(Plugin p : plugins)
+    	{
+    		if( p.getGroupId().equals(plugin.getGroupId()) && p.getArtifactId().equals(plugin.getArtifactId()))
+    		{
+    			return true;
+    		}
+    	}
+    	
+    	return false;
+    }
+    
     public static Model processManagementNodes(Model target) 
     	throws IOException
     {
-
+    //	Plugin plugin = new Plugin();
+    //	plugin.setArtifactId("maven-compiler-plugin");
+  //  	target.getBuild().addPlugin(plugin);
         // Dependency Management
         DependencyManagementProcessor depProc = new DependencyManagementProcessor();
         if ( target.getDependencyManagement() != null )

Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java
(original)
+++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java
Tue Apr 28 04:12:32 2009
@@ -14,7 +14,9 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
+import java.util.Map.Entry;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamConstants;
@@ -55,7 +57,19 @@
         interpolateModelProperties( modelProperties, ips );
         return unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri );
 	} 
-	
+
+    public PomClassicDomainModel interpolateDomainModel( PomClassicDomainModel dm, Properties
properties  )
+		throws IOException 
+	{
+    	List<InterpolatorProperty> props = new ArrayList<InterpolatorProperty>();
+    	for(Entry<Object, Object> e : properties
+					.entrySet())
+    	{
+    	//	props.add(new InterpolatorProperty(e.getKey(), e.getValue(), PomInterpolatorTag.EXECUTION_PROPERTIES))
+    	}
+    	return interpolateDomainModel(dm, props);
+    }
+    
     public PomClassicDomainModel interpolateDomainModel( PomClassicDomainModel dm, List<InterpolatorProperty>
interpolatorProperties )
 		throws IOException {
 	

Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/Interpolator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/Interpolator.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/Interpolator.java
(original)
+++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/Interpolator.java
Tue Apr 28 04:12:32 2009
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.util.List;
+import java.util.Properties;
 
 import org.apache.maven.model.PomClassicDomainModel;
 
@@ -13,5 +14,7 @@
 		
 	PomClassicDomainModel interpolateDomainModel( PomClassicDomainModel dm, List<InterpolatorProperty>
interpolatorProperties ) 
 		throws IOException ;
-		
+	
+	PomClassicDomainModel interpolateDomainModel( PomClassicDomainModel dm, Properties interpolatorProperties
) 
+	throws IOException ;		
 }

Modified: maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Tue Apr 28 04:12:32 2009
@@ -168,7 +168,10 @@
         //Interpolation & Management
         MavenProject project;
 		try {
-			Model model = ProcessorContext.processManagementNodes(interpolateDomainModel( domainModel,
configuration, pomFile ));
+			Model model = interpolateDomainModel( domainModel, configuration, pomFile );
+			ProcessorContext.addPluginsToModel(model, configuration.getPlugins());
+			
+			ProcessorContext.processManagementNodes(model);
 			project = this.fromDomainModelToMavenProject(model, domainModel.getParentFile(), configuration,
pomFile);
 		} catch (IOException e) {
 			throw new ProjectBuildingException("", "");
@@ -281,6 +284,7 @@
             throw new ProjectBuildingException("", "");
         }
        
+        
     		try {
     			Model model = ProcessorContext.processManagementNodes(interpolateDomainModel( domainModel,
configuration, artifact.getFile() ));
     			project = this.fromDomainModelToMavenProject(model, domainModel.getParentFile(), configuration,
artifact.getFile());

Modified: maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
(original)
+++ maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
Tue Apr 28 04:12:32 2009
@@ -20,11 +20,14 @@
  */
 
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.ModelEventListener;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.profiles.ProfileManager;
 
 public class DefaultProjectBuilderConfiguration
@@ -47,6 +50,22 @@
     
     private MavenProject topProject;
     
+    private Set<Plugin> plugins;
+    
+    public void setPlugins(Set<Plugin> plugins)
+    {
+    	this.plugins = plugins;
+    }
+    
+    public Set<Plugin> getPlugins()
+    {
+    	if(plugins == null)
+    	{
+    		plugins = new HashSet<Plugin>();
+    	}
+    	return plugins;
+    }
+    
     public MavenProject getTopLevelProjectFromReactor()
     {
     	return topProject;

Modified: maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java?rev=769235&r1=769234&r2=769235&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
(original)
+++ maven/components/branches/MNG-2766/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
Tue Apr 28 04:12:32 2009
@@ -1,11 +1,13 @@
 package org.apache.maven.project;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.profiles.ProfileManager;
 
 import java.util.Date;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 public interface ProjectBuilderConfiguration
 {
@@ -37,4 +39,8 @@
     MavenProject getTopLevelProjectFromReactor();
     
     void setTopLevelProjectForReactor(MavenProject mavenProject);
+    
+    void setPlugins(Set<Plugin> plugins);
+    
+    Set<Plugin> getPlugins();
 }



Mime
View raw message