o primarily refactoring in part for the preparation making room for mercury and processing events from maven-shared-model

o add plexus component descriptor generation to the bootstrap so we can start removing the hand-written descriptors and start
  using annotations everywhere



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@720432 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2008-11-25 07:11:35 +00:00
parent cca34331f3
commit c418d12814
20 changed files with 428 additions and 228 deletions

View File

@ -38,7 +38,7 @@ TODO:
<property name="it.workdir.version" value="3.0.x"/>
<target name="initTaskDefs">
<xmlproperty file="pom.xml" prefix="pom.xml" />
<xmlproperty file="pom.xml" prefix="pom.xml" />
<path id="maven-ant-tasks.classpath" path="maven-ant-tasks-2.1-SNAPSHOT.jar"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath"/>
</target>
@ -89,20 +89,20 @@ TODO:
<!-- Pull the dependencies for the MetadataGenerator CLI -->
<artifact:dependencies pathId="pmdg.pathid" filesetId="pmdg.fileset" verbose="${verbose}">
<localRepository path="${maven.repo.local}"/>
<dependency groupId="org.codehaus.plexus" artifactId="plexus-component-metadata" version="1.0-beta-2-SNAPSHOT"/>
<dependency groupId="org.codehaus.plexus" artifactId="plexus-component-metadata" version="1.0-beta-2"/>
</artifact:dependencies>
</target>
<target name="generate-resources" depends="pull" description="generates plexus component metadata.">
<target name="process-classes" depends="pull" description="generates plexus component metadata.">
<mkdir dir="${basedir}/bootstrap/target"/>
<mkdir dir="${basedir}/bootstrap/target/classes"/>
<path id="maven.classpath">
<pathelement location="bootstrap/target/classes"/>
<path refid="sources"/>
<path refid="pmdg.pathid"/>
<path refid="pom.pathid"/>
<path refid="pmdg.pathid"/>
</path>
<java fork="fork" classname="org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli" failonerror="true">
@ -166,7 +166,7 @@ TODO:
</path>
<mkdir dir="bootstrap/target/classes"/>
<javac destdir="bootstrap/target/classes" debug="${debug}">
<javac destdir="bootstrap/target/classes" debug="true">
<src refid="sources"/>
<classpath refid="pom.pathid"/>
</javac>
@ -183,7 +183,7 @@ TODO:
</path>
</target>
<target name="maven-compile" depends="compile-boot" description="compiles Maven using the bootstrap Maven, skipping automated tests">
<target name="maven-compile" depends="compile-boot,process-classes" description="compiles Maven using the bootstrap Maven, skipping automated tests">
<java fork="true" classname="org.apache.maven.cli.MavenCli" failonerror="true">
<classpath refid="maven.classpath"/>
<arg value="-e"/>

View File

@ -45,14 +45,6 @@
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>1.0-beta-2-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<version>1.0-beta-2-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

View File

@ -1,32 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>maven</artifactId>
<groupId>org.apache.maven</groupId>
<version>3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-core</artifactId>
<name>Maven Core</name>
@ -71,7 +61,6 @@ under the License.
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interactivity-api</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
@ -100,9 +89,25 @@ under the License.
<version>1.0-alpha-1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-plugin-manager</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-model</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>

View File

