o more additions to the session code, not turned on yet but doing things in

smaller batches.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162980 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-08-15 15:01:52 +00:00
parent 72d71b215f
commit 5e0b187204
27 changed files with 295 additions and 190 deletions

View File

@ -17,8 +17,11 @@ package org.apache.maven;
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.MavenLifecycleManager;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
import org.apache.maven.lifecycle.goal.GoalNotFoundException;
import org.apache.maven.lifecycle.session.MavenSession;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
@ -61,7 +64,7 @@ public class DefaultMaven
private PluginManager pluginManager;
private MavenLifecycleManager lifecycleManager;
private MavenGoalPhaseManager lifecycleManager;
private MavenProjectBuilder projectBuilder;
@ -95,7 +98,8 @@ public class DefaultMaven
MavenSession session = new MavenSession( container,
pluginManager,
project,
getLocalRepository() );
getLocalRepository(),
goals );
for ( Iterator iterator = goals.iterator(); iterator.hasNext(); )
{

View File

@ -21,6 +21,7 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.lifecycle.goal.GoalNotFoundException;
import java.io.File;
import java.util.List;

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle;
package org.apache.maven.lifecycle.goal;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -22,10 +22,10 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public abstract class AbstractMavenLifecyclePhase
public abstract class AbstractMavenGoalPhase
extends AbstractLogEnabled
implements MavenLifecyclePhase
implements MavenGoalPhase
{
public abstract void execute( MavenGoalExecutionContext context )
throws Exception;
throws GoalExecutionException;
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle;
package org.apache.maven.lifecycle.goal;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -25,9 +25,9 @@ import java.util.List;
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class DefaultMavenLifecycleManager
public class DefaultMavenGoalPhaseManager
extends AbstractLogEnabled
implements MavenLifecycleManager
implements MavenGoalPhaseManager
{
private List lifecyclePhases;
@ -37,11 +37,11 @@ public class DefaultMavenLifecycleManager
}
public void execute( MavenGoalExecutionContext context )
throws Exception
throws GoalExecutionException
{
for ( Iterator iterator = lifecyclePhases.iterator(); iterator.hasNext(); )
{
MavenLifecyclePhase phase = (MavenLifecyclePhase) iterator.next();
MavenGoalPhase phase = (MavenGoalPhase) iterator.next();
phase.enableLogging( getLogger() );

View File

@ -0,0 +1,40 @@
package org.apache.maven.lifecycle.goal;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class GoalExecutionException
extends Exception
{
public GoalExecutionException( String message )
{
super( message );
}
public GoalExecutionException( Throwable cause )
{
super( cause );
}
public GoalExecutionException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -1,4 +1,6 @@
package org.apache.maven;
package org.apache.maven.lifecycle.goal;
import org.apache.maven.lifecycle.goal.GoalExecutionException;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -17,7 +19,7 @@ package org.apache.maven;
*/
public class GoalNotFoundException
extends Exception
extends GoalExecutionException
{
private String goalName;

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle;
package org.apache.maven.lifecycle.goal;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.decoration.GoalDecoratorBindings;

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle;
package org.apache.maven.lifecycle.goal;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -17,18 +17,19 @@ package org.apache.maven.lifecycle;
*/
import org.codehaus.plexus.logging.Logger;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public interface MavenLifecyclePhase
public interface MavenGoalPhase
{
String ROLE = MavenLifecyclePhase.class.getName();
String ROLE = MavenGoalPhase.class.getName();
void execute( MavenGoalExecutionContext context )
throws Exception;
throws GoalExecutionException;
void enableLogging( Logger logger );
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle;
package org.apache.maven.lifecycle.goal;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,18 +16,20 @@ package org.apache.maven.lifecycle;
* limitations under the License.
*/
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import java.util.List;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public interface MavenLifecycleManager
public interface MavenGoalPhaseManager
{
String ROLE = MavenLifecycleManager.class.getName();
String ROLE = MavenGoalPhaseManager.class.getName();
void execute( MavenGoalExecutionContext context )
throws Exception;
throws GoalExecutionException;
List getLifecyclePhases();
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle.phase;
package org.apache.maven.lifecycle.goal.phase;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -17,9 +17,12 @@ package org.apache.maven.lifecycle.phase;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
import org.apache.maven.lifecycle.goal.GoalExecutionException;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.Iterator;
@ -28,15 +31,17 @@ import java.util.Iterator;
* @version $Id$
*/
public class DependencyDownloadPhase
extends AbstractMavenLifecyclePhase
extends AbstractMavenGoalPhase
{
public void execute( MavenGoalExecutionContext context )
throws Exception
throws GoalExecutionException
{
ArtifactResolver artifactResolver = null;
try
{
// Once this is a property component there will be an assembly phase for
// this and we won't have to do this.
artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
for ( Iterator it = context.getProject().getArtifacts().iterator(); it.hasNext(); )
@ -48,6 +53,14 @@ public class DependencyDownloadPhase
context.getLocalRepository() );
}
}
catch ( ComponentLookupException e )
{
throw new GoalExecutionException( "Can't lookup artifact resolver: ", e );
}
catch ( ArtifactResolutionException e )
{
throw new GoalExecutionException( "Can't resolve artifact: ", e );
}
finally
{
context.release( artifactResolver );

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle.phase;
package org.apache.maven.lifecycle.goal.phase;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,11 +16,12 @@ package org.apache.maven.lifecycle.phase;
* limitations under the License.
*/
import org.apache.maven.artifact.MavenMetadataSource;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.MavenMetadataSource;
import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
import org.apache.maven.lifecycle.goal.GoalExecutionException;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.project.MavenProject;
import java.util.Iterator;
@ -30,10 +31,10 @@ import java.util.Iterator;
* @version $Id$
*/
public class DependencyResolutionPhase
extends AbstractMavenLifecyclePhase
extends AbstractMavenGoalPhase
{
public void execute( MavenGoalExecutionContext context )
throws Exception
throws GoalExecutionException
{
for ( Iterator iterator = context.getResolvedGoals().iterator(); iterator.hasNext(); )
{
@ -41,7 +42,14 @@ public class DependencyResolutionPhase
if ( context.getMojoDescriptor( goalName ).requiresDependencyResolution() )
{
resolveTransitiveDependencies( context );
try
{
resolveTransitiveDependencies( context );
}
catch ( Exception e )
{
throw new GoalExecutionException( "Can't resolve transitive dependencies: ", e );
}
break;
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle.phase;
package org.apache.maven.lifecycle.goal.phase;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,14 +16,16 @@ package org.apache.maven.lifecycle.phase;
* limitations under the License.
*/
import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
import org.apache.maven.lifecycle.goal.GoalExecutionException;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.plugin.OgnlProjectValueExtractor;
import org.apache.maven.plugin.Plugin;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.HashMap;
import java.util.Iterator;
@ -35,10 +37,10 @@ import java.util.Map;
* @version $Id$
*/
public class GoalAttainmentPhase
extends AbstractMavenLifecyclePhase
extends AbstractMavenGoalPhase
{
public void execute( MavenGoalExecutionContext context )
throws Exception
throws GoalExecutionException
{
PluginExecutionResponse response;
@ -73,6 +75,14 @@ public class GoalAttainmentPhase
break;
}
}
catch ( ComponentLookupException e )
{
throw new GoalExecutionException( "Error looking up plugin: ", e );
}
catch ( Exception e )
{
throw new GoalExecutionException( "Error executing plugin: ", e );
}
finally
{
releaseComponents( mojoDescriptor, request, context );

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle.phase;
package org.apache.maven.lifecycle.goal.phase;
/*
@ -16,10 +16,12 @@ package org.apache.maven.lifecycle.phase;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.decoration.GoalDecorationParser;
import org.apache.maven.decoration.GoalDecoratorBindings;
import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
import org.apache.maven.lifecycle.goal.GoalExecutionException;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.project.MavenProject;
import org.xmlpull.v1.XmlPullParserException;
@ -33,7 +35,7 @@ import java.io.IOException;
* @author <a href="mailto:jdcasey@commonjava.org">John Casey</a>
* @version $Id$
*/
public class GoalDecorationPhase extends AbstractMavenLifecyclePhase
public class GoalDecorationPhase extends AbstractMavenGoalPhase
{
public static final String MAVEN_XML_DEFAULT_NAMESPACE = "mavenxml";
public static final String MAVEN_SCRIPT = "decorators.xml";
@ -41,31 +43,42 @@ public class GoalDecorationPhase extends AbstractMavenLifecyclePhase
private boolean decoratorsInitialized = false;
public void execute( MavenGoalExecutionContext context )
throws Exception
throws GoalExecutionException
{
synchronized ( this )
{
if ( !decoratorsInitialized )
{
initializeDecorators( context );
try
{
initializeDecorators( context );
}
catch ( XmlPullParserException e )
{
throw new GoalExecutionException( "Error parsing decorators.xml: ", e );
}
catch ( IOException e )
{
throw new GoalExecutionException( "Error reading decorators.xml file: ", e );
}
}
}
context.setGoalDecoratorBindings(decorators);
context.setGoalDecoratorBindings( decorators );
}
private void initializeDecorators( MavenGoalExecutionContext context )
throws XmlPullParserException, IOException
{
MavenProject project = context.getProject( );
MavenProject project = context.getProject();
File pom = project.getFile( );
File pom = project.getFile();
File dir = pom.getParentFile( );
File dir = pom.getParentFile();
File scriptFile = new File( dir, MAVEN_SCRIPT );
if ( scriptFile.exists( ) )
if ( scriptFile.exists() )
{
BufferedReader reader = null;
@ -73,7 +86,7 @@ public class GoalDecorationPhase extends AbstractMavenLifecyclePhase
{
reader = new BufferedReader( new FileReader( scriptFile ) );
GoalDecorationParser parser = new GoalDecorationParser( );
GoalDecorationParser parser = new GoalDecorationParser();
this.decorators = parser.parse( reader );
}
finally
@ -82,7 +95,7 @@ public class GoalDecorationPhase extends AbstractMavenLifecyclePhase
{
try
{
reader.close( );
reader.close();
}
catch ( IOException e )
{
@ -90,7 +103,7 @@ public class GoalDecorationPhase extends AbstractMavenLifecyclePhase
}
}
}
decoratorsInitialized = true;
}
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle.phase;
package org.apache.maven.lifecycle.goal.phase;
/*
@ -17,11 +17,13 @@ package org.apache.maven.lifecycle.phase;
* limitations under the License.
*/
import org.apache.maven.GoalNotFoundException;
import org.apache.maven.lifecycle.goal.GoalNotFoundException;
import org.apache.maven.decoration.GoalDecorator;
import org.apache.maven.decoration.GoalDecoratorBindings;
import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.GoalExecutionException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
@ -36,19 +38,18 @@ import java.util.Set;
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class GoalResolutionPhase extends AbstractMavenLifecyclePhase
public class GoalResolutionPhase extends AbstractMavenGoalPhase
{
public void execute( MavenGoalExecutionContext context )
throws Exception
throws GoalExecutionException
{
PluginManager pluginManager = null;
PluginManager pluginManager = context.getSession().getPluginManager();
try
{
pluginManager = (PluginManager) context.lookup( PluginManager.ROLE );
// First, start by retrieving the currently-requested goal.
MojoDescriptor goalDescriptor = context.getMojoDescriptor();
if ( goalDescriptor == null )
{
throw new GoalNotFoundException( context.getGoalName() );

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle.phase;
package org.apache.maven.lifecycle.goal.phase;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,10 +16,12 @@ package org.apache.maven.lifecycle.phase;
* limitations under the License.
*/
import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
import org.apache.maven.lifecycle.goal.GoalExecutionException;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
/**
* From the name of the goal we can determine the plugin that houses the
@ -32,12 +34,20 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
* @version $Id$
*/
public class PluginDownloadPhase
extends AbstractMavenLifecyclePhase
extends AbstractMavenGoalPhase
{
public void execute( MavenGoalExecutionContext context )
throws Exception
throws GoalExecutionException
{
PluginManager pluginManager = (PluginManager) context.lookup( PluginManager.ROLE );
PluginManager pluginManager = null;
try
{
pluginManager = (PluginManager) context.lookup( PluginManager.ROLE );
}
catch ( ComponentLookupException e )
{
throw new GoalExecutionException( "Error looking up plugin manager: ", e );
}
String goalName = context.getGoalName();
@ -51,13 +61,18 @@ public class PluginDownloadPhase
// would be good to let the plugin manager deal with all of this
pluginManager.verifyPluginForGoal( goalName );
try
{
pluginManager.verifyPluginForGoal( goalName );
}
catch ( Exception e )
{
throw new GoalExecutionException( "Error verifying plugin: ", e );
}
if ( goalName.indexOf( ":" ) < 0 )
{
goalName = context.getProject().getType() + ":" + goalName;
System.out.println( "goalName inside plugin download phase = " + goalName );
}
MojoDescriptor md = pluginManager.getMojoDescriptor( goalName );

View File

@ -17,9 +17,6 @@ package org.apache.maven.lifecycle.session;
*/
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.apache.maven.lifecycle.MavenLifecycleManager;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.MavenLifecyclePhase;
import java.util.Iterator;
import java.util.List;
@ -30,7 +27,7 @@ import java.util.List;
*/
public class DefaultMavenSessionPhaseManager
extends AbstractLogEnabled
implements MavenLifecycleManager
implements MavenSessionPhaseManager
{
private List lifecyclePhases;
@ -39,21 +36,16 @@ public class DefaultMavenSessionPhaseManager
return lifecyclePhases;
}
public void execute( MavenGoalExecutionContext context )
public void execute( MavenSession context )
throws Exception
{
for ( Iterator iterator = lifecyclePhases.iterator(); iterator.hasNext(); )
{
MavenLifecyclePhase phase = (MavenLifecyclePhase) iterator.next();
MavenSessionPhase phase = (MavenSessionPhase) iterator.next();
phase.enableLogging( getLogger() );
phase.execute( context );
if ( context.isExecutionFailure() )
{
break;
}
}
}
}

View File

@ -8,6 +8,7 @@ import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.Set;
import java.util.List;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -41,10 +42,13 @@ public class MavenSession
private Set remoteRepositories;
private List goals;
public MavenSession( PlexusContainer container,
PluginManager pluginManager,
MavenProject project,
ArtifactRepository localRepository )
ArtifactRepository localRepository,
List goals )
{
this.container = container;
@ -53,6 +57,8 @@ public class MavenSession
this.project = project;
this.localRepository = localRepository;
this.goals = goals;
}
public PlexusContainer getContainer()
@ -85,6 +91,11 @@ public class MavenSession
return remoteRepositories;
}
public List getGoals()
{
return goals;
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------

View File

@ -16,9 +16,6 @@ package org.apache.maven.lifecycle.session;
* limitations under the License.
*/
import org.apache.maven.lifecycle.MavenLifecycleManager;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import java.util.List;
/**
@ -29,7 +26,7 @@ public interface MavenSessionPhaseManager
{
String ROLE = MavenSessionPhaseManager.class.getName();
void execute( MavenGoalExecutionContext context )
void execute( MavenSession session )
throws Exception;
List getLifecyclePhases();

View File

@ -0,0 +1,61 @@
package org.apache.maven.lifecycle.session.phase;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.ExecutionResponse;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
import org.apache.maven.lifecycle.session.AbstractMavenSessionPhase;
import org.apache.maven.lifecycle.session.MavenSession;
import java.util.Iterator;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class GoalExecutionPhase
extends AbstractMavenSessionPhase
{
public void execute( MavenSession session )
throws Exception
{
MavenGoalPhaseManager lifecycleManager = (MavenGoalPhaseManager) session.lookup( MavenGoalPhaseManager.ROLE );
ExecutionResponse response = new ExecutionResponse();
for ( Iterator iterator = session.getGoals().iterator(); iterator.hasNext(); )
{
String goal = (String) iterator.next();
MavenGoalExecutionContext context;
context = new MavenGoalExecutionContext( session, session.getPluginManager().getMojoDescriptor( goal ) );
context.setGoalName( goal );
lifecycleManager.execute( context );
if ( context.isExecutionFailure() )
{
response.setExecutionFailure( context.getMojoDescriptor().getId(), context.getFailureResponse() );
break;
}
}
}
}

View File

@ -233,8 +233,6 @@ public class DefaultPluginManager
if ( !isPluginInstalled( pluginId ) )
{
System.out.println( pluginId + " is not installed. Now installing into " + localRepository.getBasedir() + " ..." );
//!! This is entirely crappy. We need a better naming for plugin artifact ids and
// we definitely need better version extraction support.
@ -251,8 +249,6 @@ public class DefaultPluginManager
public void addPlugin( Artifact pluginArtifact )
throws Exception
{
System.out.println( "adding plugin " + pluginArtifact );
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
MavenMetadataSource sr = new MavenMetadataSource( remotePluginRepositories,

View File

@ -18,7 +18,7 @@ package org.apache.maven.plugin;
import ognl.Ognl;
import ognl.OgnlException;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
/**

View File

@ -14,7 +14,7 @@
<role>org.codehaus.plexus.i18n.I18N</role>
</requirement>
<requirement>
<role>org.apache.maven.lifecycle.MavenLifecycleManager</role>
<role>org.apache.maven.lifecycle.goal.MavenGoalPhaseManager</role>
</requirement>
</requirements>
</component>
@ -26,16 +26,30 @@
</configuration>
</component>
<component>
<role>org.apache.maven.lifecycle.MavenLifecycleManager</role>
<implementation>org.apache.maven.lifecycle.DefaultMavenLifecycleManager</implementation>
<role>org.apache.maven.lifecycle.session.MavenSessionPhaseManager</role>
<implementation>org.apache.maven.lifecycle.session.DefaultMavenSessionPhaseManager</implementation>
<configuration>
<lifecycle-phases>
<lifecycle-phase implementation="org.apache.maven.lifecycle.phase.PluginDownloadPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.phase.GoalDecorationPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.phase.GoalResolutionPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.phase.DependencyResolutionPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.phase.DependencyDownloadPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.phase.GoalAttainmentPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.PluginDownloadPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalDecorationPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalResolutionPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyResolutionPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyDownloadPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalAttainmentPhase"/>
</lifecycle-phases>
</configuration>
</component>
<component>
<role>org.apache.maven.lifecycle.goal.MavenGoalPhaseManager</role>
<implementation>org.apache.maven.lifecycle.goal.DefaultMavenGoalPhaseManager</implementation>
<configuration>
<lifecycle-phases>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.PluginDownloadPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalDecorationPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalResolutionPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyResolutionPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyDownloadPhase"/>
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalAttainmentPhase"/>
</lifecycle-phases>
</configuration>
</component>

View File

@ -17,7 +17,7 @@ package org.apache.maven;
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.session.MavenSession;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
@ -28,6 +28,8 @@ import org.codehaus.classworlds.ClassWorld;
import org.codehaus.plexus.PlexusTestCase;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@ -102,7 +104,9 @@ public class MavenTestCase
project.setProperty( "foo", "bar" );
MavenSession session = new MavenSession( getContainer(), pluginManager, project, localRepository );
List goals = new ArrayList();
MavenSession session = new MavenSession( getContainer(), pluginManager, project, localRepository, goals );
MojoDescriptor descriptor;

View File

@ -1,6 +1,7 @@
package org.apache.maven.lifecycle;
import org.apache.maven.MavenTestCase;
import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
import java.util.List;
@ -14,7 +15,7 @@ public class MavenLifecycleManagerTest
public void testMavenLifecycleManager()
throws Exception
{
MavenLifecycleManager mlm = (MavenLifecycleManager) lookup( MavenLifecycleManager.ROLE );
MavenGoalPhaseManager mlm = (MavenGoalPhaseManager) lookup( MavenGoalPhaseManager.ROLE );
List lifecyclePhases = mlm.getLifecyclePhases();

View File

@ -1,9 +1,9 @@
/* Created on Jul 14, 2004 */
package org.apache.maven.lifecycle.phase;
package org.apache.maven.lifecycle.goal.phase;
import org.apache.maven.decoration.DefaultGoalDecorator;
import org.apache.maven.decoration.GoalDecoratorBindings;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.MavenTestCase;
import java.util.ArrayList;

View File

@ -1,81 +0,0 @@
/* Created on Jul 14, 2004 */
package org.apache.maven.lifecycle.phase;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.MavenTestCase;
import org.apache.maven.decoration.GoalDecoratorBindings;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
/**
* @author jdcasey
*/
public class GoalDecorationPhaseTest
extends MavenTestCase
{
private static final String DECORATOR_SCRIPT =
"<decorators defaultGoal=\"jar:jar\">" +
"<preGoal name=\"compiler:compile\" attain=\"compiler:init-fs\"/>" +
"<preGoal name=\"compiler:compile\" attain=\"compiler:init-repo\"/>" +
"<postGoal name=\"compiler:compile\" attain=\"test:test\"/>" +
"<postGoal name=\"compiler:compile\" attain=\"jar:jar\"/>" +
"</decorators>";
protected void setUp()
throws Exception
{
super.setUp();
File mavenScriptFile = new File( basedir, "target/test-classes/" + GoalDecorationPhase.MAVEN_SCRIPT );
BufferedWriter out = new BufferedWriter( new FileWriter( mavenScriptFile ) );
out.write( DECORATOR_SCRIPT );
out.flush();
out.close();
}
public void testShouldConstructWithNoArgs()
{
new GoalDecorationPhase();
}
public void testShouldParseDecoratorsFromFile() throws Exception
{
MavenGoalExecutionContext context = createGoalExecutionContext();
GoalDecorationPhase phase = new GoalDecorationPhase();
phase.execute( context );
GoalDecoratorBindings bindings = context.getGoalDecoratorBindings();
assertNotNull( bindings );
assertEquals( "jar:jar", bindings.getDefaultGoal() );
assertEquals( 2, bindings.getPreGoals( "compiler:compile" ).size() );
assertEquals( 2, bindings.getPostGoals( "compiler:compile" ).size() );
}
}

View File

@ -2,7 +2,7 @@ package org.apache.maven.plugin;
import org.apache.maven.MavenTestCase;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.lifecycle.MavenGoalExecutionContext;
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;