You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/11/15 06:38:03 UTC
svn commit: r595215 [1/4] - in /maven/components/trunk: ./
maven-build-context/ maven-core/
maven-core/src/main/aspect/org/apache/maven/compat/plugin/
maven-core/src/main/aspect/org/apache/maven/errors/
maven-core/src/main/java/org/apache/maven/ maven-...
Author: jdcasey
Date: Wed Nov 14 21:37:55 2007
New Revision: 595215
URL: http://svn.apache.org/viewvc?rev=595215&view=rev
Log:
Removing maven-build-context, and replacing it with caching aspects for model-lineage stuff and project instances. Still needs caching for artifact resolution, and I have an aspect for this too, but it's not enabled yet, since it's still buggy.
Added:
maven/components/trunk/maven-core/src/main/aspect/org/apache/maven/errors/
maven/components/trunk/maven-core/src/main/java/org/apache/maven/errors/
maven/components/trunk/maven-embedder/src/main/aspect/
maven/components/trunk/maven-embedder/src/main/aspect/org/
maven/components/trunk/maven-embedder/src/main/aspect/org/apache/
maven/components/trunk/maven-embedder/src/main/aspect/org/apache/maven/
maven/components/trunk/maven-embedder/src/main/aspect/org/apache/maven/embedder/
maven/components/trunk/maven-embedder/src/main/aspect/org/apache/maven/embedder/cache/
maven/components/trunk/maven-embedder/src/main/aspect/org/apache/maven/embedder/cache/CacheCleanerAspect.aj
maven/components/trunk/maven-project/src/main/aspect/
maven/components/trunk/maven-project/src/main/aspect/org/
maven/components/trunk/maven-project/src/main/aspect/org/apache/
maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/
maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/
maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/
maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProjectCacheAspect.aj
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/DefaultProfileActivationContext.java (with props)
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationContext.java (with props)
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelAndFile.java (with props)
Removed:
maven/components/trunk/maven-build-context/
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/SessionContext.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutionContext.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java
Modified:
maven/components/trunk/build.properties
maven/components/trunk/maven-core/pom.xml
maven/components/trunk/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenRealmManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/loader/DefaultPluginLoader.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/loader/PluginLoader.java
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin.xml
maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManagerTest.java
maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java
maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultBuildPlannerTest.java
maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/plan/testutils/TestPluginLoader.java
maven/components/trunk/maven-embedder/pom.xml
maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/cli/CLIRequestUtils.java
maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
maven/components/trunk/maven-project/pom.xml
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/ProfileManager.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/AlwaysOnProfileActivator.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivator.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/ProfileAdvisor.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/PomMetadataSource.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java
maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivatorTest.java
maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java
maven/components/trunk/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
maven/components/trunk/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml
maven/components/trunk/pom.xml
Modified: maven/components/trunk/build.properties
URL: http://svn.apache.org/viewvc/maven/components/trunk/build.properties?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/build.properties (original)
+++ maven/components/trunk/build.properties Wed Nov 14 21:37:55 2007
@@ -17,7 +17,7 @@
aspectj.version=1.5.3
classworlds.version=1.2-alpha-10
-plexus.version=1.0-alpha-39
+plexus.version=1.0-alpha-40
plexus-utils.version=1.4.5
maven-artifact.version=3.0-SNAPSHOT
commons-cli.version=1.0
Modified: maven/components/trunk/maven-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/pom.xml?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/pom.xml (original)
+++ maven/components/trunk/maven-core/pom.xml Wed Nov 14 21:37:55 2007
@@ -37,11 +37,6 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-build-context</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
Modified: maven/components/trunk/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj (original)
+++ maven/components/trunk/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj Wed Nov 14 21:37:55 2007
@@ -37,10 +37,6 @@
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.LogEnabled;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
import java.io.IOException;
import java.util.Iterator;
@@ -50,12 +46,38 @@
public privileged aspect Maven20xCompatAspect
{
- // pointcut to avoid recursive matching on behavior injected by this aspect.
- private pointcut notHere(): !within( Maven20xCompatAspect );
-
// GRAB Session as soon as it's constructed.
private MavenSession session;
+ // GRAB the request when it's passed into a method that returns a corresponding result.
+ // NOTE: We'll use this in multiple places below...
+ private MavenExecutionRequest request;
+
+ // Grab this so we have a voice!
+ private Logger logger;
+
+ // used for injecting plexus-utils into extension and plugin artifact sets.
+ private VersionRange vr = null;
+ private Artifact plexusUtilsArtifact = null;
+
+
+ private pointcut mavenEmbedderStop():
+ execution( * org.apache.maven.embedder.MavenEmbedder.stop( .. ) );
+
+ // TODO: There must be a more elegant way to release these resources than depending on MavenEmbedder.stop().
+ after(): mavenEmbedderStop()
+ {
+ session = null;
+ request = null;
+ logger = null;
+ vr = null;
+ plexusUtilsArtifact = null;
+ }
+
+
+ // pointcut to avoid recursive matching on behavior injected by this aspect.
+ private pointcut notHere(): !within( Maven20xCompatAspect );
+
private pointcut sessionCreation( MavenSession session ):
execution( public MavenSession+.new(..) )
&& this( session )
@@ -114,7 +136,7 @@
PluginDescriptor around( String prefix, PluginManager manager ): getPluginDescriptorForPrefix( prefix, manager )
{
// TODO: Implement Me!
- return null;
+ throw new UnsupportedOperationException( "This method has not yet been implemented in Maven's backward-compatibility library." );
}
public PluginDescriptor PluginManager.getPluginDescriptorForPrefix( String prefix )
@@ -122,11 +144,6 @@
return null;
}
- public PluginDescriptor DefaultPluginManager.getPluginDescriptorForPrefix( String prefix )
- {
- return null;
- }
-
// Intercept retrieval of artifact dependencies of an extension, inject plexus-utils if it's not there.
private pointcut extDepArtifactsResolved( DefaultExtensionManager mgr ):
call( public Set ResolutionGroup+.getArtifacts() )
@@ -161,19 +178,25 @@
return result;
}
- // GRAB the request when it's passed into a method that returns a corresponding result.
- // NOTE: We'll use this in multiple places below...
- private MavenExecutionRequest request;
-
private pointcut methodsTakingRequest( MavenExecutionRequest request ):
execution( MavenExecutionResult *.*( MavenExecutionRequest ) )
+ && !withincode( * *.*( MavenExecutionRequest ) )
&& args( request )
&& notHere();
// capture the request instance before it's passed into any method that returns a corresponding MavenExecutionResult.
- before( MavenExecutionRequest request ): methodsTakingRequest( request )
+ Object around( MavenExecutionRequest request ): methodsTakingRequest( request )
{
this.request = request;
+
+ try
+ {
+ return proceed( request );
+ }
+ finally
+ {
+ this.request = null;
+ }
}
// USE Request to compensate for old buildSettings() API.
@@ -203,33 +226,23 @@
return null;
}
- // container used in the plugin manager.
- private PlexusContainer container;
-
- private pointcut pluginManagerContextualized( Context context ):
- execution( void DefaultPluginManager+.contextualize( Context ) )
- && args( context );
-
- // capture the container when the DefaultPluginManager is contextualized.
- void around( Context context ) throws ContextException: pluginManagerContextualized( context )
- {
- proceed( context );
- container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
- }
+ private pointcut pluginManager( DefaultPluginManager manager ):
+ execution( * DefaultPluginManager.*( .. ) )
+ && this( manager );
- private pointcut pluginRealmCreation( Plugin plugin ):
+ private pointcut pluginRealmCreation( Plugin plugin, DefaultPluginManager manager ):
call( ClassRealm MavenRealmManager+.createPluginRealm( Plugin, Artifact, Collection ) )
- && withincode( void DefaultPluginManager.addPlugin(..) )
+ && cflow( pluginManager( manager ) )
&& args( plugin, .. );
// Add various imports for Xpp3 stuff back into the core realm every time a plugin realm is created.
- ClassRealm around( Plugin plugin ): pluginRealmCreation( plugin )
+ ClassRealm around( Plugin plugin, DefaultPluginManager manager ): pluginRealmCreation( plugin, manager )
{
- ClassRealm pluginRealm = proceed( plugin );
+ ClassRealm pluginRealm = proceed( plugin, manager );
try
{
- String parentRealmId = container.getContainerRealm().getId();
+ String parentRealmId = manager.container.getContainerRealm().getId();
// adding for MNG-3012 to try to work around problems with Xpp3Dom (from plexus-utils)
// spawning a ClassCastException when a mojo calls plugin.getConfiguration() from maven-model...
@@ -252,9 +265,6 @@
return pluginRealm;
}
- // Grab this so we have a voice!
- private Logger logger;
-
private pointcut enableLoggingCall( Logger logger ):
execution( void LogEnabled+.enableLogging( Logger ) )
&& args( logger );
@@ -288,9 +298,6 @@
// --------------------------
// UTILITIES
// --------------------------
-
- private VersionRange vr = null;
- private Artifact plexusUtilsArtifact = null;
private void checkPlexusUtils( Set dependencyArtifacts, ArtifactFactory artifactFactory )
{
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Wed Nov 14 21:37:55 2007
@@ -23,16 +23,12 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.context.BuildContextManager;
-import org.apache.maven.context.SystemBuildContext;
import org.apache.maven.execution.DefaultMavenExecutionResult;
-import org.apache.maven.execution.ExecutionBuildContext;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager;
import org.apache.maven.execution.RuntimeInformation;
-import org.apache.maven.execution.SessionContext;
import org.apache.maven.extension.BuildExtensionScanner;
import org.apache.maven.extension.ExtensionScanningException;
import org.apache.maven.lifecycle.LifecycleExecutionException;
@@ -80,8 +76,6 @@
// Components
// ----------------------------------------------------------------------
- protected BuildContextManager buildContextManager;
-
protected MavenProjectBuilder projectBuilder;
protected LifecycleExecutor lifecycleExecutor;
@@ -213,8 +207,6 @@
}
}
- initializeBuildContext( request );
-
try
{
lifecycleExecutor.execute(
@@ -240,24 +232,6 @@
return result;
}
- /**
- * Initialize some context objects to be stored in the container's context map for reference by
- * other Maven components (including custom components that need more information about the
- * build than is supplied to them by the APIs).
- */
- private void initializeBuildContext( MavenExecutionRequest request )
- {
- new ExecutionBuildContext( request ).store( buildContextManager );
-
- SystemBuildContext systemContext = SystemBuildContext.getSystemBuildContext(
- buildContextManager,
- true );
-
- systemContext.setSystemProperties( request.getProperties() );
-
- systemContext.store( buildContextManager );
- }
-
private List getProjects( MavenExecutionRequest request )
throws MavenExecutionException
{
@@ -427,9 +401,6 @@
request,
dispatcher,
reactorManager );
-
- SessionContext ctx = new SessionContext( session );
- ctx.store( buildContextManager );
return session;
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java Wed Nov 14 21:37:55 2007
@@ -616,4 +616,11 @@
{
return realmManager;
}
+
+ public MavenExecutionRequest clearAccumulatedBuildState()
+ {
+ realmManager.clear();
+
+ return this;
+ }
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java Wed Nov 14 21:37:55 2007
@@ -3,6 +3,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Plugin;
import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
@@ -59,17 +60,25 @@
{
try
{
+ logger.debug( "disposing managed ClassRealm with id: " + id );
world.disposeRealm( id );
+
+ logger.debug( "dissociating all components from managed ClassRealm with id: " + id );
+ container.removeComponentRealm( realm );
}
catch ( NoSuchRealmException e )
{
// cannot happen.
}
+ catch ( PlexusContainerException e )
+ {
+ logger.debug( "Error while dissociating: " + e.getMessage(), e );
+ }
}
}
managedRealmIds.clear();
-// pluginArtifacts.clear();
+ pluginArtifacts.clear();
}
public boolean hasExtensionRealm( Artifact extensionArtifact )
@@ -320,7 +329,7 @@
try
{
realm = world.newRealm( id );
-// managedRealmIds.add( id );
+ managedRealmIds.add( id );
}
catch ( DuplicateRealmException e )
{
@@ -329,6 +338,8 @@
}
populateRealm( id, realm, pluginArtifact, artifacts );
+
+ logger.debug( "Saving artifacts:\n\n" + artifacts + "\n\nfor plugin: " + id );
pluginArtifacts.put( id, artifacts );
return realm;
@@ -382,9 +393,21 @@
if ( artifacts != null )
{
+ logger.debug( "Returning artifacts:\n\n" + artifacts + "\n\nfor plugin: " + id );
return new ArrayList( artifacts );
}
+ logger.debug( "Found no artifacts for plugin: " + id );
return null;
+ }
+
+ public void setPluginArtifacts( Plugin plugin,
+ Collection artifacts )
+ {
+ String id = RealmUtils.createPluginRealmId( plugin );
+
+ logger.debug( "Setting artifact collection for plugin with id: " + id + " to:\n\n" + artifacts );
+
+ pluginArtifacts.put( id, artifacts );
}
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java Wed Nov 14 21:37:55 2007
@@ -205,4 +205,6 @@
MavenExecutionRequest setRealmManager( MavenRealmManager realmManager );
MavenRealmManager getRealmManager();
+
+ MavenExecutionRequest clearAccumulatedBuildState();
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenRealmManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenRealmManager.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenRealmManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenRealmManager.java Wed Nov 14 21:37:55 2007
@@ -36,4 +36,7 @@
Artifact pluginArtifact,
Collection artifacts )
throws RealmManagementException;
+
+ void setPluginArtifacts( Plugin plugin,
+ Collection artifacts );
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java Wed Nov 14 21:37:55 2007
@@ -21,17 +21,21 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.monitor.event.EventDispatcher;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.MavenReport;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Stack;
/**
* @author Jason van Zyl
@@ -49,6 +53,9 @@
private MavenExecutionRequest request;
+ private MavenProject currentProject;
+ private Stack forkedProjectStack = new Stack();
+
private Map reports = new LinkedHashMap();
public MavenSession( PlexusContainer container,
@@ -158,6 +165,72 @@
public MavenExecutionRequest getRequest()
{
return request;
+ }
+
+ /**
+ * Push the existing currentProject onto the forked-project stack, and set the specified project
+ * as the new current project. This signifies the beginning of a new forked-execution context.
+ */
+ public void addForkedProject( MavenProject project )
+ {
+ forkedProjectStack.push( currentProject );
+ currentProject = project;
+ }
+
+ /**
+ * Peel off the last forked project from the stack, and restore it as the currentProject. This
+ * signifies the cleanup of a completed forked-execution context.
+ */
+ public MavenProject removeForkedProject()
+ {
+ if ( !forkedProjectStack.isEmpty() )
+ {
+ MavenProject lastCurrent = currentProject;
+ currentProject = (MavenProject) forkedProjectStack.pop();
+
+ return lastCurrent;
+ }
+
+ return null;
+ }
+
+ public void setCurrentProject( MavenProject currentProject )
+ {
+ this.currentProject = currentProject;
+ }
+
+ /**
+ * Return the current project for use in a mojo execution.
+ */
+ public MavenProject getCurrentProject()
+ {
+ return currentProject;
+ }
+
+ /**
+ * Retrieve the list of reports ({@link MavenReport} instances) that have been executed against
+ * this project, for use in another mojo's execution.
+ */
+ public List getReports()
+ {
+ return new ArrayList( reports.values() );
+ }
+
+ /**
+ * Clear the reports for this project
+ */
+ public void clearReports()
+ {
+ reports.clear();
+ }
+
+ /**
+ * Add a newly-executed report ({@link MavenReport} instance) to the reports collection, for
+ * future reference.
+ */
+ public void addReport( MojoDescriptor mojoDescriptor, MavenReport report )
+ {
+ reports.put( mojoDescriptor.getId(), report );
}
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java Wed Nov 14 21:37:55 2007
@@ -20,14 +20,15 @@
*/
import org.apache.maven.artifact.ArtifactUtils;
-import org.apache.maven.context.BuildContextManager;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.model.Build;
import org.apache.maven.model.Extension;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.plugin.loader.PluginLoader;
-import org.apache.maven.profiles.activation.CustomActivatorAdvice;
+import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
+import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
@@ -56,8 +57,6 @@
private Logger logger;
- private BuildContextManager buildContextManager;
-
private ExtensionManager extensionManager;
private MavenProjectBuilder projectBuilder;
@@ -98,12 +97,6 @@
throws ExtensionScanningException
{
- // setup the CustomActivatorAdvice to fail quietly while we discover extensions...then, we'll
- // reset it.
- CustomActivatorAdvice activatorAdvice = CustomActivatorAdvice.getCustomActivatorAdvice( buildContextManager );
- activatorAdvice.setFailQuietly( true );
- activatorAdvice.store( buildContextManager );
-
try
{
List originalRemoteRepositories = getInitialRemoteRepositories();
@@ -184,11 +177,6 @@
throw new ExtensionScanningException( "Failed to interpolate model from: " + pom
+ " prior to scanning for extensions.", pom, e );
}
- finally
- {
- activatorAdvice.reset();
- activatorAdvice.store( buildContextManager );
- }
}
private String createKey( Model model )
@@ -322,6 +310,14 @@
List originalRemoteRepositories )
throws ExtensionScanningException
{
+ ProfileManager profileManager = request.getProfileManager();
+
+ ProfileActivationContext profileActivationContext = profileManager == null
+ ? new DefaultProfileActivationContext( System.getProperties(), false )
+ : profileManager.getProfileActivationContext();
+
+ boolean suppressActivatorFailure = profileActivationContext.isCustomActivatorFailureSuppressed();
+
ModelLineage lineage;
try
{
@@ -331,6 +327,7 @@
// not for POMs from the repository...otherwise, we would need to be more careful with
// the last parameter here and determine whether it's appropriate for the POM to have
// an accompanying profiles.xml file.
+ profileActivationContext.setCustomActivatorFailureSuppressed( true );
lineage = modelLineageBuilder.buildModelLineage( pom, request.getLocalRepository(), originalRemoteRepositories,
request.getProfileManager(), false, true );
}
@@ -338,6 +335,10 @@
{
throw new ExtensionScanningException( "Error building model lineage in order to pre-scan for extensions: "
+ e.getMessage(), pom, e );
+ }
+ finally
+ {
+ profileActivationContext.setCustomActivatorFailureSuppressed( suppressActivatorFailure );
}
return lineage;
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Wed Nov 14 21:37:55 2007
@@ -25,7 +25,6 @@
import org.apache.maven.ProjectBuildFailureException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.context.BuildContextManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager;
import org.apache.maven.lifecycle.binding.MojoBindingFactory;
@@ -84,8 +83,6 @@
private MojoBindingFactory mojoBindingFactory;
- private BuildContextManager buildContextManager;
-
// this is needed for setting the lookup realm before we start building a project.
private PlexusContainer container;
@@ -196,16 +193,13 @@
try
{
- // NEW: To support forked execution under the new lifecycle architecture, the current project
- // is stored in a build-context managed data type. This context type holds the current project
- // for the fork being executed, plus a stack of projects used in the ancestor execution contexts.
- LifecycleExecutionContext ctx = new LifecycleExecutionContext( rootProject );
- ctx.store( buildContextManager );
+ session.setCurrentProject( rootProject );
// NEW: Build up the execution plan, including configuration.
List mojoBindings = getLifecycleBindings(
segment.getTasks(),
rootProject,
+ session,
target );
// NEW: Then, iterate over each binding in that plan, and execute the associated mojo.
@@ -243,9 +237,7 @@
}
finally
{
- // clean up the execution context, so we don't pollute for future project-executions.
- LifecycleExecutionContext.delete( buildContextManager );
-
+ session.setCurrentProject( null );
restoreLookupRealm( oldLookupRealm );
}
@@ -306,12 +298,12 @@
try
{
- LifecycleExecutionContext ctx = new LifecycleExecutionContext( currentProject );
- ctx.store( buildContextManager );
+ session.setCurrentProject( currentProject );
List mojoBindings = getLifecycleBindings(
segment.getTasks(),
currentProject,
+ session,
target );
for ( Iterator mojoIterator = mojoBindings.iterator(); mojoIterator.hasNext(); )
@@ -346,8 +338,7 @@
}
finally
{
- LifecycleExecutionContext.delete( buildContextManager );
-
+ session.setCurrentProject( null );
restoreLookupRealm( oldLookupRealm );
}
@@ -421,6 +412,7 @@
*/
private List getLifecycleBindings( final List tasks,
final MavenProject project,
+ final MavenSession session,
final String targetDescription )
throws LifecycleExecutionException
{
@@ -429,7 +421,8 @@
{
BuildPlan plan = buildPlanner.constructBuildPlan(
tasks,
- project );
+ project,
+ session );
if ( getLogger().isDebugEnabled() )
{
@@ -461,9 +454,7 @@
final String target )
throws LifecycleExecutionException, MojoFailureException
{
- // NEW: Retrieve/use the current project stored in the execution context, for consistency.
- LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
- MavenProject project = ctx.getCurrentProject();
+ MavenProject project = session.getCurrentProject();
// NEW: Since the MojoBinding instances are configured when the build plan is constructed,
// all that remains to be done here is to load the PluginDescriptor, construct a MojoExecution
@@ -476,7 +467,8 @@
{
pluginDescriptor = pluginLoader.loadPlugin(
mojoBinding,
- project );
+ project,
+ session );
}
catch ( PluginLoaderException e )
{
@@ -757,11 +749,13 @@
MojoBinding binding = mojoBindingFactory.parseMojoBinding(
task,
project,
+ session,
true );
PluginDescriptor descriptor = pluginLoader.loadPlugin(
binding,
- project );
+ project,
+ session );
MojoDescriptor mojoDescriptor = descriptor.getMojo( binding.getGoal() );
return mojoDescriptor;
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java Wed Nov 14 21:37:55 2007
@@ -1,9 +1,11 @@
package org.apache.maven.lifecycle.binding;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleBindingLoader;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.LifecycleUtils;
+import org.apache.maven.lifecycle.MojoBindingUtils;
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
import org.apache.maven.lifecycle.model.LifecycleBindings;
import org.apache.maven.lifecycle.model.MojoBinding;
@@ -121,8 +123,9 @@
/**
* Construct the LifecycleBindings that constitute the extra mojos bound to the lifecycle within the POM itself.
+ * @param session
*/
- public LifecycleBindings getProjectCustomBindings( final MavenProject project )
+ public LifecycleBindings getProjectCustomBindings( final MavenProject project, final MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException
{
LifecycleBindings bindings = new LifecycleBindings();
@@ -169,7 +172,12 @@
mojoBinding.setExecutionId( execution.getId() );
mojoBinding.setOrigin( "POM" );
+ logger.debug( "Mojo: " + MojoBindingUtils.toString( mojoBinding ) + ": determining binding phase." );
+
String phase = execution.getPhase();
+
+ logger.debug( "Phase from <execution/> section (merged with outer <plugin/> section) is: " + phase );
+
boolean pluginResolved = false;
if ( phase == null )
@@ -178,7 +186,7 @@
{
try
{
- pluginDescriptor = pluginLoader.loadPlugin( plugin, project );
+ pluginDescriptor = pluginLoader.loadPlugin( plugin, project, session );
pluginResolved = true;
}
catch ( PluginLoaderException e )
@@ -214,6 +222,8 @@
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
phase = mojoDescriptor.getPhase();
+
+ logger.debug( "Phase from plugin descriptor: " + mojoDescriptor.getFullGoalName() + " is: " + phase );
}
if ( phase == null )
@@ -343,7 +353,7 @@
MojoBinding binding;
if ( goal.indexOf( ":" ) > 0 )
{
- binding = mojoBindingFactory.parseMojoBinding( goal, project, false );
+ binding = mojoBindingFactory.parseMojoBinding( goal, project );
}
else
{
@@ -404,7 +414,7 @@
* <li>plugin-level configuration</li>
* </ol>
*/
- public List getReportBindings( final MavenProject project )
+ public List getReportBindings( final MavenProject project, final MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException
{
if ( project.getModel().getReports() != null )
@@ -425,7 +435,7 @@
if ( ( reportSets == null ) || reportSets.isEmpty() )
{
- reports.addAll( getReportsForPlugin( reportPlugin, null, project ) );
+ reports.addAll( getReportsForPlugin( reportPlugin, null, project, session ) );
}
else
{
@@ -433,7 +443,7 @@
{
ReportSet reportSet = (ReportSet) j.next();
- reports.addAll( getReportsForPlugin( reportPlugin, reportSet, project ) );
+ reports.addAll( getReportsForPlugin( reportPlugin, reportSet, project, session ) );
}
}
}
@@ -502,12 +512,12 @@
* Retrieve any reports from the specified ReportPlugin which are referenced in the specified POM.
*/
private List getReportsForPlugin( final ReportPlugin reportPlugin, final ReportSet reportSet,
- final MavenProject project ) throws LifecycleLoaderException
+ final MavenProject project, final MavenSession session ) throws LifecycleLoaderException
{
PluginDescriptor pluginDescriptor;
try
{
- pluginDescriptor = pluginLoader.loadReportPlugin( reportPlugin, project );
+ pluginDescriptor = pluginLoader.loadReportPlugin( reportPlugin, project, session );
}
catch ( PluginLoaderException e )
{
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java Wed Nov 14 21:37:55 2007
@@ -1,5 +1,6 @@
package org.apache.maven.lifecycle.binding;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.model.MojoBinding;
@@ -28,7 +29,7 @@
* If a plugin-prefix is allowed and used, resolve the prefix and use the resulting PluginDescriptor
* to set groupId and artifactId on the MojoBinding instance.
*/
- public MojoBinding parseMojoBinding( String bindingSpec, MavenProject project, boolean allowPrefixReference )
+ public MojoBinding parseMojoBinding( String bindingSpec, MavenProject project, MavenSession session, boolean allowPrefixReference )
throws LifecycleSpecificationException, LifecycleLoaderException
{
StringTokenizer tok = new StringTokenizer( bindingSpec, ":" );
@@ -51,7 +52,7 @@
PluginDescriptor pluginDescriptor;
try
{
- pluginDescriptor = pluginLoader.findPluginForPrefix( prefix, project );
+ pluginDescriptor = pluginLoader.findPluginForPrefix( prefix, project, session );
}
catch ( PluginLoaderException e )
{
@@ -119,7 +120,26 @@
{
try
{
- return parseMojoBinding( bindingSpec, null, false );
+ return parseMojoBinding( bindingSpec, null, null, false );
+ }
+ catch ( LifecycleLoaderException e )
+ {
+ IllegalStateException error = new IllegalStateException( e.getMessage()
+ + "\n\nTHIS SHOULD BE IMPOSSIBLE DUE TO THE USAGE OF THE PLUGIN-LOADER." );
+
+ error.initCause( e );
+
+ throw error;
+ }
+ }
+
+ public MojoBinding parseMojoBinding( String bindingSpec,
+ MavenProject project )
+ throws LifecycleSpecificationException
+ {
+ try
+ {
+ return parseMojoBinding( bindingSpec, project, null, false );
}
catch ( LifecycleLoaderException e )
{
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java Wed Nov 14 21:37:55 2007
@@ -1,5 +1,6 @@
package org.apache.maven.lifecycle.binding;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.model.LifecycleBindings;
@@ -37,7 +38,7 @@
/**
* Construct the LifecycleBindings that constitute the extra mojos bound to the lifecycle within the POM itself.
*/
- LifecycleBindings getProjectCustomBindings( MavenProject project )
+ LifecycleBindings getProjectCustomBindings( MavenProject project, MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException;
/**
@@ -59,6 +60,6 @@
* <li>plugin-level configuration</li>
* </ol>
*/
- List getReportBindings( MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException;
+ List getReportBindings( MavenProject project, MavenSession session ) throws LifecycleLoaderException, LifecycleSpecificationException;
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java Wed Nov 14 21:37:55 2007
@@ -1,5 +1,6 @@
package org.apache.maven.lifecycle.binding;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.model.MojoBinding;
@@ -23,21 +24,38 @@
* If a plugin-prefix is allowed and used, resolve the prefix and use the resulting PluginDescriptor
* to set groupId and artifactId on the MojoBinding instance.
*/
- MojoBinding parseMojoBinding( String bindingSpec, MavenProject project, boolean allowPrefixReference )
+ MojoBinding parseMojoBinding( String bindingSpec,
+ MavenProject project,
+ MavenSession session,
+ boolean allowPrefixReference )
throws LifecycleSpecificationException, LifecycleLoaderException;
/**
* Create a new MojoBinding instance with the specified information, and inject POM configurations
* appropriate to that mojo before returning it.
*/
- MojoBinding createMojoBinding( String groupId, String artifactId, String version, String goal, MavenProject project );
+ MojoBinding createMojoBinding( String groupId,
+ String artifactId,
+ String version,
+ String goal,
+ MavenProject project );
/**
- * Simplified version of {@link MojoBindingFactory#parseMojoBinding(String, MavenProject, boolean)}
+ * Simplified version of {@link MojoBindingFactory#parseMojoBinding(String, MavenProject, MavenSession, boolean)}
* which assumes the project is null and prefixes are not allowed. This method will <b>never</b>
* result in the {@link PluginLoader} being used to resolve the PluginDescriptor.
*/
MojoBinding parseMojoBinding( String bindingSpec )
+ throws LifecycleSpecificationException;
+
+ /**
+ * Simplified version of {@link MojoBindingFactory#parseMojoBinding(String, MavenProject, MavenSession, boolean)}
+ * which assumes that prefixes are not allowed. This method will <b>never</b>
+ * result in the {@link PluginLoader} being used to resolve the PluginDescriptor.
+ * @throws LifecycleSpecificationException
+ */
+ MojoBinding parseMojoBinding( String bindingSpec,
+ MavenProject project )
throws LifecycleSpecificationException;
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java Wed Nov 14 21:37:55 2007
@@ -1,5 +1,6 @@
package org.apache.maven.lifecycle.plan;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.project.MavenProject;
@@ -21,6 +22,6 @@
/**
* Orchestrates construction of the build plan which will be used by the user of LifecycleExecutor.
*/
- BuildPlan constructBuildPlan( List tasks, MavenProject project )
+ BuildPlan constructBuildPlan( List tasks, MavenProject project, MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException;
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java Wed Nov 14 21:37:55 2007
@@ -1,5 +1,6 @@
package org.apache.maven.lifecycle.plan;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.LifecycleUtils;
@@ -46,28 +47,28 @@
/**
* Orchestrates construction of the build plan which will be used by the user of LifecycleExecutor.
*/
- public BuildPlan constructBuildPlan( final List tasks, final MavenProject project )
+ public BuildPlan constructBuildPlan( final List tasks, final MavenProject project, final MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException
{
LifecycleBindings defaultBindings = lifecycleBindingManager.getDefaultBindings( project );
LifecycleBindings packagingBindings = lifecycleBindingManager.getBindingsForPackaging( project );
- LifecycleBindings projectBindings = lifecycleBindingManager.getProjectCustomBindings( project );
+ LifecycleBindings projectBindings = lifecycleBindingManager.getProjectCustomBindings( project, session );
BuildPlan plan = new BuildPlan( packagingBindings, projectBindings, defaultBindings, tasks );
// initialize/resolve any direct-invocation tasks, if possible.
- initializeDirectInvocations( plan, project );
+ initializeDirectInvocations( plan, project, session );
// Inject forked lifecycles as plan modifiers for each mojo that has @execute in it.
- addForkedLifecycleModifiers( plan, project, new LinkedList() );
- addReportingLifecycleModifiers( plan, project, new LinkedList() );
+ addForkedLifecycleModifiers( plan, project, session, new LinkedList() );
+ addReportingLifecycleModifiers( plan, project, session, new LinkedList() );
// TODO: Inject relative-ordered project/plugin executions as plan modifiers.
return plan;
}
- private void initializeDirectInvocations( final BuildPlan plan, final MavenProject project )
+ private void initializeDirectInvocations( final BuildPlan plan, final MavenProject project, final MavenSession session )
throws LifecycleSpecificationException, LifecycleLoaderException
{
List tasks = plan.getTasks();
@@ -78,7 +79,7 @@
if ( !LifecycleUtils.isValidPhaseName( task ) )
{
- MojoBinding binding = mojoBindingFactory.parseMojoBinding( task, project, true );
+ MojoBinding binding = mojoBindingFactory.parseMojoBinding( task, project, session, true );
plan.addDirectInvocationBinding( task, binding );
}
}
@@ -94,7 +95,7 @@
* process of injecting any modifiers that are necessary to accommodate forked execution.
* @param callStack
*/
- private void addForkedLifecycleModifiers( final BuildPlan plan, final MavenProject project, LinkedList callStack )
+ private void addForkedLifecycleModifiers( final BuildPlan plan, final MavenProject project, MavenSession session, LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
List planBindings = plan.renderExecutionPlan( new Stack() );
@@ -104,14 +105,14 @@
{
MojoBinding mojoBinding = (MojoBinding) it.next();
- findForkModifiers( mojoBinding, plan, project, callStack );
+ findForkModifiers( mojoBinding, plan, project, session, callStack );
}
}
- private void findForkModifiers( final MojoBinding mojoBinding, final BuildPlan plan, final MavenProject project, LinkedList callStack )
+ private void findForkModifiers( final MojoBinding mojoBinding, final BuildPlan plan, final MavenProject project, MavenSession session, LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
- PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project );
+ PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project, session );
if ( pluginDescriptor == null )
{
@@ -125,7 +126,7 @@
+ pluginDescriptor.getId() + "." );
}
- findForkModifiers( mojoBinding, pluginDescriptor, plan, project, false, callStack );
+ findForkModifiers( mojoBinding, pluginDescriptor, plan, project, session, false, callStack );
}
/**
@@ -133,8 +134,9 @@
* process of injecting any modifiers that are necessary to accommodate mojos that require access to the project's
* configured reports.
* @param callStack
+ * @param session
*/
- private void addReportingLifecycleModifiers( final BuildPlan plan, final MavenProject project, LinkedList callStack )
+ private void addReportingLifecycleModifiers( final BuildPlan plan, final MavenProject project, MavenSession session, LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
List planBindings = plan.renderExecutionPlan( new Stack() );
@@ -144,7 +146,7 @@
{
MojoBinding mojoBinding = (MojoBinding) it.next();
- PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project );
+ PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project, session );
if ( pluginDescriptor == null )
{
@@ -160,7 +162,7 @@
if ( mojoDescriptor.isRequiresReports() )
{
- List reportBindings = lifecycleBindingManager.getReportBindings( project );
+ List reportBindings = lifecycleBindingManager.getReportBindings( project, session );
if ( reportBindings != null )
{
@@ -170,11 +172,11 @@
{
MojoBinding reportBinding = (MojoBinding) reportBindingIt.next();
- PluginDescriptor pd = loadPluginDescriptor( reportBinding, plan, project );
+ PluginDescriptor pd = loadPluginDescriptor( reportBinding, plan, project, session );
if ( pd != null )
{
- findForkModifiers( reportBinding, pd, plan, project, true, callStack );
+ findForkModifiers( reportBinding, pd, plan, project, session, true, callStack );
}
}
}
@@ -187,12 +189,12 @@
}
private PluginDescriptor loadPluginDescriptor( final MojoBinding mojoBinding, final BuildPlan plan,
- final MavenProject project )
+ final MavenProject project, final MavenSession session )
{
PluginDescriptor pluginDescriptor = null;
try
{
- pluginDescriptor = pluginLoader.loadPlugin( mojoBinding, project );
+ pluginDescriptor = pluginLoader.loadPlugin( mojoBinding, project, session );
}
catch ( PluginLoaderException e )
{
@@ -221,7 +223,8 @@
* @param callStack
*/
private void findForkModifiers( final MojoBinding mojoBinding, final PluginDescriptor pluginDescriptor,
- final BuildPlan plan, final MavenProject project, final boolean includeReportConfig, LinkedList callStack )
+ final BuildPlan plan, final MavenProject project, final MavenSession session,
+ final boolean includeReportConfig, LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
String referencingGoal = mojoBinding.getGoal();
@@ -240,7 +243,7 @@
}
else if ( mojoDescriptor.getExecutePhase() != null )
{
- recursePhaseMojoFork( mojoBinding, pluginDescriptor, plan, project, includeReportConfig, callStack );
+ recursePhaseMojoFork( mojoBinding, pluginDescriptor, plan, project, session, includeReportConfig, callStack );
}
}
@@ -252,9 +255,10 @@
* Hands off to the
* {@link DefaultBuildPlanner#modifyBuildPlanForForkedLifecycle(MojoBinding, PluginDescriptor, ModifiablePlanElement, LifecycleBindings, MavenProject, LinkedList, List)}
* method to handle the actual plan modification.
+ * @param session
*/
private void recursePhaseMojoFork( final MojoBinding mojoBinding, final PluginDescriptor pluginDescriptor,
- final BuildPlan plan, final MavenProject project,
+ final BuildPlan plan, final MavenProject project, final MavenSession session,
final boolean includeReportConfig, LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
@@ -301,7 +305,7 @@
plan.addForkedExecution( mojoBinding, clonedPlan );
- addForkedLifecycleModifiers( clonedPlan, project, callStack );
+ addForkedLifecycleModifiers( clonedPlan, project, session, callStack );
}
finally
{
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/EndForkedExecutionMojo.java Wed Nov 14 21:37:55 2007
@@ -1,7 +1,6 @@
package org.apache.maven.lifecycle.statemgmt;
-import org.apache.maven.context.BuildContextManager;
-import org.apache.maven.lifecycle.LifecycleExecutionContext;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -20,23 +19,20 @@
private int forkId = -1;
- private BuildContextManager buildContextManager;
+ private MavenSession session;
public void execute()
throws MojoExecutionException, MojoFailureException
{
getLog().info( "Ending forked execution [fork id: " + forkId + "]" );
- LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
- MavenProject executionProject = ctx.removeForkedProject();
+ MavenProject executionProject = session.removeForkedProject();
- MavenProject project = ctx.getCurrentProject();
+ MavenProject project = session.getCurrentProject();
if ( ( project != null ) && ( executionProject != null ) )
{
project.setExecutionProject( executionProject );
}
-
- ctx.store( buildContextManager );
}
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java Wed Nov 14 21:37:55 2007
@@ -1,5 +1,6 @@
package org.apache.maven.lifecycle.statemgmt;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.MojoBindingUtils;
import org.apache.maven.lifecycle.binding.MojoBindingFactory;
import org.apache.maven.lifecycle.model.MojoBinding;
@@ -30,6 +31,8 @@
private MavenProject project;
+ private MavenSession session;
+
private MojoBindingFactory bindingFactory;
public void execute() throws MojoExecutionException, MojoFailureException
@@ -37,7 +40,7 @@
MojoBinding binding = bindingFactory.createMojoBinding( groupId, artifactId, version, artifactId, project );
try
{
- PluginDescriptor descriptor = pluginLoader.loadPlugin( binding, project );
+ PluginDescriptor descriptor = pluginLoader.loadPlugin( binding, project, session );
MojoDescriptor mojoDescriptor = descriptor.getMojo( goal );
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/StartForkedExecutionMojo.java Wed Nov 14 21:37:55 2007
@@ -1,7 +1,6 @@
package org.apache.maven.lifecycle.statemgmt;
-import org.apache.maven.context.BuildContextManager;
-import org.apache.maven.lifecycle.LifecycleExecutionContext;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -19,21 +18,19 @@
private MavenProject project;
- private int forkId = -1;
+ private MavenSession session;
- private BuildContextManager buildContextManager;
+ private int forkId = -1;
public void execute()
throws MojoExecutionException, MojoFailureException
{
getLog().info( "Starting forked execution [fork id: " + forkId + "]" );
- LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
if ( project != null )
{
- ctx.addForkedProject( new MavenProject( project ) );
+ session.addForkedProject( new MavenProject( project ) );
}
- ctx.store( buildContextManager );
}
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Wed Nov 14 21:37:55 2007
@@ -35,12 +35,10 @@
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.context.BuildContextManager;
import org.apache.maven.execution.MavenRealmManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.RealmManagementException;
import org.apache.maven.execution.RuntimeInformation;
-import org.apache.maven.lifecycle.LifecycleExecutionContext;
import org.apache.maven.lifecycle.statemgmt.StateManagementUtils;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin;
@@ -135,8 +133,6 @@
protected PluginMappingManager pluginMappingManager;
- private BuildContextManager buildContextManager;
-
// END component requirements
public DefaultPluginManager()
@@ -337,8 +333,10 @@
Set artifacts = getPluginArtifacts( pluginArtifact, projectPlugin, project,
session.getLocalRepository() );
+ getLogger().debug( "Got plugin artifacts:\n\n" + artifacts );
+
MavenRealmManager realmManager = session.getRealmManager();
- ClassRealm pluginRealm = realmManager.getPluginRealm( projectPlugin );;
+ ClassRealm pluginRealm = realmManager.getPluginRealm( projectPlugin );
if ( pluginRealm == null )
{
try
@@ -389,6 +387,15 @@
getLogger().debug( "Realm for plugin: " + plugin.getKey() + ":\n" + pluginRealm );
}
+ else
+ {
+ List managedPluginArtifacts = realmManager.getPluginArtifacts( projectPlugin );
+
+ if ( ( managedPluginArtifacts == null ) || ( managedPluginArtifacts.isEmpty() && !artifacts.isEmpty() ) )
+ {
+ realmManager.setPluginArtifacts( projectPlugin, artifacts );
+ }
+ }
}
private Set getPluginArtifacts( Artifact pluginArtifact,
@@ -581,14 +588,7 @@
// for reference by future mojos.
if ( mojo instanceof MavenReport )
{
- LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
- if ( ctx == null )
- {
- ctx = new LifecycleExecutionContext( project );
- }
-
- ctx.addReport( mojoDescriptor, (MavenReport) mojo );
- ctx.store( buildContextManager );
+ session.addReport( mojoDescriptor, (MavenReport) mojo );
}
dispatcher.dispatchEnd( event, goalExecId );
@@ -783,19 +783,10 @@
// PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
// mojoDescriptor.getConfiguration() );
- // NEW: Pass in the LifecycleExecutionContext so we have access to the current project,
- // forked project stack (future), and reports.
- LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
- if ( ctx == null )
- {
- ctx = new LifecycleExecutionContext( project );
- }
-
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session,
mojoExecution,
pathTranslator,
- ctx,
getLogger(),
session.getExecutionProperties() );
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Wed Nov 14 21:37:55 2007
@@ -20,7 +20,6 @@
*/
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.lifecycle.LifecycleExecutionContext;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
@@ -75,38 +74,33 @@
private final Properties properties;
- private final LifecycleExecutionContext lifecycleExecutionContext;
-
public PluginParameterExpressionEvaluator( MavenSession context,
MojoExecution mojoExecution,
PathTranslator pathTranslator,
- LifecycleExecutionContext lifecycleExecutionContext,
Logger logger,
Properties properties )
{
this.context = context;
this.mojoExecution = mojoExecution;
this.pathTranslator = pathTranslator;
- this.lifecycleExecutionContext = lifecycleExecutionContext;
this.logger = logger;
this.properties = properties;
-
- this.project = lifecycleExecutionContext.getCurrentProject();
+ project = context.getCurrentProject();
String basedir = null;
if ( project != null )
{
- File projectFile = project.getFile();
+ File projectFile = project.getBasedir();
// this should always be the case for non-super POM instances...
if ( projectFile != null )
{
- basedir = projectFile.getParentFile().getAbsolutePath();
+ basedir = projectFile.getAbsolutePath();
}
}
- if ( basedir == null && context != null )
+ if ( ( basedir == null ) && ( context != null ) )
{
basedir = context.getExecutionRootDirectory();
}
@@ -133,10 +127,9 @@
this.context = context;
this.mojoExecution = mojoExecution;
this.pathTranslator = pathTranslator;
- this.lifecycleExecutionContext = new LifecycleExecutionContext( project );
this.logger = logger;
this.properties = properties;
-
+
this.project = project;
String basedir = null;
@@ -169,7 +162,7 @@
{
return null;
}
-
+
String expression = stripTokens( expr );
if ( expression.equals( expr ) )
{
@@ -180,15 +173,15 @@
if ( lastIndex >= 0 )
{
String retVal = expr.substring( 0, index );
-
- if ( index > 0 && expr.charAt( index - 1 ) == '$' )
+
+ if ( ( index > 0 ) && ( expr.charAt( index - 1 ) == '$' ) )
{
retVal += expr.substring( index + 1, lastIndex + 1 );
}
else
{
Object subResult = evaluate( expr.substring( index, lastIndex + 1 ) );
-
+
if ( subResult != null )
{
retVal += subResult;
@@ -198,7 +191,7 @@
retVal += "$" + expr.substring( index + 1, lastIndex + 1 );
}
}
-
+
retVal += evaluate( expr.substring( lastIndex + 1 ) );
return retVal;
}
@@ -243,9 +236,9 @@
}
else if ( "reports".equals( expression ) )
{
- value = lifecycleExecutionContext.getReports();
+ value = context.getReports();
}
- else if ("mojoExecution".equals(expression))
+ else if ("mojoExecution".equals(expression))
{
value = mojoExecution;
}
@@ -357,7 +350,7 @@
{
// The CLI should win for defining properties
- if ( value == null && properties != null )
+ if ( ( value == null ) && ( properties != null ) )
{
// We will attempt to get nab a system property as a way to specify a
// parameter to a plugins. My particular case here is allowing the surefire
@@ -367,7 +360,7 @@
value = properties.getProperty( expression );
}
- if ( value == null && ( project != null && project.getProperties() != null ) )
+ if ( ( value == null ) && ( ( project != null ) && ( project.getProperties() != null ) ) )
{
value = project.getProperties().getProperty( expression );
}
@@ -400,7 +393,7 @@
private String stripTokens( String expr )
{
- if ( expr.startsWith( "${" ) && expr.indexOf( "}" ) == expr.length() - 1 )
+ if ( expr.startsWith( "${" ) && ( expr.indexOf( "}" ) == expr.length() - 1 ) )
{
expr = expr.substring( 2, expr.length() - 1 );
}
@@ -411,11 +404,11 @@
{
File basedir;
- if ( project != null && project.getFile() != null )
+ if ( ( project != null ) && ( project.getFile() != null ) )
{
basedir = project.getFile().getParentFile();
}
- else if ( context != null && context.getExecutionRootDirectory() != null )
+ else if ( ( context != null ) && ( context.getExecutionRootDirectory() != null ) )
{
basedir = new File( context.getExecutionRootDirectory() ).getAbsoluteFile();
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/loader/DefaultPluginLoader.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/loader/DefaultPluginLoader.java?rev=595215&r1=595214&r2=595215&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/loader/DefaultPluginLoader.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/loader/DefaultPluginLoader.java Wed Nov 14 21:37:55 2007
@@ -3,8 +3,7 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.context.BuildContextManager;
-import org.apache.maven.execution.SessionContext;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin;
@@ -44,8 +43,6 @@
private PluginMappingManager pluginMappingManager;
- private BuildContextManager buildContextManager;
-
private MavenPluginCollector pluginCollector;
/**
@@ -53,7 +50,7 @@
* using the project for {@link ArtifactRepository} and other supplemental plugin information as
* necessary.
*/
- public PluginDescriptor loadPlugin( MojoBinding mojoBinding, MavenProject project )
+ public PluginDescriptor loadPlugin( MojoBinding mojoBinding, MavenProject project, MavenSession session )
throws PluginLoaderException
{
PluginDescriptor pluginDescriptor = null;
@@ -63,7 +60,7 @@
plugin.setArtifactId( mojoBinding.getArtifactId() );
plugin.setVersion( mojoBinding.getVersion() );
- pluginDescriptor = loadPlugin( plugin, project );
+ pluginDescriptor = loadPlugin( plugin, project, session );
// fill in any blanks once we know more about this plugin.
if ( pluginDescriptor != null )
@@ -88,7 +85,7 @@
* and try to resolve based on that.</li>
* </ol>
*/
- public PluginDescriptor findPluginForPrefix( String prefix, MavenProject project )
+ public PluginDescriptor findPluginForPrefix( String prefix, MavenProject project, MavenSession session )
throws PluginLoaderException
{
Set descriptors = pluginCollector.getPluginDescriptorsForPrefix( prefix );
@@ -109,12 +106,12 @@
if ( pluginDescriptor == null )
{
- pluginDescriptor = loadFromProject( prefix, project );
+ pluginDescriptor = loadFromProject( prefix, project, session );
}
if ( pluginDescriptor == null )
{
- pluginDescriptor = loadByPrefix( prefix, project );
+ pluginDescriptor = loadByPrefix( prefix, project, session );
}
if ( pluginDescriptor == null )
@@ -122,7 +119,7 @@
Plugin plugin = new Plugin();
plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) );
- pluginDescriptor = loadPlugin( plugin, project );
+ pluginDescriptor = loadPlugin( plugin, project, session );
}
if ( pluginDescriptor == null )
@@ -137,7 +134,7 @@
* Look for a plugin configured in the current project that has a prefix matching the one
* specified. Return the {@link PluginDescriptor} if a match is found.
*/
- private PluginDescriptor loadFromProject( String prefix, MavenProject project )
+ private PluginDescriptor loadFromProject( String prefix, MavenProject project, MavenSession session )
throws PluginLoaderException
{
PluginDescriptor result = null;
@@ -146,7 +143,7 @@
{
Plugin plugin = (Plugin) it.next();
- PluginDescriptor pluginDescriptor = loadPlugin( plugin, project );
+ PluginDescriptor pluginDescriptor = loadPlugin( plugin, project, session );
if ( prefix.equals( pluginDescriptor.getGoalPrefix() ) )
{
result = pluginDescriptor;
@@ -161,14 +158,13 @@
* Look for a plugin in the pluginGroups specified in the settings.xml that has a prefix
* matching the one specified. Return the {@link PluginDescriptor} if a match is found.
*/
- private PluginDescriptor loadByPrefix( String prefix, MavenProject project )
+ private PluginDescriptor loadByPrefix( String prefix, MavenProject project, MavenSession session )
throws PluginLoaderException
{
- SessionContext ctx = SessionContext.read( buildContextManager );
- Settings settings = ctx.getSettings();
+ Settings settings = session.getSettings();
Plugin plugin = pluginMappingManager.getByPrefix( prefix, settings.getPluginGroups(),
- project.getPluginArtifactRepositories(), ctx.getLocalRepository() );
+ project.getPluginArtifactRepositories(), session.getLocalRepository() );
PluginDescriptor pluginDescriptor = null;
if ( plugin != null )
@@ -179,7 +175,7 @@
plugin.setVersion( projectPlugin.getVersion() );
}
- pluginDescriptor = loadPlugin( plugin, project );
+ pluginDescriptor = loadPlugin( plugin, project, session );
}
return pluginDescriptor;
@@ -189,7 +185,7 @@
* Load the {@link PluginDescriptor} instance for the specified plugin, using the project for
* the {@link ArtifactRepository} and other supplemental plugin information as necessary.
*/
- public PluginDescriptor loadPlugin( Plugin plugin, MavenProject project )
+ public PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session )
throws PluginLoaderException
{
if ( plugin.getGroupId() == null )
@@ -197,11 +193,9 @@
plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
}
- SessionContext ctx = SessionContext.read( buildContextManager );
-
try
{
- PluginDescriptor result = pluginManager.verifyPlugin( plugin, project, ctx.getSession() );
+ PluginDescriptor result = pluginManager.verifyPlugin( plugin, project, session );
// this has been simplified from the old code that injected the plugin management stuff, since
// pluginManagement injection is now handled by the project method.
@@ -249,7 +243,7 @@
* using the project for {@link ArtifactRepository} and other supplemental report/plugin information as
* necessary.
*/
- public PluginDescriptor loadReportPlugin( MojoBinding mojoBinding, MavenProject project )
+ public PluginDescriptor loadReportPlugin( MojoBinding mojoBinding, MavenProject project, MavenSession session )
throws PluginLoaderException
{
ReportPlugin plugin = new ReportPlugin();
@@ -257,7 +251,7 @@
plugin.setArtifactId( mojoBinding.getArtifactId() );
plugin.setVersion( mojoBinding.getVersion() );
- PluginDescriptor pluginDescriptor = loadReportPlugin( plugin, project );
+ PluginDescriptor pluginDescriptor = loadReportPlugin( plugin, project, session );
mojoBinding.setVersion( pluginDescriptor.getVersion() );
@@ -268,16 +262,14 @@
* Load the {@link PluginDescriptor} instance for the specified report plugin, using the project for
* the {@link ArtifactRepository} and other supplemental report/plugin information as necessary.
*/
- public PluginDescriptor loadReportPlugin( ReportPlugin plugin, MavenProject project )
+ public PluginDescriptor loadReportPlugin( ReportPlugin plugin, MavenProject project, MavenSession session )
throws PluginLoaderException
{
// TODO: Shouldn't we be injecting pluginManagement info here??
- SessionContext ctx = SessionContext.read( buildContextManager );
-
try
{
- return pluginManager.verifyReportPlugin( plugin, project, ctx.getSession() );
+ return pluginManager.verifyReportPlugin( plugin, project, session );
}
catch ( ArtifactResolutionException e )
{