@ -155,14 +155,9 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
String event = MavenEvents.MAVEN_EXECUTION;
dispatcher.dispatchStart(
event,
request.getBaseDirectory() );
dispatcher.dispatchStart( event, request.getBaseDirectory() );
MavenSession session = createSession(
request,
reactorManager,
dispatcher );
MavenSession session = createSession( request, reactorManager, dispatcher );
if ( request.getGoals() != null )
{
@ -205,10 +200,7 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
try
{
lifecycleExecutor.execute(
session,
reactorManager,
dispatcher );
lifecycleExecutor.execute( session, reactorManager, dispatcher );
}
catch ( LifecycleExecutionException e )
{
@ -391,11 +383,7 @@ protected MavenSession createSession( MavenExecutionRequest request,
ReactorManager reactorManager,
EventDispatcher dispatcher )
{
MavenSession session = new MavenSession(
container,
request,
dispatcher,
reactorManager );
MavenSession session = new MavenSession( container, request, dispatcher, reactorManager );
return session;
}

View File

@ -1,26 +1,29 @@
package org.apache.maven.execution;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.errors.CoreErrorReporter;
import org.apache.maven.listeners.BuildExtensionListener;
import org.apache.maven.monitor.event.EventMonitor;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.profiles.activation.ProfileActivationContext;
@ -28,13 +31,10 @@
import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.realm.MavenRealmManager;
import org.apache.maven.settings.Settings;
import org.apache.maven.shared.model.ModelEventListener;
import org.apache.maven.wagon.events.TransferListener;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/**
* @author Jason van Zyl
@ -44,9 +44,9 @@ public class DefaultMavenExecutionRequest
implements MavenExecutionRequest
{
private ArtifactRepository localRepository;
private File localRepositoryPath;
private boolean offline = false;
private boolean interactiveMode = true;
@ -115,58 +115,56 @@ public class DefaultMavenExecutionRequest
private ProfileManager profileManager;
private List remoteRepositories;
private List<ArtifactRepository> remoteRepositories;
/**
* Suppress SNAPSHOT updates.
*
* @issue MNG-2681
*/
private boolean noSnapshotUpdates;
private MavenRealmManager realmManager;
public DefaultMavenExecutionRequest()
public static MavenExecutionRequest copy( MavenExecutionRequest original )
{
// default constructor.
DefaultMavenExecutionRequest copy = new DefaultMavenExecutionRequest();
copy.setLocalRepository( original.getLocalRepository() );
copy.setLocalRepositoryPath( original.getLocalRepositoryPath() );
copy.setOffline( original.isOffline() );
copy.setInteractiveMode( original.isInteractiveMode() );
copy.setProxies( original.getProxies() );
copy.setServers( original.getServers() );
copy.setMirrors( original.getMirrors() );
copy.setProfiles( original.getProfiles() );
copy.setPluginGroups( original.getPluginGroups() );
copy.setUsePluginUpdateOverride( original.isUsePluginUpdateOverride() );
copy.setProjectPresent( original.isProjectPresent() );
copy.setUserSettingsFile( original.getUserSettingsFile() );
copy.setGlobalSettingsFile( original.getGlobalSettingsFile() );
copy.setBaseDirectory( new File( original.getBaseDirectory() ) );
copy.setGoals( original.getGoals() );
copy.setUseReactor( original.useReactor() );
copy.setRecursive( original.isRecursive() );
copy.setPom( original.getPom() );
copy.setReactorFailureBehavior( original.getReactorFailureBehavior() );
copy.setProperties( original.getProperties() );
copy.setStartTime( original.getStartTime() );
copy.setShowErrors( original.isShowErrors() );
copy.setEventMonitors( original.getEventMonitors());
copy.setActiveProfiles( original.getActiveProfiles());
copy.setInactiveProfiles( original.getInactiveProfiles());
copy.setTransferListener( original.getTransferListener());
copy.setLoggingLevel( original.getLoggingLevel());
copy.setGlobalChecksumPolicy( original.getGlobalChecksumPolicy());
copy.setUpdateSnapshots( original.isUpdateSnapshots());
copy.setProfileManager( original.getProfileManager() );
copy.setRemoteRepositories( original.getRemoteRepositories() );
copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
copy.setRealmManager( original.getRealmManager() );
return original;
}
public DefaultMavenExecutionRequest( MavenExecutionRequest original )
{
localRepository = original.getLocalRepository();
localRepositoryPath = original.getLocalRepositoryPath();
offline = original.isOffline();
interactiveMode = original.isInteractiveMode();
proxies = original.getProxies();
servers = original.getServers();
mirrors = original.getMirrors();
profiles = original.getProfiles();
pluginGroups = original.getPluginGroups();
usePluginUpdateOverride = original.isUsePluginUpdateOverride();
isProjectPresent = original.isProjectPresent();
userSettingsFile = original.getUserSettingsFile();
globalSettingsFile = original.getGlobalSettingsFile();
basedir = new File( original.getBaseDirectory() );
goals = original.getGoals();
useReactor = original.useReactor();
recursive = original.isRecursive();
pom = original.getPom();
reactorFailureBehavior = original.getReactorFailureBehavior();
properties = original.getProperties();
startTime = original.getStartTime();
showErrors = original.isShowErrors();
eventMonitors = original.getEventMonitors();
activeProfiles = original.getActiveProfiles();
inactiveProfiles = original.getInactiveProfiles();
transferListener = original.getTransferListener();
loggingLevel = original.getLoggingLevel();
globalChecksumPolicy = original.getGlobalChecksumPolicy();
updateSnapshots = original.isUpdateSnapshots();
profileManager = original.getProfileManager();
remoteRepositories = original.getRemoteRepositories();
noSnapshotUpdates = original.isNoSnapshotUpdates();
realmManager = original.getRealmManager();
}
public String getBaseDirectory()
{
if ( basedir == null )
@ -233,6 +231,36 @@ public List getEventMonitors()
return eventMonitors;
}
public void setBasedir( File basedir )
{
this.basedir = basedir;
}
public void setEventMonitors( List eventMonitors )
{
this.eventMonitors = eventMonitors;
}
public void setActiveProfiles( List activeProfiles )
{
this.activeProfiles = activeProfiles;
}
public void setInactiveProfiles( List inactiveProfiles )
{
this.inactiveProfiles = inactiveProfiles;
}
public void setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
{
this.remoteRepositories = remoteRepositories;
}
public void setProjectBuildingConfiguration( ProjectBuilderConfiguration projectBuildingConfiguration )
{
this.projectBuildingConfiguration = projectBuildingConfiguration;
}
public List getActiveProfiles()
{
if ( activeProfiles == null )
@ -656,7 +684,7 @@ public MavenExecutionRequest addRemoteRepository( ArtifactRepository repository
{
if ( remoteRepositories == null )
{
remoteRepositories = new ArrayList();
remoteRepositories = new ArrayList<ArtifactRepository>();
}
remoteRepositories.add( repository );
@ -664,7 +692,7 @@ public MavenExecutionRequest addRemoteRepository( ArtifactRepository repository
return this;
}
public List getRemoteRepositories()
public List<ArtifactRepository> getRemoteRepositories()
{
return remoteRepositories;
}
@ -730,6 +758,7 @@ public ProjectBuilderConfiguration getProjectBuildingConfiguration()
projectBuildingConfiguration.setGlobalProfileManager( getProfileManager() );
projectBuildingConfiguration.setUserProperties( getUserProperties() );
projectBuildingConfiguration.setBuildStartTime( getStartTime() );
projectBuildingConfiguration.setRemoteRepositories( getRemoteRepositories() );
}
return projectBuildingConfiguration;

View File

@ -19,6 +19,11 @@
* under the License.
*/
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.errors.CoreErrorReporter;
@ -31,11 +36,6 @@
import org.apache.maven.wagon.events.TransferListener;
import org.codehaus.plexus.logging.Logger;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Properties;
/**
* @author Jason van Zyl
* @version $Id$

View File

@ -151,10 +151,7 @@ public void execute( final MavenSession session,
throw new NoGoalsSpecifiedException( buffer.toString() );
}
List taskSegments = segmentTaskListByAggregationNeeds(
goals,
session,
rootProject );
List taskSegments = segmentTaskListByAggregationNeeds( goals, session, rootProject );
try
{
@ -162,19 +159,10 @@ public void execute( final MavenSession session,
}
catch ( LifecycleException e )
{
e.printStackTrace();
throw new LifecycleExecutionException(
"Failed to construct one or more initial build plans."
+ " Reason: " + e.getMessage(),
e );
throw new LifecycleExecutionException( "Failed to construct one or more initial build plans." + " Reason: " + e.getMessage(), e );
}
executeTaskSegments(
taskSegments,
reactorManager,
session,
rootProject,
dispatcher );
executeTaskSegments( taskSegments, reactorManager, session, rootProject, dispatcher );
}
/**
@ -210,7 +198,7 @@ private void executeTaskSegments( final List taskSegments,
for ( Iterator projectIterator = sortedProjects.iterator(); projectIterator.hasNext(); )
{
MavenProject currentProject = (MavenProject) projectIterator.next();
executeTaskSegmentForProject( segment, currentProject, reactorManager, dispatcher, session );
}
}
@ -255,11 +243,7 @@ private void executeTaskSegmentForProject( TaskSegment segment,
session.setCurrentProject( project );
// NEW: Build up the execution plan, including configuration.
List mojoBindings = getLifecycleBindings(
segment.getTasks(),
project,
session,
target );
List mojoBindings = getLifecycleBindings( segment.getTasks(), project, session, target );
String currentPhase = null;

View File

@ -0,0 +1,166 @@
package org.apache.maven.listeners;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.builder.ArtifactModelContainerFactory;
import org.apache.maven.project.builder.ProjectUri;
import org.apache.maven.shared.model.ModelContainer;
import org.apache.maven.shared.model.ModelContainerFactory;
import org.apache.maven.shared.model.ModelEventListener;
import org.apache.maven.shared.model.ModelProperty;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Configuration;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.sonatype.plexus.plugin.manager.PlexusPluginManager;
import org.sonatype.plexus.plugin.manager.PluginMetadata;
import org.sonatype.plexus.plugin.manager.PluginResolutionRequest;
import org.sonatype.plexus.plugin.manager.PluginResolutionResult;
// I need access to the local repository
// i need the remote repositories
// i need filters to keep stuff out of the realm that exists
@Component(role = MavenModelEventListener.class, hint="extensions", instantiationStrategy="per-lookup" )
public class BuildExtensionListener
implements MavenModelEventListener
{
@Configuration(value = "true")
private boolean inBuild = true;
@Requirement
PlexusPluginManager pluginManager;
private List<BuildExtension> buildExtensions = new ArrayList<BuildExtension>();
public void fire( List<ModelContainer> modelContainers )
{
if ( !inBuild )
{
return;
}
for ( ModelContainer mc : modelContainers )
{
if ( hasExtension( mc ) )
{
buildExtensions.add( new BuildExtension( mc.getProperties() ) );
}
}
}
public List<String> getUris()
{
return Arrays.asList( ProjectUri.Build.Extensions.Extension.xUri );
}
public Collection<ModelContainerFactory> getModelContainerFactories()
{
return Arrays.asList( (ModelContainerFactory) new ArtifactModelContainerFactory() );
}
private static boolean hasExtension( ModelContainer container )
{
for ( ModelProperty mp : container.getProperties() )
{
if ( mp.getUri().equals( ProjectUri.Build.Extensions.Extension.xUri ) )
{
return true;
}
}
return false;
}
private static class BuildExtension
{
private String groupId;
private String artifactId;
private String version;
public BuildExtension( String groupId, String artifactId, String version )
{
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
}
BuildExtension( List<ModelProperty> modelProperties )
{
for ( ModelProperty mp : modelProperties )
{
if ( mp.getUri().equals( ProjectUri.Build.Extensions.Extension.groupId ) )
{
groupId = mp.getValue();
}
else if ( mp.getUri().equals( ProjectUri.Build.Extensions.Extension.artifactId ) )
{
artifactId = mp.getValue();
}
else if ( mp.getUri().equals( ProjectUri.Build.Extensions.Extension.version ) )
{
version = mp.getValue();
}
}
}
}
// Processing the information that was collected.
public void processModelContainers( MavenSession session )
{
for ( BuildExtension be : buildExtensions )
{
PluginResolutionRequest request = new PluginResolutionRequest()
.setPluginMetadata( new PluginMetadata( be.groupId, be.artifactId, be.version ) )
.addLocalRepository( session.getRequest().getLocalRepositoryPath() )
.setRemoteRepositories( convertToMercuryRepositories( session.getRequest().getRemoteRepositories() ) );
PluginResolutionResult result = null;
try
{
result = pluginManager.resolve( request );
}
catch ( Exception e )
{
e.printStackTrace();
}
ClassRealm realm = pluginManager.createClassRealm( result.getArtifacts() );
realm.display();
List<ComponentDescriptor<?>> components = pluginManager.discoverComponents( realm );
}
}
List<String> convertToMercuryRepositories( List<ArtifactRepository> repositories )
{
List<String> repos = new ArrayList<String>();
if ( repositories != null )
{
for ( ArtifactRepository r : repositories )
{
repos.add( r.getUrl() );
}
}
else
{
// I'm doing this because I am about to rip the artifact clusterfuck out and
// replace it with mercury and I don't want to pull in 5 component to make a
// remote repository. This will do until alpha-2.
repos.add( "http://repo1.maven.org/maven2" );
}
return repos;
}
}

View File

@ -315,7 +315,7 @@ else if ( projectPlugin.getVersion() == null ||
{
getLogger().debug( "Discovering components in realm: " + pluginRealm );
container.discoverComponents( pluginRealm, false );
container.discoverComponents( pluginRealm );
}
catch ( PlexusConfigurationException e )
{

View File

@ -43,6 +43,8 @@
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.realm.RealmManagementException;
import org.apache.maven.realm.RealmScanningUtils;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.LogEnabled;
@ -52,20 +54,26 @@
import java.util.ArrayList;
import java.util.List;
@Component(role = PluginManagerSupport.class)
public class DefaultPluginManagerSupport
implements PluginManagerSupport, LogEnabled, Contextualizable
{
@Requirement
private ArtifactResolver artifactResolver;
@Requirement
private ArtifactFactory artifactFactory;
@Requirement
private MavenProjectBuilder mavenProjectBuilder;
@Requirement
private RuntimeInformation runtimeInformation;
@Requirement
private PluginVersionManager pluginVersionManager;
//@Requirement
private Logger logger;
private Context containerContext;
@ -90,8 +98,6 @@ public Artifact resolvePluginArtifact( Plugin plugin,
List remoteRepositories = new ArrayList();
// remoteRepositories.addAll( project.getPluginArtifactRepositories() );
remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
MavenProject pluginProject = null;

View File

@ -22,7 +22,7 @@ under the License.
<!--
| These are the artifacts handlers that were previously in maven-artifact and they don't belong there as these
| are Maven specific artifact handlers. We need to put these into their respective plugins and make this fully dynamic. jvz.
| are Maven specific artifact handlers. We need to put these into their respective plugins and make this fully dynamic. jvz.
-->
<component>

View File

@ -472,17 +472,11 @@ private MavenSession newMavenSession()
model.setVersion( "1" );
MavenProject project = new MavenProject( model );
ReactorManager rm = new ReactorManager( Collections.singletonList( project ),
ReactorManager.FAIL_FAST );
MockControl reqCtl = MockControl.createControl( MavenExecutionRequest.class );
MavenExecutionRequest req = (MavenExecutionRequest) reqCtl.getMock();
MavenSession session = new MavenSession( getContainer(), req, new DefaultEventDispatcher(),
rm );
ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST );
MockControl mockMavenExecutionRequest = MockControl.createControl( MavenExecutionRequest.class );
MavenExecutionRequest req = (MavenExecutionRequest) mockMavenExecutionRequest.getMock();
MavenSession session = new MavenSession( getContainer(), req, new DefaultEventDispatcher(), rm );
return session;
}
}

View File

@ -132,7 +132,7 @@ else if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) )
{
CLIReportingUtils.showVersion();
}
MavenExecutionRequest request = CLIRequestUtils.buildRequest( commandLine, debug, quiet, showErrors );
Configuration configuration = buildEmbedderConfiguration( request, commandLine, classWorld );

View File

@ -103,7 +103,7 @@
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
/**
* Class intended to be used by clients who wish to embed Maven into their applications
* Class intended to be used by clients who wish to embed Maven into their applications.
*
* @author Jason van Zyl
*/
@ -152,7 +152,7 @@ public class MavenEmbedder
private MavenExecutionRequestPopulator populator;
private BuildPlanner buildPlanner;
// ----------------------------------------------------------------------
// Configuration
// ----------------------------------------------------------------------
@ -506,7 +506,7 @@ public BuildPlan getBuildPlan( List goals,
boolean allowUnbindableMojos )
throws MavenEmbedderException
{
MavenExecutionRequest req = new DefaultMavenExecutionRequest( request );
MavenExecutionRequest req = DefaultMavenExecutionRequest.copy( request );
req.setGoals( goals );
EventDispatcher dispatcher = new DefaultEventDispatcher( req.getEventMonitors() );
@ -709,7 +709,7 @@ private void handleExtensions( List extensions )
try
{
container.discoverComponents( childRealm, true );
container.discoverComponents( childRealm );
}
catch ( PlexusConfigurationException e )
{

View File

@ -122,7 +122,7 @@ public MavenExecutionRequest populateDefaults( MavenExecutionRequest request,
profileManager( request, configuration );
processSettings( request, configuration );
return request;
}

View File

@ -21,28 +21,30 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.shared.model.ModelEventListener;
import org.codehaus.plexus.PlexusContainer;
import java.util.Date;
import java.util.List;
import java.util.Properties;
public class DefaultProjectBuilderConfiguration
implements ProjectBuilderConfiguration
{
private ProfileManager globalProfileManager;
private ArtifactRepository localRepository;
private List<ArtifactRepository> remoteRepositories;
private Properties userProperties;
private Properties executionProperties = System.getProperties();
private Date buildStartTime;
public DefaultProjectBuilderConfiguration()
{
}
private List<ModelEventListener> listeners;
public ProjectBuilderConfiguration setGlobalProfileManager( ProfileManager globalProfileManager )
{
this.globalProfileManager = globalProfileManager;
@ -64,6 +66,17 @@ public ArtifactRepository getLocalRepository()
{
return localRepository;
}
public List<ArtifactRepository> getRemoteRepositories()
{
return remoteRepositories;
}
public ProjectBuilderConfiguration setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
{
this.remoteRepositories = remoteRepositories;
return this;
}
public ProjectBuilderConfiguration setUserProperties( Properties userProperties )
{
@ -103,4 +116,14 @@ public ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime )
return this;
}
public List<ModelEventListener> getModelEventListeners()
{
return listeners;
}
public ProjectBuilderConfiguration setModelEventListeners( List<ModelEventListener> listeners )
{
this.listeners = listeners;
return this;
}
}

View File

@ -2,14 +2,18 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.shared.model.ModelEventListener;
import org.codehaus.plexus.PlexusContainer;
import java.util.Date;
import java.util.List;
import java.util.Properties;
public interface ProjectBuilderConfiguration
{
ArtifactRepository getLocalRepository();
List<ArtifactRepository> getRemoteRepositories();
ProfileManager getGlobalProfileManager();
@ -21,12 +25,13 @@ public interface ProjectBuilderConfiguration
ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository );
ProjectBuilderConfiguration setRemoteRepositories( List<ArtifactRepository> remoteRepositories );
ProjectBuilderConfiguration setUserProperties( Properties userProperties );
ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties );
Date getBuildStartTime();
ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime );
ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime );
}

View File

@ -19,21 +19,6 @@
* under the License.
*/
import org.apache.maven.MavenTools;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.project.builder.*;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
import org.apache.maven.shared.model.*;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@ -43,6 +28,31 @@
import java.util.Collections;
import java.util.List;
import org.apache.maven.MavenTools;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.project.builder.ArtifactModelContainerFactory;
import org.apache.maven.project.builder.IdModelContainerFactory;
import org.apache.maven.project.builder.PomArtifactResolver;
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.ProjectBuilder;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
import org.apache.maven.shared.model.DomainModel;
import org.apache.maven.shared.model.ImportModel;
import org.apache.maven.shared.model.InterpolatorProperty;
import org.apache.maven.shared.model.ModelEventListener;
import org.apache.maven.shared.model.ModelTransformerContext;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
/**
* Default implementation of the project builder.
*/
@ -60,7 +70,9 @@ public final class DefaultProjectBuilder
private ModelValidator validator;
private MavenTools mavenTools;
List<ModelEventListener> listeners;
/**
* Default constructor
*/
@ -160,17 +172,18 @@ public MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedMo
{
domainModels.add( new PomClassicDomainModel( model ) );
}
PomClassicTransformer transformer = new PomClassicTransformer( new PomClassicDomainModelFactory() );
ModelTransformerContext ctx = new ModelTransformerContext(
Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
PomClassicDomainModel transformedDomainModel = ( (PomClassicDomainModel) ctx.transform( domainModels,
transformer,
transformer,
importModels,
properties,
null) );
listeners ) );
try
{
MavenProject mavenProject = new MavenProject( transformedDomainModel.getModel(), artifactFactory,

View File

@ -267,6 +267,6 @@ under the License.
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
</requirements>
</component>
</component>
</components>
</component-set>

53
pom.xml
View File

@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven-parent</artifactId>
<version>10-SNAPSHOT</version>
<version>9</version>
<relativePath>../pom/maven/pom.xml</relativePath>
</parent>
<groupId>org.apache.maven</groupId>
@ -156,7 +156,7 @@ under the License.
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>1.0-beta-2-SNAPSHOT</version>
<version>${plexusVersion}</version>
<executions>
<execution>
<goals>
@ -245,7 +245,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3</version>
<version>2.4.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -254,15 +254,6 @@ under the License.
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<forkMode>once</forkMode>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>maven-core</module>
@ -276,7 +267,7 @@ under the License.
<module>maven-mercury</module>
<module>maven-embedder</module>
<module>maven-toolchain</module>
<module>maven-compat</module>
<module>maven-compat</module>
</modules>
<properties>
<artifactVersion>3.0-alpha-2-SNAPSHOT</artifactVersion>
@ -286,7 +277,7 @@ under the License.
<doxiaVersion>1.0-alpha-9</doxiaVersion>
<easyMockVersion>1.2_Java1.3</easyMockVersion>
<junitVersion>3.8.1</junitVersion>
<plexusVersion>1.0-beta-2-SNAPSHOT</plexusVersion>
<plexusVersion>1.0-beta-2</plexusVersion>
<plexusInteractivityVersion>1.0-alpha-6</plexusInteractivityVersion>
<plexusInterpolationVersion>1.1</plexusInterpolationVersion>
<plexusUtilsVersion>1.5.5</plexusUtilsVersion>
@ -295,7 +286,6 @@ under the License.
<mercuryVersion>1.0.0-alpha-2-SNAPSHOT</mercuryVersion>
<woodstoxVersion>3.2.6</woodstoxVersion>
</properties>
<!--start-->
<dependencies>
<dependency>
@ -367,6 +357,11 @@ under the License.
</dependency>
<!--end-->
<!-- Plexus -->
<dependency>
<groupId>org.apache.maven.artifact</groupId>
<artifactId>maven-artifact</artifactId>
<version>${artifactVersion}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
@ -429,11 +424,6 @@ under the License.
<artifactId>wagon-ssh-external</artifactId>
<version>${wagonVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.artifact</groupId>
<artifactId>maven-artifact</artifactId>
<version>${artifactVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sink-api</artifactId>
@ -469,23 +459,28 @@ under the License.
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-artifact</artifactId>
<version>${mercuryVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-artifact</artifactId>
<version>${mercuryVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-external</artifactId>
<version>${mercuryVersion}</version>
</dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-external</artifactId>
<version>${mercuryVersion}</version>
</dependency>
<!-- Needed for backward compat aspect. -->
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectjVersion}</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-plugin-manager</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<!--start-->
</dependencyManagement>