mirror of https://github.com/apache/maven.git
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:
parent
cca34331f3
commit
c418d12814
10
build.xml
10
build.xml
|
@ -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"/>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
<?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"
|
||||
|
@ -26,7 +17,6 @@ under the License.
|
|||
<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>
|
||||
|
|
|
@ -155,14 +155,9 @@ public class DefaultMaven
|
|||
|
||||
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 class DefaultMaven
|
|||
|
||||
try
|
||||
{
|
||||
lifecycleExecutor.execute(
|
||||
session,
|
||||
reactorManager,
|
||||
dispatcher );
|
||||
lifecycleExecutor.execute( session, reactorManager, dispatcher );
|
||||
}
|
||||
catch ( LifecycleExecutionException e )
|
||||
{
|
||||
|
@ -391,11 +383,7 @@ public class DefaultMaven
|
|||
ReactorManager reactorManager,
|
||||
EventDispatcher dispatcher )
|
||||
{
|
||||
MavenSession session = new MavenSession(
|
||||
container,
|
||||
request,
|
||||
dispatcher,
|
||||
reactorManager );
|
||||
MavenSession session = new MavenSession( container, request, dispatcher, reactorManager );
|
||||
|
||||
return session;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* 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.
|
||||
* 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.DefaultProjectBuilderConfiguration;
|
|||
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
|
||||
|
@ -115,56 +115,54 @@ 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.
|
||||
}
|
||||
|
||||
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();
|
||||
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 String getBaseDirectory()
|
||||
|
@ -233,6 +231,36 @@ public class DefaultMavenExecutionRequest
|
|||
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 class DefaultMavenExecutionRequest
|
|||
{
|
||||
if ( remoteRepositories == null )
|
||||
{
|
||||
remoteRepositories = new ArrayList();
|
||||
remoteRepositories = new ArrayList<ArtifactRepository>();
|
||||
}
|
||||
|
||||
remoteRepositories.add( repository );
|
||||
|
@ -664,7 +692,7 @@ public class DefaultMavenExecutionRequest
|
|||
return this;
|
||||
}
|
||||
|
||||
public List getRemoteRepositories()
|
||||
public List<ArtifactRepository> getRemoteRepositories()
|
||||
{
|
||||
return remoteRepositories;
|
||||
}
|
||||
|
@ -730,6 +758,7 @@ public class DefaultMavenExecutionRequest
|
|||
projectBuildingConfiguration.setGlobalProfileManager( getProfileManager() );
|
||||
projectBuildingConfiguration.setUserProperties( getUserProperties() );
|
||||
projectBuildingConfiguration.setBuildStartTime( getStartTime() );
|
||||
projectBuildingConfiguration.setRemoteRepositories( getRemoteRepositories() );
|
||||
}
|
||||
|
||||
return projectBuildingConfiguration;
|
||||
|
|
|
@ -19,6 +19,11 @@ package org.apache.maven.execution;
|
|||
* 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.settings.Settings;
|
|||
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$
|
||||
|
|
|
@ -151,10 +151,7 @@ public class DefaultLifecycleExecutor
|
|||
throw new NoGoalsSpecifiedException( buffer.toString() );
|
||||
}
|
||||
|
||||
List taskSegments = segmentTaskListByAggregationNeeds(
|
||||
goals,
|
||||
session,
|
||||
rootProject );
|
||||
List taskSegments = segmentTaskListByAggregationNeeds( goals, session, rootProject );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -162,19 +159,10 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -255,11 +243,7 @@ public class DefaultLifecycleExecutor
|
|||
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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -315,7 +315,7 @@ public class DefaultPluginManager
|
|||
{
|
||||
getLogger().debug( "Discovering components in realm: " + pluginRealm );
|
||||
|
||||
container.discoverComponents( pluginRealm, false );
|
||||
container.discoverComponents( pluginRealm );
|
||||
}
|
||||
catch ( PlexusConfigurationException e )
|
||||
{
|
||||
|
|
|
@ -43,6 +43,8 @@ import org.apache.maven.project.ProjectBuildingException;
|
|||
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 org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
|||
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 class DefaultPluginManagerSupport
|
|||
|
||||
List remoteRepositories = new ArrayList();
|
||||
|
||||
// remoteRepositories.addAll( project.getPluginArtifactRepositories() );
|
||||
|
||||
remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
|
||||
|
||||
MavenProject pluginProject = null;
|
||||
|
|
|
@ -472,17 +472,11 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ import org.codehaus.plexus.util.dag.CycleDetectedException;
|
|||
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
|
||||
*/
|
||||
|
@ -506,7 +506,7 @@ public class MavenEmbedder
|
|||
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 @@ public class MavenEmbedder
|
|||
|
||||
try
|
||||
{
|
||||
container.discoverComponents( childRealm, true );
|
||||
container.discoverComponents( childRealm );
|
||||
}
|
||||
catch ( PlexusConfigurationException e )
|
||||
{
|
||||
|
|
|
@ -21,27 +21,29 @@ package org.apache.maven.project;
|
|||
|
||||
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 )
|
||||
{
|
||||
|
@ -65,6 +67,17 @@ public class DefaultProjectBuilderConfiguration
|
|||
return localRepository;
|
||||
}
|
||||
|
||||
public List<ArtifactRepository> getRemoteRepositories()
|
||||
{
|
||||
return remoteRepositories;
|
||||
}
|
||||
|
||||
public ProjectBuilderConfiguration setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
|
||||
{
|
||||
this.remoteRepositories = remoteRepositories;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilderConfiguration setUserProperties( Properties userProperties )
|
||||
{
|
||||
this.userProperties = userProperties;
|
||||
|
@ -103,4 +116,14 @@ public class DefaultProjectBuilderConfiguration
|
|||
return this;
|
||||
}
|
||||
|
||||
public List<ModelEventListener> getModelEventListeners()
|
||||
{
|
||||
return listeners;
|
||||
}
|
||||
|
||||
public ProjectBuilderConfiguration setModelEventListeners( List<ModelEventListener> listeners )
|
||||
{
|
||||
this.listeners = listeners;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,19 @@ package org.apache.maven.project;
|
|||
|
||||
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();
|
||||
|
||||
Properties getUserProperties();
|
||||
|
@ -21,6 +25,8 @@ public interface ProjectBuilderConfiguration
|
|||
|
||||
ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository );
|
||||
|
||||
ProjectBuilderConfiguration setRemoteRepositories( List<ArtifactRepository> remoteRepositories );
|
||||
|
||||
ProjectBuilderConfiguration setUserProperties( Properties userProperties );
|
||||
|
||||
ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties );
|
||||
|
@ -28,5 +34,4 @@ public interface ProjectBuilderConfiguration
|
|||
Date getBuildStartTime();
|
||||
|
||||
ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime );
|
||||
|
||||
}
|
||||
|
|
|
@ -19,21 +19,6 @@ package org.apache.maven.project.builder.impl;
|
|||
* 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.Collection;
|
|||
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.
|
||||
*/
|
||||
|
@ -61,6 +71,8 @@ public final class DefaultProjectBuilder
|
|||
|
||||
private MavenTools mavenTools;
|
||||
|
||||
List<ModelEventListener> listeners;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
|
@ -162,6 +174,7 @@ public final class DefaultProjectBuilder
|
|||
}
|
||||
|
||||
PomClassicTransformer transformer = new PomClassicTransformer( new PomClassicDomainModelFactory() );
|
||||
|
||||
ModelTransformerContext ctx = new ModelTransformerContext(
|
||||
Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
||||
|
||||
|
@ -170,7 +183,7 @@ public final class DefaultProjectBuilder
|
|||
transformer,
|
||||
importModels,
|
||||
properties,
|
||||
null) );
|
||||
listeners ) );
|
||||
try
|
||||
{
|
||||
MavenProject mavenProject = new MavenProject( transformedDomainModel.getModel(), artifactFactory,
|
||||
|
|
33
pom.xml
33
pom.xml
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -486,6 +476,11 @@ under the License.
|
|||
<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>
|
||||
|
|
Loading…
Reference in New Issue