mirror of https://github.com/apache/maven.git
Default plugins.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@769235 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
93e27192b7
commit
c3715849bf
|
@ -18,10 +18,13 @@ package org.apache.maven.execution;
|
|||
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 @@ public class DefaultMavenExecutionRequest
|
|||
private File globalSettingsFile;
|
||||
|
||||
private File userToolchainsFile;
|
||||
|
||||
private Set<Plugin> plugins;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Request
|
||||
|
@ -115,6 +120,8 @@ public class DefaultMavenExecutionRequest
|
|||
* @issue MNG-2681
|
||||
*/
|
||||
private boolean noSnapshotUpdates;
|
||||
|
||||
public DefaultMavenExecutionRequest() { }
|
||||
|
||||
public static MavenExecutionRequest copy( MavenExecutionRequest original )
|
||||
{
|
||||
|
@ -149,6 +156,7 @@ public class DefaultMavenExecutionRequest
|
|||
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 @@ public class DefaultMavenExecutionRequest
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,11 @@ import java.io.File;
|
|||
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 @@ public interface MavenExecutionRequest
|
|||
MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
|
||||
|
||||
ProjectBuilderConfiguration getProjectBuildingConfiguration();
|
||||
|
||||
void setPlugins(Set<Plugin> plugins);
|
||||
|
||||
Set<Plugin> getPlugins();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.maven.embedder.MavenEmbedderFileLogger;
|
|||
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 @@ public class MavenCli
|
|||
{
|
||||
configuration.setLocalRepository( new File( localRepoProperty ) );
|
||||
}
|
||||
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.maven.execution.DefaultMavenExecutionResult;
|
|||
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 @@ public class MavenEmbedder
|
|||
private Configuration configuration;
|
||||
|
||||
private MavenExecutionRequest request;
|
||||
|
||||
private LifecycleExecutor lifecycleExecutor;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Constructors
|
||||
|
@ -452,6 +455,8 @@ public class MavenEmbedder
|
|||
|
||||
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 @@ public class MavenEmbedder
|
|||
|
||||
int oldThreshold = loggerManager.getThreshold();
|
||||
|
||||
request.setPlugins(lifecycleExecutor.lifecyclePlugins("default", "jar"));
|
||||
|
||||
try
|
||||
{
|
||||
loggerManager.setThresholds( request.getLoggingLevel() );
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.Arrays;
|
|||
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 @@ public class ProcessorContext
|
|||
|
||||
}
|
||||
|
||||
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 )
|
||||
|
|
|
@ -14,7 +14,9 @@ import java.util.LinkedHashSet;
|
|||
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 @@ public class DefaultInterpolator implements Interpolator {
|
|||
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 {
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.apache.maven.model.interpolator;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.model.PomClassicDomainModel;
|
||||
|
||||
|
@ -13,5 +14,7 @@ public interface Interpolator
|
|||
|
||||
PomClassicDomainModel interpolateDomainModel( PomClassicDomainModel dm, List<InterpolatorProperty> interpolatorProperties )
|
||||
throws IOException ;
|
||||
|
||||
|
||||
PomClassicDomainModel interpolateDomainModel( PomClassicDomainModel dm, Properties interpolatorProperties )
|
||||
throws IOException ;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,10 @@ public class DefaultMavenProjectBuilder
|
|||
//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 @@ public class DefaultMavenProjectBuilder
|
|||
throw new ProjectBuildingException("", "");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Model model = ProcessorContext.processManagementNodes(interpolateDomainModel( domainModel, configuration, artifact.getFile() ));
|
||||
project = this.fromDomainModelToMavenProject(model, domainModel.getParentFile(), configuration, artifact.getFile());
|
||||
|
|
|
@ -20,11 +20,14 @@ package org.apache.maven.project;
|
|||
*/
|
||||
|
||||
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 @@ public class DefaultProjectBuilderConfiguration
|
|||
|
||||
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;
|
||||
|
|
|
@ -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 @@ public interface ProjectBuilderConfiguration
|
|||
MavenProject getTopLevelProjectFromReactor();
|
||||
|
||||
void setTopLevelProjectForReactor(MavenProject mavenProject);
|
||||
|
||||
void setPlugins(Set<Plugin> plugins);
|
||||
|
||||
Set<Plugin> getPlugins();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue