From b97533f8459c5b7e80469157c9bc41ddbf0b7654 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Mon, 29 Oct 2007 19:42:33 +0000 Subject: [PATCH] Fix Maven/DefaultMaven method signatures, push projectSessions map into request. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@589822 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/maven/DefaultMaven.java | 16 ++++++------ .../src/main/java/org/apache/maven/Maven.java | 6 ++--- .../DefaultMavenExecutionRequest.java | 25 +++++++++++++++++++ .../execution/MavenExecutionRequest.java | 6 ++++- .../apache/maven/embedder/MavenEmbedder.java | 4 +-- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 572e27ac0f..31738a482c 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -102,13 +102,12 @@ public class DefaultMaven // lifecycle execution public ReactorManager createReactorManager( MavenExecutionRequest request, - MavenExecutionResult result, - Map projectSessions ) + MavenExecutionResult result ) { List projects; try { - projects = getProjects( request, projectSessions ); + projects = getProjects( request ); if ( projects.isEmpty() ) { @@ -159,7 +158,7 @@ public class DefaultMaven return reactorManager; } - public MavenExecutionResult execute( MavenExecutionRequest request, Map projectSessions ) + public MavenExecutionResult execute( MavenExecutionRequest request ) { request.setStartTime( new Date() ); @@ -167,8 +166,7 @@ public class DefaultMaven ReactorManager reactorManager = createReactorManager( request, - result, - projectSessions ); + result ); if ( result.hasExceptions() ) { @@ -187,7 +185,7 @@ public class DefaultMaven request, reactorManager, dispatcher, - projectSessions ); + request.getProjectSessions() ); for ( Iterator i = request.getGoals().iterator(); i.hasNext(); ) { @@ -262,7 +260,7 @@ public class DefaultMaven systemContext.store( buildContextManager ); } - private List getProjects( MavenExecutionRequest request, Map projectSessions ) + private List getProjects( MavenExecutionRequest request ) throws MavenExecutionException { List projects; @@ -283,7 +281,7 @@ public class DefaultMaven // instances just-in-time. try { - buildExtensionScanner.scanForBuildExtensions( files, request.getLocalRepository(), request.getProfileManager(), projectSessions ); + buildExtensionScanner.scanForBuildExtensions( files, request.getLocalRepository(), request.getProfileManager(), request.getProjectSessions() ); } catch ( ExtensionScanningException e ) { diff --git a/maven-core/src/main/java/org/apache/maven/Maven.java b/maven-core/src/main/java/org/apache/maven/Maven.java index 51e693a8da..e3db808757 100644 --- a/maven-core/src/main/java/org/apache/maven/Maven.java +++ b/maven-core/src/main/java/org/apache/maven/Maven.java @@ -23,8 +23,6 @@ import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.execution.ReactorManager; -import java.util.Map; - /** * @author Jason van Zyl * @version $Id$ @@ -53,7 +51,7 @@ public interface Maven static final int LOGGING_LEVEL_DISABLE = 5; - MavenExecutionResult execute( MavenExecutionRequest request, Map projectSessions ); + MavenExecutionResult execute( MavenExecutionRequest request ); - ReactorManager createReactorManager( MavenExecutionRequest request, MavenExecutionResult result, Map projectSessions ); + ReactorManager createReactorManager( MavenExecutionRequest request, MavenExecutionResult result ); } \ No newline at end of file diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java index 6caa25218c..2f67d9fe4e 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java @@ -28,7 +28,9 @@ import org.apache.maven.wagon.events.TransferListener; import java.io.File; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Properties; /** @@ -60,6 +62,13 @@ public class DefaultMavenExecutionRequest private boolean isProjectPresent = true; + /** + * These are {@link MavenProjectSession} instances, keyed by + * groupId:artifactId:version of the project, and used to lookup and store + * extension and plugin realms specific to that project. + */ + private Map projectSessions; + // ---------------------------------------------------------------------------- // We need to allow per execution user and global settings as the embedder // might be running in a mode where its executing many threads with totally @@ -603,4 +612,20 @@ public class DefaultMavenExecutionRequest { return remoteRepositories; } + + public Map getProjectSessions() + { + if ( projectSessions == null ) + { + projectSessions = new HashMap(); + } + + return projectSessions; + } + + public MavenExecutionRequest setProjectSessions( Map projectSessions ) + { + this.projectSessions = projectSessions; + return this; + } } diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java index 5d3e7fc3db..fbe6625fb5 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java @@ -30,6 +30,7 @@ import org.codehaus.plexus.logging.Logger; import java.io.File; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.Properties; /** @@ -194,7 +195,7 @@ public interface MavenExecutionRequest boolean isProjectPresent(); MavenExecutionRequest setProjectPresent( boolean isProjectPresent ); - File getUserSettingsFile(); + File getUserSettingsFile(); MavenExecutionRequest setUserSettingsFile( File userSettingsFile ); File getGlobalSettingsFile(); @@ -202,4 +203,7 @@ public interface MavenExecutionRequest MavenExecutionRequest addRemoteRepository( ArtifactRepository repository ); List getRemoteRepositories(); + + MavenExecutionRequest setProjectSessions( Map projectSessions ); + Map getProjectSessions(); } diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java index 78871ea9af..75ef949c5c 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java @@ -490,7 +490,7 @@ public class MavenEmbedder return result.addExtensionScanningException( e ); } - ReactorManager reactorManager = maven.createReactorManager( request, result, projectSessions ); + ReactorManager reactorManager = maven.createReactorManager( request, result ); if ( result.hasExceptions() ) { @@ -901,7 +901,7 @@ public class MavenEmbedder return result; } - return maven.execute( request, projectSessions ); + return maven.execute( request ); } finally {