mirror of https://github.com/apache/maven.git
o Removed GoalDecorationPhase, since goal decoration is now a part of the model
o Removed PluginDownloadPhase, since plugin resolution/download has to be a part of the prereq and pre/postGoal resolution, too o Changed DefaultMaven to execute the session lifecycle, and the component wiring to likewise wire the DefaultMaven with a session lifecycle manager o Removed the org.apache.maven.decoration package and its contents, since this is all in the model now o Fixed the GoalResolutionPhase to verify each goal's plugin in turn as it resolves prereqs, preGoals and postGoals o Fixed the GoalResolutionPhaseTest to work with the new resolution model o Added a new createGoalExecutionContext to the MavenTestCase base class, to allow me to inject a MavenProject directly rather than a pom file o Fixed the MavenLifecycleManagerTest to only expect 4 lifecycle phases, now than the plugin resolution and goal decoration phases are obsoleted o All builds on local machine, but will depend on plexus-0.17.jar/pom and plexus-artifact-container-1.0-alpha-1.jar/pom to build on beaver o I uploaded plexus-artifact-container-1.0-alpha-1.jar to ${plexus.home}/dist, but cannot upload POMs due to priveleges problem in poms dir. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163007 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
24ce8263d9
commit
a949eb66de
|
@ -25,23 +25,22 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
* @version $Id$
|
* @version $Id: DefaultArtifactHandlerManager.java,v 1.1.1.1 2004/08/09
|
||||||
|
* 18:37:32 jvanzyl Exp $
|
||||||
*/
|
*/
|
||||||
public class DefaultArtifactHandlerManager
|
public class DefaultArtifactHandlerManager
|
||||||
implements ArtifactHandlerManager
|
implements ArtifactHandlerManager
|
||||||
{
|
{
|
||||||
private Map artifactHandlers;
|
private Map artifactHandlers;
|
||||||
|
|
||||||
public ArtifactHandler getArtifactHandler( String type )
|
public ArtifactHandler getArtifactHandler( String type ) throws ArtifactHandlerNotFoundException
|
||||||
throws ArtifactHandlerNotFoundException
|
|
||||||
{
|
{
|
||||||
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( type );
|
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( type );
|
||||||
|
|
||||||
if ( handler == null )
|
if ( handler == null )
|
||||||
{
|
{
|
||||||
throw new ArtifactHandlerNotFoundException(
|
throw new ArtifactHandlerNotFoundException( "Artifact handler for type '" + type + "' cannot be found." );
|
||||||
"Artifact handler for type '" + type + "' cannot be found." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler;
|
return handler;
|
||||||
|
@ -82,18 +81,12 @@ public class DefaultArtifactHandlerManager
|
||||||
{
|
{
|
||||||
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( artifact.getType() );
|
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( artifact.getType() );
|
||||||
|
|
||||||
return interpolateLayout( artifact.getGroupId(),
|
return interpolateLayout( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), handler
|
||||||
artifact.getArtifactId(),
|
.directory(), handler.extension() );
|
||||||
artifact.getVersion(),
|
|
||||||
handler.directory(),
|
|
||||||
handler.extension() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String interpolateLayout( String groupId,
|
private String interpolateLayout( String groupId, String artifactId, String version, String directory,
|
||||||
String artifactId,
|
String extension )
|
||||||
String version,
|
|
||||||
String directory,
|
|
||||||
String extension )
|
|
||||||
{
|
{
|
||||||
String layout = getLayout();
|
String layout = getLayout();
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
<decorators>
|
|
||||||
<preGoal name="compiler:compile" attain="clean:clean"/>
|
|
||||||
<postGoal name="compiler:compile" attain="jar:install"/>
|
|
||||||
</decorators>
|
|
|
@ -1 +1 @@
|
||||||
jar:jar
|
compiler:compile
|
||||||
|
|
|
@ -11,4 +11,18 @@
|
||||||
<type>test</type>
|
<type>test</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<preGoals>
|
||||||
|
<preGoal>
|
||||||
|
<name>compiler:compile</name>
|
||||||
|
<attain>clean:clean</attain>
|
||||||
|
</preGoal>
|
||||||
|
</preGoals>
|
||||||
|
|
||||||
|
<postGoals>
|
||||||
|
<postGoal>
|
||||||
|
<name>compiler:compile</name>
|
||||||
|
<attain>jar:jar</attain>
|
||||||
|
</postGoal>
|
||||||
|
</postGoals>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -52,17 +52,6 @@
|
||||||
<artifactId>ognl</artifactId>
|
<artifactId>ognl</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Used to support maven.xml script and goal decorating in general. -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>marmalade</groupId>
|
|
||||||
<artifactId>marmalade-core</artifactId>
|
|
||||||
<version>0.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>marmalade</groupId>
|
|
||||||
<artifactId>marmalade-el-ognl</artifactId>
|
|
||||||
<version>0.1</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Wagon -->
|
<!-- Wagon -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
package org.apache.maven;
|
package org.apache.maven;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001-2004 The Apache Software Foundation.
|
* 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
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* you may not use this file except in compliance with the License.
|
* http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
||||||
* You may obtain a copy of the License at
|
* or agreed to in writing, software distributed under the License is
|
||||||
*
|
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* KIND, either express or implied. See the License for the specific language
|
||||||
*
|
* governing permissions and limitations under the License.
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
@ -23,6 +18,7 @@ import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
|
||||||
import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
|
import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
|
||||||
import org.apache.maven.lifecycle.goal.GoalNotFoundException;
|
import org.apache.maven.lifecycle.goal.GoalNotFoundException;
|
||||||
import org.apache.maven.lifecycle.session.MavenSession;
|
import org.apache.maven.lifecycle.session.MavenSession;
|
||||||
|
import org.apache.maven.lifecycle.session.MavenSessionPhaseManager;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
@ -65,7 +61,7 @@ public class DefaultMaven
|
||||||
|
|
||||||
private PluginManager pluginManager;
|
private PluginManager pluginManager;
|
||||||
|
|
||||||
private MavenGoalPhaseManager lifecycleManager;
|
private MavenSessionPhaseManager lifecycleManager;
|
||||||
|
|
||||||
private MavenProjectBuilder projectBuilder;
|
private MavenProjectBuilder projectBuilder;
|
||||||
|
|
||||||
|
@ -75,20 +71,18 @@ public class DefaultMaven
|
||||||
// Project execution
|
// Project execution
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public ExecutionResponse execute( List goals )
|
public ExecutionResponse execute( List goals ) throws GoalNotFoundException
|
||||||
throws GoalNotFoundException
|
|
||||||
{
|
{
|
||||||
return execute( (MavenProject) null, goals );
|
return execute( (MavenProject) null, goals );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecutionResponse execute( File projectFile, List goals )
|
public ExecutionResponse execute( File projectFile, List goals ) throws ProjectBuildingException,
|
||||||
throws ProjectBuildingException, GoalNotFoundException
|
GoalNotFoundException
|
||||||
{
|
{
|
||||||
return execute( getProject( projectFile ), goals );
|
return execute( getProject( projectFile ), goals );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecutionResponse execute( MavenProject project, List goals )
|
public ExecutionResponse execute( MavenProject project, List goals ) throws GoalNotFoundException
|
||||||
throws GoalNotFoundException
|
|
||||||
{
|
{
|
||||||
Date fullStop;
|
Date fullStop;
|
||||||
|
|
||||||
|
@ -96,57 +90,35 @@ public class DefaultMaven
|
||||||
|
|
||||||
ExecutionResponse response = new ExecutionResponse();
|
ExecutionResponse response = new ExecutionResponse();
|
||||||
|
|
||||||
MavenSession session = new MavenSession( container,
|
MavenSession session = new MavenSession( container, pluginManager, project, getLocalRepository(), goals );
|
||||||
pluginManager,
|
|
||||||
project,
|
|
||||||
getLocalRepository(),
|
|
||||||
goals );
|
|
||||||
|
|
||||||
for ( Iterator iterator = goals.iterator(); iterator.hasNext(); )
|
try
|
||||||
{
|
{
|
||||||
String goal = (String) iterator.next();
|
lifecycleManager.execute( session );
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
response.setException( e );
|
||||||
|
|
||||||
MavenGoalExecutionContext context;
|
if ( logResults )
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
context = new MavenGoalExecutionContext( session, getMojoDescriptor( goal ) );
|
line();
|
||||||
|
|
||||||
context.setGoalName( goal );
|
getLogger().error( "BUILD ERROR" );
|
||||||
|
|
||||||
lifecycleManager.execute( context );
|
line();
|
||||||
|
|
||||||
if ( context.isExecutionFailure() )
|
getLogger().error( "Cause: ", e );
|
||||||
{
|
|
||||||
response.setExecutionFailure( context.getMojoDescriptor().getId(), context.getFailureResponse() );
|
|
||||||
|
|
||||||
break;
|
line();
|
||||||
}
|
|
||||||
|
stats( fullStart, new Date() );
|
||||||
|
|
||||||
|
line();
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
response.setException( e );
|
|
||||||
|
|
||||||
if ( logResults )
|
// An exception is a failure
|
||||||
{
|
return response;
|
||||||
line();
|
|
||||||
|
|
||||||
getLogger().error( "BUILD ERROR" );
|
|
||||||
|
|
||||||
line();
|
|
||||||
|
|
||||||
getLogger().error( "Cause: ", e );
|
|
||||||
|
|
||||||
line();
|
|
||||||
|
|
||||||
stats( fullStart, new Date() );
|
|
||||||
|
|
||||||
line();
|
|
||||||
}
|
|
||||||
|
|
||||||
// An exception is a failure
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fullStop = new Date();
|
fullStop = new Date();
|
||||||
|
@ -204,7 +176,8 @@ public class DefaultMaven
|
||||||
|
|
||||||
Runtime r = Runtime.getRuntime();
|
Runtime r = Runtime.getRuntime();
|
||||||
|
|
||||||
getLogger().info( "Final Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb ) + "M/" + ( r.totalMemory() / mb ) + "M" );
|
getLogger().info(
|
||||||
|
"Final Memory: " + ((r.totalMemory() - r.freeMemory()) / mb) + "M/" + (r.totalMemory() / mb) + "M" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,8 +190,8 @@ public class DefaultMaven
|
||||||
// Reactor execution
|
// Reactor execution
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public ExecutionResponse executeReactor( String goals, String includes, String excludes )
|
public ExecutionResponse executeReactor( String goals, String includes, String excludes ) throws ReactorException,
|
||||||
throws ReactorException, GoalNotFoundException
|
GoalNotFoundException
|
||||||
{
|
{
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
|
@ -298,8 +271,7 @@ public class DefaultMaven
|
||||||
// Project building
|
// Project building
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public MavenProject getProject( File project )
|
public MavenProject getProject( File project ) throws ProjectBuildingException
|
||||||
throws ProjectBuildingException
|
|
||||||
{
|
{
|
||||||
if ( project.exists() )
|
if ( project.exists() )
|
||||||
{
|
{
|
||||||
|
@ -316,8 +288,7 @@ public class DefaultMaven
|
||||||
// Reactor
|
// Reactor
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public List getSortedProjects( List projects )
|
public List getSortedProjects( List projects ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return projectBuilder.getSortedProjects( projects );
|
return projectBuilder.getSortedProjects( projects );
|
||||||
}
|
}
|
||||||
|
@ -361,8 +332,7 @@ public class DefaultMaven
|
||||||
// Lifecylce Management
|
// Lifecylce Management
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public void contextualize( Context context )
|
public void contextualize( Context context ) throws ContextException
|
||||||
throws ContextException
|
|
||||||
{
|
{
|
||||||
container = (ArtifactEnabledContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
container = (ArtifactEnabledContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||||
}
|
}
|
||||||
|
@ -393,8 +363,7 @@ public class DefaultMaven
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public void booty()
|
public void booty() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
pluginManager.setLocalRepository( getLocalRepository() );
|
pluginManager.setLocalRepository( getLocalRepository() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/* Created on Apr 6, 2004 */
|
|
||||||
package org.apache.maven.decoration;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default implementation of a goal decorator.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jdcasey@commonjava.org">John Casey</a>
|
|
||||||
*/
|
|
||||||
public class DefaultGoalDecorator implements GoalDecorator
|
|
||||||
{
|
|
||||||
|
|
||||||
private String goal;
|
|
||||||
private String decoratorGoal;
|
|
||||||
|
|
||||||
public DefaultGoalDecorator( String goal, String decoratorGoal )
|
|
||||||
{
|
|
||||||
this.goal = goal;
|
|
||||||
this.decoratorGoal = decoratorGoal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGoalToDecorate()
|
|
||||||
{
|
|
||||||
return goal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDecoratorGoal()
|
|
||||||
{
|
|
||||||
return decoratorGoal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "DefaultGoalDecorator[decorate: " + goal +
|
|
||||||
" with: " + decoratorGoal + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
/* Created on Jul 2, 2004 */
|
|
||||||
package org.apache.maven.decoration;
|
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jdcasey
|
|
||||||
*/
|
|
||||||
public class GoalDecorationParser {
|
|
||||||
|
|
||||||
public static final String ROOT_TAG = "decorators";
|
|
||||||
public static final String DEFAULT_GOAL_ATTRIBUTE = "defaultGoal";
|
|
||||||
|
|
||||||
public static final String PREGOAL_TAG = "preGoal";
|
|
||||||
public static final String POSTGOAL_TAG = "postGoal";
|
|
||||||
|
|
||||||
public static final String NAME_ATTRIBUTE = "name";
|
|
||||||
public static final String ATTAIN_ATTRIBUTE = "attain";
|
|
||||||
|
|
||||||
public GoalDecorationParser() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public GoalDecoratorBindings parse(Reader reader) throws XmlPullParserException, IOException {
|
|
||||||
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
|
|
||||||
XmlPullParser parser = factory.newPullParser();
|
|
||||||
|
|
||||||
parser.setInput(reader);
|
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = null;
|
|
||||||
|
|
||||||
int eventType = parser.getEventType();
|
|
||||||
while(eventType != XmlPullParser.END_DOCUMENT) {
|
|
||||||
|
|
||||||
if(eventType == XmlPullParser.START_TAG) {
|
|
||||||
String tagName = parser.getName();
|
|
||||||
if(ROOT_TAG.equals(tagName)) {
|
|
||||||
bindings = new GoalDecoratorBindings();
|
|
||||||
|
|
||||||
String defaultGoal = parser.getAttributeValue("", DEFAULT_GOAL_ATTRIBUTE);
|
|
||||||
if(defaultGoal != null && defaultGoal.length() > 0) {
|
|
||||||
bindings.setDefaultGoal(defaultGoal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(PREGOAL_TAG.equals(tagName)) {
|
|
||||||
String name = parser.getAttributeValue("", NAME_ATTRIBUTE);
|
|
||||||
String attain = parser.getAttributeValue("", ATTAIN_ATTRIBUTE);
|
|
||||||
DefaultGoalDecorator decorator = new DefaultGoalDecorator(name, attain);
|
|
||||||
|
|
||||||
bindings.addPreGoal(decorator);
|
|
||||||
}
|
|
||||||
else if(POSTGOAL_TAG.equals(tagName)) {
|
|
||||||
String name = parser.getAttributeValue("", NAME_ATTRIBUTE);
|
|
||||||
String attain = parser.getAttributeValue("", ATTAIN_ATTRIBUTE);
|
|
||||||
DefaultGoalDecorator decorator = new DefaultGoalDecorator(name, attain);
|
|
||||||
|
|
||||||
bindings.addPostGoal(decorator);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new IllegalArgumentException(tagName + " is not allowed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
eventType = parser.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
return bindings;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
/* Created on Apr 5, 2004 */
|
|
||||||
package org.apache.maven.decoration;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a decorator which executes around the main execution of a goal, but which
|
|
||||||
* fits outside the DAG, since it (a) cannot have prereqs, and (b) should decorate the execution
|
|
||||||
* of all prereqs of the goal, to encapsulate the entire process.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jdcasey@commonjava.org">John Casey</a>
|
|
||||||
*/
|
|
||||||
public interface GoalDecorator
|
|
||||||
{
|
|
||||||
|
|
||||||
/** The goal to which this decorator is bound. */
|
|
||||||
String getGoalToDecorate();
|
|
||||||
|
|
||||||
/** The goal to execute when this decorator is triggered by execution of the bound goal target.
|
|
||||||
*/
|
|
||||||
String getDecoratorGoal();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
/* Created on Apr 9, 2004 */
|
|
||||||
package org.apache.maven.decoration;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jdcasey
|
|
||||||
*/
|
|
||||||
public class GoalDecoratorBindings
|
|
||||||
{
|
|
||||||
|
|
||||||
private Map preGoals = new HashMap();
|
|
||||||
private Map postGoals = new HashMap();
|
|
||||||
private String defaultGoal = "compiler:compile";
|
|
||||||
|
|
||||||
public GoalDecoratorBindings()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPreGoal( GoalDecorator decorator )
|
|
||||||
{
|
|
||||||
addGoalDecorator( decorator, preGoals );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPostGoal( GoalDecorator decorator )
|
|
||||||
{
|
|
||||||
addGoalDecorator( decorator, postGoals );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getPreGoals( String goal )
|
|
||||||
{
|
|
||||||
List result = (List) preGoals.get( goal );
|
|
||||||
if ( result == null )
|
|
||||||
{
|
|
||||||
result = Collections.EMPTY_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.unmodifiableList( result );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getPostGoals( String goal )
|
|
||||||
{
|
|
||||||
List result = (List) postGoals.get( goal );
|
|
||||||
if ( result == null )
|
|
||||||
{
|
|
||||||
result = Collections.EMPTY_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.unmodifiableList( result );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addGoalDecorator( GoalDecorator decorator, Map decoratorMap )
|
|
||||||
{
|
|
||||||
String goal = decorator.getGoalToDecorate();
|
|
||||||
|
|
||||||
List decorators = (List) decoratorMap.get( goal );
|
|
||||||
if ( decorators == null )
|
|
||||||
{
|
|
||||||
decorators = new ArrayList();
|
|
||||||
decoratorMap.put( goal, decorators );
|
|
||||||
}
|
|
||||||
|
|
||||||
decorators.add( decorator );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param defGoal
|
|
||||||
*/
|
|
||||||
public void setDefaultGoal( String defGoal )
|
|
||||||
{
|
|
||||||
this.defaultGoal = defGoal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefaultGoal()
|
|
||||||
{
|
|
||||||
return defaultGoal;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.apache.maven.lifecycle.goal;
|
package org.apache.maven.lifecycle.goal;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.decoration.GoalDecoratorBindings;
|
|
||||||
import org.apache.maven.lifecycle.session.MavenSession;
|
import org.apache.maven.lifecycle.session.MavenSession;
|
||||||
import org.apache.maven.plugin.FailureResponse;
|
import org.apache.maven.plugin.FailureResponse;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
|
@ -12,8 +11,9 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
* @version $Id$
|
* @version $Id: MavenGoalExecutionContext.java,v 1.1 2004/08/15 15:01:50
|
||||||
|
* jvanzyl Exp $
|
||||||
*/
|
*/
|
||||||
public class MavenGoalExecutionContext
|
public class MavenGoalExecutionContext
|
||||||
{
|
{
|
||||||
|
@ -27,13 +27,13 @@ public class MavenGoalExecutionContext
|
||||||
|
|
||||||
private List resolvedGoals;
|
private List resolvedGoals;
|
||||||
|
|
||||||
private GoalDecoratorBindings goalDecoratorBindings;
|
// private GoalDecoratorBindings goalDecoratorBindings;
|
||||||
|
|
||||||
private String goalName;
|
private String goalName;
|
||||||
|
|
||||||
public MavenGoalExecutionContext( MavenSession session, MojoDescriptor goal )
|
public MavenGoalExecutionContext( MavenSession session, MojoDescriptor goal )
|
||||||
{
|
{
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
|
||||||
this.mojoDescriptor = goal;
|
this.mojoDescriptor = goal;
|
||||||
}
|
}
|
||||||
|
@ -62,14 +62,12 @@ public class MavenGoalExecutionContext
|
||||||
return session.getRemoteRepositories();
|
return session.getRemoteRepositories();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object lookup( String role )
|
public Object lookup( String role ) throws ComponentLookupException
|
||||||
throws ComponentLookupException
|
|
||||||
{
|
{
|
||||||
return session.lookup( role );
|
return session.lookup( role );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object lookup( String role, String hint )
|
public Object lookup( String role, String hint ) throws ComponentLookupException
|
||||||
throws ComponentLookupException
|
|
||||||
{
|
{
|
||||||
return session.lookup( role, hint );
|
return session.lookup( role, hint );
|
||||||
}
|
}
|
||||||
|
@ -125,7 +123,7 @@ public class MavenGoalExecutionContext
|
||||||
|
|
||||||
public boolean isExecutionFailure()
|
public boolean isExecutionFailure()
|
||||||
{
|
{
|
||||||
return ( failedGoal != null );
|
return (failedGoal != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFailedGoal()
|
public String getFailedGoal()
|
||||||
|
@ -148,16 +146,6 @@ public class MavenGoalExecutionContext
|
||||||
this.failureResponse = failureResponse;
|
this.failureResponse = failureResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GoalDecoratorBindings getGoalDecoratorBindings()
|
|
||||||
{
|
|
||||||
return goalDecoratorBindings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGoalDecoratorBindings( GoalDecoratorBindings goalDecoratorBindings )
|
|
||||||
{
|
|
||||||
this.goalDecoratorBindings = goalDecoratorBindings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGoalName()
|
public String getGoalName()
|
||||||
{
|
{
|
||||||
return goalName;
|
return goalName;
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package org.apache.maven.lifecycle.goal.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.decoration.GoalDecorationParser;
|
|
||||||
import org.apache.maven.decoration.GoalDecoratorBindings;
|
|
||||||
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;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
|
||||||
* @author <a href="mailto:jdcasey@commonjava.org">John Casey</a>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class GoalDecorationPhase extends AbstractMavenGoalPhase
|
|
||||||
{
|
|
||||||
public void execute( MavenGoalExecutionContext context )
|
|
||||||
throws GoalExecutionException
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.apache.maven.lifecycle.goal.phase;
|
package org.apache.maven.lifecycle.goal.phase;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001-2004 The Apache Software Foundation.
|
* Copyright 2001-2004 The Apache Software Foundation.
|
||||||
*
|
*
|
||||||
|
@ -18,12 +17,13 @@ package org.apache.maven.lifecycle.goal.phase;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.lifecycle.goal.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.goal.AbstractMavenGoalPhase;
|
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.MavenGoalExecutionContext;
|
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
|
||||||
import org.apache.maven.lifecycle.goal.GoalExecutionException;
|
import org.apache.maven.lifecycle.goal.GoalExecutionException;
|
||||||
|
import org.apache.maven.model.GoalDecorator;
|
||||||
|
import org.apache.maven.model.PostGoal;
|
||||||
|
import org.apache.maven.model.PreGoal;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
|
|
||||||
|
@ -35,31 +35,37 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class GoalResolutionPhase extends AbstractMavenGoalPhase
|
public class GoalResolutionPhase
|
||||||
|
extends AbstractMavenGoalPhase
|
||||||
{
|
{
|
||||||
public void execute( MavenGoalExecutionContext context )
|
public void execute( MavenGoalExecutionContext context ) throws GoalExecutionException
|
||||||
throws GoalExecutionException
|
|
||||||
{
|
{
|
||||||
PluginManager pluginManager = context.getSession().getPluginManager();
|
PluginManager pluginManager = context.getSession().getPluginManager();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// First, start by retrieving the currently-requested goal.
|
// First, start by retrieving the currently-requested goal.
|
||||||
MojoDescriptor goalDescriptor = context.getMojoDescriptor();
|
String goal = context.getGoalName();
|
||||||
|
|
||||||
if ( goalDescriptor == null )
|
|
||||||
{
|
|
||||||
throw new GoalNotFoundException( context.getGoalName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
String goal = goalDescriptor.getId();
|
|
||||||
|
|
||||||
List resolvedGoals = resolveTopLevel( goal, new HashSet(), new LinkedList(), context, pluginManager );
|
List resolvedGoals = resolveTopLevel( goal, new HashSet(), new LinkedList(), context, pluginManager );
|
||||||
|
|
||||||
context.setResolvedGoals( resolvedGoals );
|
context.setResolvedGoals( resolvedGoals );
|
||||||
|
|
||||||
|
if ( goal.indexOf( ":" ) < 0 )
|
||||||
|
{
|
||||||
|
goal = context.getProject().getType() + ":" + goal;
|
||||||
|
}
|
||||||
|
|
||||||
|
MojoDescriptor md = pluginManager.getMojoDescriptor( goal );
|
||||||
|
|
||||||
|
context.setMojoDescriptor( md );
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
throw new GoalExecutionException( "Error resolving goals: ", e );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -67,19 +73,26 @@ public class GoalResolutionPhase extends AbstractMavenGoalPhase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List resolveTopLevel( String goal, Set includedGoals, List results, MavenGoalExecutionContext context, PluginManager pluginManager )
|
private List resolveTopLevel( String goal, Set includedGoals, List results, MavenGoalExecutionContext context,
|
||||||
|
PluginManager pluginManager ) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
// Retrieve the prereqs-driven execution path for this goal, using the DAG.
|
// Ensure that the plugin for this goal is installed.
|
||||||
|
pluginManager.verifyPluginForGoal( goal );
|
||||||
|
|
||||||
|
// Retrieve the prereqs-driven execution path for this goal, using the
|
||||||
|
// DAG.
|
||||||
List work = pluginManager.getGoals( goal );
|
List work = pluginManager.getGoals( goal );
|
||||||
|
|
||||||
// Reverse the original goals list to preserve encapsulation while decorating.
|
// Reverse the original goals list to preserve encapsulation while
|
||||||
|
// decorating.
|
||||||
Collections.reverse( work );
|
Collections.reverse( work );
|
||||||
|
|
||||||
return resolveWithPrereqs( work, includedGoals, results, context, pluginManager );
|
return resolveWithPrereqs( work, includedGoals, results, context, pluginManager );
|
||||||
}
|
}
|
||||||
|
|
||||||
private List resolveWithPrereqs( List work, Set includedGoals, List results, MavenGoalExecutionContext context, PluginManager pluginManager )
|
private List resolveWithPrereqs( List work, Set includedGoals, List results, MavenGoalExecutionContext context,
|
||||||
|
PluginManager pluginManager ) throws Exception
|
||||||
{
|
{
|
||||||
if ( !work.isEmpty() )
|
if ( !work.isEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -89,35 +102,50 @@ public class GoalResolutionPhase extends AbstractMavenGoalPhase
|
||||||
|
|
||||||
if ( descriptor.alwaysExecute() || !includedGoals.contains( goal ) )
|
if ( descriptor.alwaysExecute() || !includedGoals.contains( goal ) )
|
||||||
{
|
{
|
||||||
GoalDecoratorBindings bindings = context.getGoalDecoratorBindings();
|
List preGoals = new LinkedList();
|
||||||
if ( bindings != null )
|
List allPreGoals = context.getProject().getModel().getPreGoals();
|
||||||
|
for ( Iterator it = allPreGoals.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
List preGoals = bindings.getPreGoals( goal );
|
PreGoal preGoal = (PreGoal) it.next();
|
||||||
|
if ( goal.equals( preGoal.getName() ) )
|
||||||
results = resolveGoalDecorators( preGoals, includedGoals, results, context, pluginManager );
|
{
|
||||||
|
preGoals.add( preGoal.getAttain() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
results = resolveGoalDecorators( goal, true, includedGoals, results, context, pluginManager );
|
||||||
|
|
||||||
results = resolveWithPrereqs( work, includedGoals, results, context, pluginManager );
|
results = resolveWithPrereqs( work, includedGoals, results, context, pluginManager );
|
||||||
includedGoals.add( goal );
|
includedGoals.add( goal );
|
||||||
results.add( goal );
|
results.add( goal );
|
||||||
|
|
||||||
if ( bindings != null )
|
results = resolveGoalDecorators( goal, false, includedGoals, results, context, pluginManager );
|
||||||
{
|
|
||||||
List postGoals = bindings.getPostGoals( goal );
|
|
||||||
results = resolveGoalDecorators( postGoals, includedGoals, results, context, pluginManager );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List resolveGoalDecorators( List preGoals, Set includedGoals, List results, MavenGoalExecutionContext context, PluginManager pluginManager )
|
private List resolveGoalDecorators( String baseGoal, boolean usePreGoals, Set includedGoals, List results,
|
||||||
|
MavenGoalExecutionContext context, PluginManager pluginManager ) throws Exception
|
||||||
{
|
{
|
||||||
for ( Iterator it = preGoals.iterator(); it.hasNext(); )
|
List decorators = null;
|
||||||
|
if ( usePreGoals )
|
||||||
|
{
|
||||||
|
decorators = context.getProject().getModel().getPreGoals();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
decorators = context.getProject().getModel().getPostGoals();
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator it = decorators.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
GoalDecorator decorator = (GoalDecorator) it.next();
|
GoalDecorator decorator = (GoalDecorator) it.next();
|
||||||
String goal = decorator.getDecoratorGoal();
|
if ( baseGoal.equals( decorator.getName() ) )
|
||||||
resolveTopLevel( goal, includedGoals, results, context, pluginManager );
|
{
|
||||||
|
String goal = decorator.getAttain();
|
||||||
|
resolveTopLevel( goal, includedGoals, results, context, pluginManager );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
package org.apache.maven.lifecycle.goal.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.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
|
|
||||||
* goal. The goal will be in the form pluginId:goalName so we take the pluginId
|
|
||||||
* portion of the name and with that we can determine if the plugin is installed
|
|
||||||
* or not. If the plugin is not installed then we can use the pluginId to retrieve
|
|
||||||
* the plugin and install it for use.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class PluginDownloadPhase
|
|
||||||
extends AbstractMavenGoalPhase
|
|
||||||
{
|
|
||||||
public void execute( MavenGoalExecutionContext context )
|
|
||||||
throws GoalExecutionException
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
|
|
||||||
// m2 install
|
|
||||||
|
|
||||||
// install the install plugin
|
|
||||||
|
|
||||||
// if this is a dispatcher goal then turn install in to type:install
|
|
||||||
|
|
||||||
// then the appropriate prereqs will be called
|
|
||||||
|
|
||||||
// would be good to let the plugin manager deal with all of this
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pluginManager.verifyPluginForGoal( goalName );
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
throw new GoalExecutionException( "Error verifying plugin: ", e );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( goalName.indexOf( ":" ) < 0 )
|
|
||||||
{
|
|
||||||
goalName = context.getProject().getType() + ":" + goalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
MojoDescriptor md = pluginManager.getMojoDescriptor( goalName );
|
|
||||||
|
|
||||||
context.setMojoDescriptor( md );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,14 +25,13 @@ import org.apache.maven.lifecycle.session.MavenSession;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class GoalExecutionPhase
|
public class GoalExecutionPhase
|
||||||
extends AbstractMavenSessionPhase
|
extends AbstractMavenSessionPhase
|
||||||
{
|
{
|
||||||
public void execute( MavenSession session )
|
public void execute( MavenSession session ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
MavenGoalPhaseManager lifecycleManager = (MavenGoalPhaseManager) session.lookup( MavenGoalPhaseManager.ROLE );
|
MavenGoalPhaseManager lifecycleManager = (MavenGoalPhaseManager) session.lookup( MavenGoalPhaseManager.ROLE );
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
package org.apache.maven.plugin;
|
package org.apache.maven.plugin;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001-2004 The Apache Software Foundation.
|
* 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
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* you may not use this file except in compliance with the License.
|
* http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
||||||
* You may obtain a copy of the License at
|
* or agreed to in writing, software distributed under the License is
|
||||||
*
|
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* KIND, either express or implied. See the License for the specific language
|
||||||
*
|
* governing permissions and limitations under the License.
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
@ -111,8 +106,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
private Set pluginsInProcess = new HashSet();
|
private Set pluginsInProcess = new HashSet();
|
||||||
|
|
||||||
public void processPluginDescriptor( MavenPluginDescriptor mavenPluginDescriptor )
|
public void processPluginDescriptor( MavenPluginDescriptor mavenPluginDescriptor ) throws CycleDetectedException
|
||||||
throws CycleDetectedException
|
|
||||||
{
|
{
|
||||||
if ( pluginsInProcess.contains( mavenPluginDescriptor.getPluginId() ) )
|
if ( pluginsInProcess.contains( mavenPluginDescriptor.getPluginId() ) )
|
||||||
{
|
{
|
||||||
|
@ -152,8 +146,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processEdge( String mojoId, String prereq )
|
private boolean processEdge( String mojoId, String prereq ) throws CycleDetectedException
|
||||||
throws CycleDetectedException
|
|
||||||
{
|
{
|
||||||
dag.addEdge( mojoId, prereq );
|
dag.addEdge( mojoId, prereq );
|
||||||
|
|
||||||
|
@ -191,7 +184,7 @@ public class DefaultPluginManager
|
||||||
{
|
{
|
||||||
ComponentSetDescriptor componentSetDescriptor = event.getComponentSetDescriptor();
|
ComponentSetDescriptor componentSetDescriptor = event.getComponentSetDescriptor();
|
||||||
|
|
||||||
if ( !( componentSetDescriptor instanceof MavenPluginDescriptor ) )
|
if ( !(componentSetDescriptor instanceof MavenPluginDescriptor) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -214,7 +207,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
public boolean isPluginInstalled( String pluginId )
|
public boolean isPluginInstalled( String pluginId )
|
||||||
{
|
{
|
||||||
return ( pluginDescriptors.get( pluginId ) != null );
|
return (pluginDescriptors.get( pluginId ) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPluginId( String goalName )
|
private String getPluginId( String goalName )
|
||||||
|
@ -227,14 +220,14 @@ public class DefaultPluginManager
|
||||||
return goalName;
|
return goalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verifyPluginForGoal( String goalName )
|
public void verifyPluginForGoal( String goalName ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
String pluginId = getPluginId( goalName );
|
String pluginId = getPluginId( goalName );
|
||||||
|
|
||||||
if ( !isPluginInstalled( pluginId ) )
|
if ( !isPluginInstalled( pluginId ) )
|
||||||
{
|
{
|
||||||
//!! This is entirely crappy. We need a better naming for plugin artifact ids and
|
//!! This is entirely crappy. We need a better naming for plugin
|
||||||
|
// artifact ids and
|
||||||
// we definitely need better version extraction support.
|
// we definitely need better version extraction support.
|
||||||
|
|
||||||
String artifactId = "maven-" + pluginId + "-plugin";
|
String artifactId = "maven-" + pluginId + "-plugin";
|
||||||
|
@ -244,47 +237,43 @@ public class DefaultPluginManager
|
||||||
Artifact pluginArtifact = new DefaultArtifact( "maven", artifactId, version, "plugin", "jar" );
|
Artifact pluginArtifact = new DefaultArtifact( "maven", artifactId, version, "plugin", "jar" );
|
||||||
|
|
||||||
addPlugin( pluginArtifact );
|
addPlugin( pluginArtifact );
|
||||||
|
|
||||||
|
// Now, we need to resolve the plugins for this goal's prereqs.
|
||||||
|
MojoDescriptor mojoDescriptor = getMojoDescriptor( goalName );
|
||||||
|
|
||||||
|
List prereqs = mojoDescriptor.getPrereqs();
|
||||||
|
|
||||||
|
if ( prereqs != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = prereqs.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
String prereq = (String) it.next();
|
||||||
|
|
||||||
|
verifyPluginForGoal( prereq );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlugin( Artifact pluginArtifact )
|
public void addPlugin( Artifact pluginArtifact ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
|
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
|
||||||
|
|
||||||
MavenMetadataSource sr = new MavenMetadataSource( remotePluginRepositories,
|
MavenMetadataSource sr = new MavenMetadataSource( remotePluginRepositories, localRepository, artifactResolver );
|
||||||
localRepository,
|
|
||||||
artifactResolver );
|
|
||||||
|
|
||||||
String[] excludes = new String[]
|
String[] excludes = new String[] { "maven-core", "maven-artifact", "maven-model", "maven-plugin", "plexus",
|
||||||
{
|
"xstream", "xpp3", "classworlds", "ognl" };
|
||||||
"maven-core",
|
|
||||||
"maven-artifact",
|
|
||||||
"maven-model",
|
|
||||||
"maven-plugin",
|
|
||||||
"plexus",
|
|
||||||
"xstream",
|
|
||||||
"xpp3",
|
|
||||||
"classworlds",
|
|
||||||
"ognl"
|
|
||||||
};
|
|
||||||
|
|
||||||
container.addComponent( pluginArtifact,
|
container.addComponent( pluginArtifact, artifactResolver, remotePluginRepositories, localRepository, sr,
|
||||||
artifactResolver,
|
excludes );
|
||||||
remotePluginRepositories,
|
|
||||||
localRepository,
|
|
||||||
sr,
|
|
||||||
excludes );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void contextualize( Context context )
|
public void contextualize( Context context ) throws ContextException
|
||||||
throws ContextException
|
|
||||||
{
|
{
|
||||||
container = (ArtifactEnabledContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
container = (ArtifactEnabledContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize()
|
public void initialize() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
//!! move this to be configurable from the Maven component
|
//!! move this to be configurable from the Maven component
|
||||||
remotePluginRepositories = new HashSet();
|
remotePluginRepositories = new HashSet();
|
||||||
|
@ -303,4 +292,3 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<role>org.codehaus.plexus.i18n.I18N</role>
|
<role>org.codehaus.plexus.i18n.I18N</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
<requirement>
|
<requirement>
|
||||||
<role>org.apache.maven.lifecycle.goal.MavenGoalPhaseManager</role>
|
<role>org.apache.maven.lifecycle.session.MavenSessionPhaseManager</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
@ -30,12 +30,7 @@
|
||||||
<implementation>org.apache.maven.lifecycle.session.DefaultMavenSessionPhaseManager</implementation>
|
<implementation>org.apache.maven.lifecycle.session.DefaultMavenSessionPhaseManager</implementation>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycle-phases>
|
<lifecycle-phases>
|
||||||
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.PluginDownloadPhase"/>
|
<lifecycle-phase implementation="org.apache.maven.lifecycle.session.phase.GoalExecutionPhase"/>
|
||||||
<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>
|
</lifecycle-phases>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
@ -44,8 +39,6 @@
|
||||||
<implementation>org.apache.maven.lifecycle.goal.DefaultMavenGoalPhaseManager</implementation>
|
<implementation>org.apache.maven.lifecycle.goal.DefaultMavenGoalPhaseManager</implementation>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycle-phases>
|
<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.GoalResolutionPhase"/>
|
||||||
<lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyResolutionPhase"/>
|
<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.DependencyDownloadPhase"/>
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class MavenTestCase
|
public class MavenTestCase
|
||||||
|
@ -43,18 +43,32 @@ public class MavenTestCase
|
||||||
|
|
||||||
protected MavenProjectBuilder projectBuilder;
|
protected MavenProjectBuilder projectBuilder;
|
||||||
|
|
||||||
protected void setUp()
|
protected String testRepoUrl;
|
||||||
throws Exception
|
|
||||||
|
protected void setUp() throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
File testRepoLocation = new File( "target/repo" );
|
||||||
|
if ( !testRepoLocation.exists() )
|
||||||
|
{
|
||||||
|
testRepoLocation.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
testRepoUrl = testRepoLocation.toURL().toExternalForm();
|
||||||
|
testRepoUrl = testRepoUrl.substring( 0, testRepoUrl.length() - 1 );
|
||||||
|
|
||||||
pluginManager = (PluginManager) lookup( PluginManager.ROLE );
|
pluginManager = (PluginManager) lookup( PluginManager.ROLE );
|
||||||
|
|
||||||
projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void customizeContext()
|
protected String getTestRepoURL()
|
||||||
throws Exception
|
{
|
||||||
|
return testRepoUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void customizeContext() throws Exception
|
||||||
{
|
{
|
||||||
ClassWorld classWorld = new ClassWorld();
|
ClassWorld classWorld = new ClassWorld();
|
||||||
|
|
||||||
|
@ -64,31 +78,28 @@ public class MavenTestCase
|
||||||
|
|
||||||
getContainer().addContextValue( "maven.home", new File( getBasedir(), "target/maven.home" ).getPath() );
|
getContainer().addContextValue( "maven.home", new File( getBasedir(), "target/maven.home" ).getPath() );
|
||||||
|
|
||||||
getContainer().addContextValue( "maven.home.local", new File( getBasedir(), "target/maven.home.local" ).getPath() );
|
getContainer().addContextValue( "maven.home.local",
|
||||||
|
new File( getBasedir(), "target/maven.home.local" ).getPath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MavenGoalExecutionContext createGoalExecutionContext()
|
protected MavenGoalExecutionContext createGoalExecutionContext() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return createGoalExecutionContext( null, null );
|
return createGoalExecutionContext( null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MavenGoalExecutionContext createGoalExecutionContext( File pom )
|
protected MavenGoalExecutionContext createGoalExecutionContext( File pom ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return createGoalExecutionContext( pom, null );
|
return createGoalExecutionContext( pom, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MavenGoalExecutionContext createGoalExecutionContext( String goal )
|
protected MavenGoalExecutionContext createGoalExecutionContext( String goal ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return createGoalExecutionContext( null, goal );
|
return createGoalExecutionContext( null, goal );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MavenGoalExecutionContext createGoalExecutionContext( File pom, String goal )
|
protected MavenGoalExecutionContext createGoalExecutionContext( File pom, String goal ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
ArtifactRepository localRepository = new ArtifactRepository( "local", "file://" );
|
ArtifactRepository localRepository = new ArtifactRepository( "local", testRepoUrl );
|
||||||
|
|
||||||
MavenProject project;
|
MavenProject project;
|
||||||
|
|
||||||
|
@ -103,12 +114,20 @@ public class MavenTestCase
|
||||||
project = projectBuilder.build( f, localRepository );
|
project = projectBuilder.build( f, localRepository );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return createGoalExecutionContext( project, localRepository, goal );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MavenGoalExecutionContext createGoalExecutionContext( MavenProject project,
|
||||||
|
ArtifactRepository localRepository, String goal )
|
||||||
|
{
|
||||||
project.setProperty( "foo", "bar" );
|
project.setProperty( "foo", "bar" );
|
||||||
|
|
||||||
List goals = new ArrayList();
|
List goals = new ArrayList();
|
||||||
|
|
||||||
MavenSession session = new MavenSession( getContainer(), pluginManager, project, localRepository, goals );
|
MavenSession session = new MavenSession( getContainer(), pluginManager, project, localRepository, goals );
|
||||||
|
|
||||||
|
pluginManager.setLocalRepository( localRepository );
|
||||||
|
|
||||||
MojoDescriptor descriptor;
|
MojoDescriptor descriptor;
|
||||||
|
|
||||||
if ( goal != null )
|
if ( goal != null )
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
/* Created on Jul 14, 2004 */
|
|
||||||
package org.apache.maven.decoration;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 junit.framework.TestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jdcasey
|
|
||||||
*/
|
|
||||||
public class DefaultGoalDecoratorTest extends TestCase {
|
|
||||||
|
|
||||||
public void testShouldConstructWithTargetGoalAndDecoratorGoal() {
|
|
||||||
new DefaultGoalDecorator("compiler:compile", "compiler:init");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldRetrieveTargetGoal() {
|
|
||||||
DefaultGoalDecorator decorator = new DefaultGoalDecorator("compiler:compile", "compiler:init");
|
|
||||||
|
|
||||||
assertEquals("compiler:compile", decorator.getGoalToDecorate());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldRetrieveDecoratorGoal() {
|
|
||||||
DefaultGoalDecorator decorator = new DefaultGoalDecorator("compiler:compile", "compiler:init");
|
|
||||||
|
|
||||||
assertEquals("compiler:init", decorator.getDecoratorGoal());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
/* Created on Jul 14, 2004 */
|
|
||||||
package org.apache.maven.decoration;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jdcasey
|
|
||||||
*/
|
|
||||||
public class GoalDecorationParserTest extends TestCase {
|
|
||||||
|
|
||||||
private static final String SCRIPT_WITH_ONE_PREGOAL_NO_DEFAULT_GOAL =
|
|
||||||
"<decorators>" +
|
|
||||||
"<preGoal name=\"compiler:compile\" attain=\"compiler:init\"/>" +
|
|
||||||
"</decorators>";
|
|
||||||
|
|
||||||
private static final String SCRIPT_WITH_ONE_POSTGOAL_NO_DEFAULT_GOAL =
|
|
||||||
"<decorators>" +
|
|
||||||
"<postGoal name=\"compiler:compile\" attain=\"compiler:init\"/>" +
|
|
||||||
"</decorators>";
|
|
||||||
|
|
||||||
private static final String SCRIPT_WITH_DEFAULT_GOAL_NO_DECORATORS =
|
|
||||||
"<decorators defaultGoal=\"jar:jar\"/>";
|
|
||||||
|
|
||||||
private static final String SCRIPT_WITH_ONE_POSTGOAL_ONE_PREGOAL_AND_DEFAULT_GOAL =
|
|
||||||
"<decorators defaultGoal=\"jar:jar\">" +
|
|
||||||
"<preGoal name=\"compiler:compile\" attain=\"compiler:init\"/>" +
|
|
||||||
"<postGoal name=\"compiler:compile\" attain=\"jar:initFS\"/>" +
|
|
||||||
"</decorators>";
|
|
||||||
|
|
||||||
public void testShouldConstructWithNoArgs() {
|
|
||||||
new GoalDecorationParser();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldParseOnePreGoalNoPostGoalsNoDefaultGoal() throws XmlPullParserException, IOException {
|
|
||||||
GoalDecoratorBindings bindings = parse(SCRIPT_WITH_ONE_POSTGOAL_ONE_PREGOAL_AND_DEFAULT_GOAL);
|
|
||||||
|
|
||||||
assertEquals(1, bindings.getPreGoals("compiler:compile").size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldParseNoPreGoalsOnePostGoalNoDefaultGoal() throws XmlPullParserException, IOException {
|
|
||||||
GoalDecoratorBindings bindings = parse(SCRIPT_WITH_ONE_POSTGOAL_ONE_PREGOAL_AND_DEFAULT_GOAL);
|
|
||||||
|
|
||||||
assertEquals(1, bindings.getPostGoals("compiler:compile").size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldParseNoPreGoalsNoPostGoalsWithDefaultGoal() throws XmlPullParserException, IOException {
|
|
||||||
GoalDecoratorBindings bindings = parse(SCRIPT_WITH_ONE_POSTGOAL_ONE_PREGOAL_AND_DEFAULT_GOAL);
|
|
||||||
|
|
||||||
assertEquals("jar:jar", bindings.getDefaultGoal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldParseOnePreGoalOnePostGoalWithDefaultGoal() throws XmlPullParserException, IOException {
|
|
||||||
GoalDecoratorBindings bindings = parse(SCRIPT_WITH_ONE_POSTGOAL_ONE_PREGOAL_AND_DEFAULT_GOAL);
|
|
||||||
|
|
||||||
assertEquals("jar:jar", bindings.getDefaultGoal());
|
|
||||||
assertEquals(1, bindings.getPreGoals("compiler:compile").size());
|
|
||||||
assertEquals(1, bindings.getPostGoals("compiler:compile").size());
|
|
||||||
}
|
|
||||||
|
|
||||||
private GoalDecoratorBindings parse(String inputString) throws XmlPullParserException, IOException {
|
|
||||||
GoalDecorationParser parser = new GoalDecorationParser();
|
|
||||||
StringReader reader = new StringReader(inputString);
|
|
||||||
|
|
||||||
return parser.parse(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
/* Created on Jul 14, 2004 */
|
|
||||||
package org.apache.maven.decoration;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 junit.framework.TestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jdcasey
|
|
||||||
*/
|
|
||||||
public class GoalDecoratorBindingsTest extends TestCase {
|
|
||||||
|
|
||||||
public void testShouldConstructWithNoArguments() {
|
|
||||||
new GoalDecoratorBindings();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldAddOnePreGoalAndRetrievePreGoalsListOfSizeOne() {
|
|
||||||
String targetGoal = "compiler:compile";
|
|
||||||
|
|
||||||
DefaultGoalDecorator decorator = new DefaultGoalDecorator(targetGoal, "compiler:init");
|
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
|
||||||
bindings.addPreGoal(decorator);
|
|
||||||
|
|
||||||
assertEquals(1, bindings.getPreGoals(targetGoal).size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldAddOnePostGoalAndRetrievePostGoalsListOfSizeOne() {
|
|
||||||
String targetGoal = "compiler:compile";
|
|
||||||
|
|
||||||
DefaultGoalDecorator decorator = new DefaultGoalDecorator(targetGoal, "compiler:init");
|
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
|
||||||
bindings.addPostGoal(decorator);
|
|
||||||
|
|
||||||
assertEquals(1, bindings.getPostGoals(targetGoal).size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldAddTwoPreGoalsAndRetrievePreGoalsListOfSizeTwo() {
|
|
||||||
String targetGoal = "compiler:compile";
|
|
||||||
|
|
||||||
DefaultGoalDecorator decorator = new DefaultGoalDecorator(targetGoal, "compiler:init");
|
|
||||||
DefaultGoalDecorator decorator2 = new DefaultGoalDecorator(targetGoal, "compiler:clean");
|
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
|
||||||
bindings.addPreGoal(decorator);
|
|
||||||
bindings.addPreGoal(decorator2);
|
|
||||||
|
|
||||||
assertEquals(2, bindings.getPreGoals(targetGoal).size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldAddTwoPostGoalsAndRetrievePostGoalsListOfSizeTwo() {
|
|
||||||
String targetGoal = "compiler:compile";
|
|
||||||
|
|
||||||
DefaultGoalDecorator decorator = new DefaultGoalDecorator(targetGoal, "compiler:init");
|
|
||||||
DefaultGoalDecorator decorator2 = new DefaultGoalDecorator(targetGoal, "compiler:clean");
|
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
|
||||||
bindings.addPostGoal(decorator);
|
|
||||||
bindings.addPostGoal(decorator2);
|
|
||||||
|
|
||||||
assertEquals(2, bindings.getPostGoals(targetGoal).size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldSetAndRetrieveDefaultGoal() {
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
|
||||||
bindings.setDefaultGoal("jar:jar");
|
|
||||||
|
|
||||||
assertEquals("jar:jar", bindings.getDefaultGoal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShouldGetDefaultGoalOfCompiler_CompileWhenNotExplicitlySet() {
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
|
||||||
|
|
||||||
assertEquals("compiler:compile", bindings.getDefaultGoal());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -6,19 +6,19 @@ import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
* @version $Id$
|
* @version $Id: MavenLifecycleManagerTest.java,v 1.2 2004/08/15 15:01:51
|
||||||
|
* jvanzyl Exp $
|
||||||
*/
|
*/
|
||||||
public class MavenLifecycleManagerTest
|
public class MavenLifecycleManagerTest
|
||||||
extends MavenTestCase
|
extends MavenTestCase
|
||||||
{
|
{
|
||||||
public void testMavenLifecycleManager()
|
public void testMavenLifecycleManager() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
MavenGoalPhaseManager mlm = (MavenGoalPhaseManager) lookup( MavenGoalPhaseManager.ROLE );
|
MavenGoalPhaseManager mlm = (MavenGoalPhaseManager) lookup( MavenGoalPhaseManager.ROLE );
|
||||||
|
|
||||||
List lifecyclePhases = mlm.getLifecyclePhases();
|
List lifecyclePhases = mlm.getLifecyclePhases();
|
||||||
|
|
||||||
assertEquals( 6, lifecyclePhases.size() );
|
assertEquals( 4, lifecyclePhases.size() );
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,19 @@
|
||||||
/* Created on Jul 14, 2004 */
|
/* Created on Jul 14, 2004 */
|
||||||
package org.apache.maven.lifecycle.goal.phase;
|
package org.apache.maven.lifecycle.goal.phase;
|
||||||
|
|
||||||
import org.apache.maven.decoration.DefaultGoalDecorator;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.decoration.GoalDecoratorBindings;
|
|
||||||
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
|
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
|
||||||
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.PostGoal;
|
||||||
|
import org.apache.maven.model.PreGoal;
|
||||||
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.MavenTestCase;
|
import org.apache.maven.MavenTestCase;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
@ -19,35 +25,37 @@ public class GoalResolutionPhaseTest
|
||||||
extends MavenTestCase
|
extends MavenTestCase
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
<!-- Test main with preGoal and postGoal -->
|
* <!-- Test main with preGoal and postGoal --> <mojo>
|
||||||
<mojo>
|
* <id>resolveTest:t1-preGoal </id>
|
||||||
<id>t1:preGoal</id>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </instantiationStrategy> </mojo> <mojo> <id>resolveTest:t1-main </id>
|
||||||
</mojo>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<mojo>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<id>t1:main</id>
|
* </instantiationStrategy> </mojo> <mojo> <id>resolveTest:t1-postGoal </id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
</mojo>
|
* </instantiationStrategy> </mojo> <!-- End of test -->
|
||||||
<mojo>
|
*/
|
||||||
<id>t1:postGoal</id>
|
public void testT1_ShouldFind_PreGoal_MainGoal_PostGoal() throws Exception
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
|
||||||
</mojo>
|
|
||||||
<!-- End of test -->
|
|
||||||
*/
|
|
||||||
public void testT1_ShouldFind_PreGoal_MainGoal_PostGoal()
|
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
String mainGoal = "t1:main";
|
String mainGoal = "resolveTest:t1-main";
|
||||||
String preGoal = "t1:preGoal";
|
String preGoal = "resolveTest:t1-preGoal";
|
||||||
String postGoal = "t1:postGoal";
|
String postGoal = "resolveTest:t1-postGoal";
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
PreGoal pg = new PreGoal();
|
||||||
|
pg.setAttain( preGoal );
|
||||||
|
pg.setName( mainGoal );
|
||||||
|
|
||||||
bindings.addPreGoal( new DefaultGoalDecorator( mainGoal, preGoal ) );
|
List preGoals = new LinkedList();
|
||||||
bindings.addPostGoal( new DefaultGoalDecorator( mainGoal, postGoal ) );
|
preGoals.add( pg );
|
||||||
|
|
||||||
|
PostGoal pog = new PostGoal();
|
||||||
|
pog.setAttain( postGoal );
|
||||||
|
pog.setName( mainGoal );
|
||||||
|
|
||||||
|
List postGoals = new LinkedList();
|
||||||
|
postGoals.add( pog );
|
||||||
|
|
||||||
Map messages = new TreeMap();
|
Map messages = new TreeMap();
|
||||||
|
|
||||||
|
@ -61,33 +69,23 @@ public class GoalResolutionPhaseTest
|
||||||
order.add( mainGoal );
|
order.add( mainGoal );
|
||||||
order.add( postGoal );
|
order.add( postGoal );
|
||||||
|
|
||||||
runTest( mainGoal, bindings, order, messages );
|
runTest( mainGoal, preGoals, postGoals, order, messages );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<!-- Test main with prereq -->
|
* <!-- Test main with prereq --> <mojo> <id>resolveTest:t2-prereq </id>
|
||||||
<mojo>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<id>t2:prereq</id>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* </instantiationStrategy> </mojo> <mojo> <id>resolveTest:t2-main </id>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
</mojo>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<mojo>
|
* </instantiationStrategy> <prereqs> <prereq>resolveTest:t2-prereq
|
||||||
<id>t2:main</id>
|
* </prereq> </prereqs> </mojo> <!-- End of test -->
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
*/
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
public void testT2_ShouldFind_Prereq_MainGoal() throws Exception
|
||||||
<prereqs>
|
|
||||||
<prereq>t2:prereq</prereq>
|
|
||||||
</prereqs>
|
|
||||||
</mojo>
|
|
||||||
<!-- End of test -->
|
|
||||||
*/
|
|
||||||
public void testT2_ShouldFind_Prereq_MainGoal()
|
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
String mainGoal = "t2:main";
|
String mainGoal = "resolveTest:t2-main";
|
||||||
String prereq = "t2:prereq";
|
String prereq = "resolveTest:t2-prereq";
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
|
||||||
|
|
||||||
Map messages = new TreeMap();
|
Map messages = new TreeMap();
|
||||||
|
|
||||||
|
@ -99,48 +97,46 @@ public class GoalResolutionPhaseTest
|
||||||
order.add( prereq );
|
order.add( prereq );
|
||||||
order.add( mainGoal );
|
order.add( mainGoal );
|
||||||
|
|
||||||
runTest( mainGoal, bindings, order, messages );
|
runTest( mainGoal, Collections.EMPTY_LIST, Collections.EMPTY_LIST, order, messages );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<!-- Test main with prereq, preGoal and postGoal -->
|
* <!-- Test main with prereq, preGoal and postGoal --> <mojo>
|
||||||
<mojo>
|
* <id>resolveTest:t3-preGoal </id>
|
||||||
<id>t3:preGoal</id>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </instantiationStrategy> </mojo> <mojo> <id>resolveTest:t3-prereq </id>
|
||||||
</mojo>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<mojo>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<id>t3:prereq</id>
|
* </instantiationStrategy> </mojo> <mojo> <id>resolveTest:t3-main </id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
</mojo>
|
* </instantiationStrategy> <prereqs> <prereq>resolveTest:t3-prereq
|
||||||
<mojo>
|
* </prereq> </prereqs> </mojo> <mojo> <id>resolveTest:t3-postGoal </id>
|
||||||
<id>t3:main</id>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </instantiationStrategy> </mojo> <!-- End of test -->
|
||||||
<prereqs>
|
*/
|
||||||
<prereq>t3:prereq</prereq>
|
public void testT3_ShouldFind_PreGoal_Prereq_MainGoal_PostGoal() throws Exception
|
||||||
</prereqs>
|
|
||||||
</mojo>
|
|
||||||
<mojo>
|
|
||||||
<id>t3:postGoal</id>
|
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
|
||||||
</mojo>
|
|
||||||
<!-- End of test -->
|
|
||||||
*/
|
|
||||||
public void testT3_ShouldFind_PreGoal_Prereq_MainGoal_PostGoal()
|
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
String mainGoal = "t3:main";
|
String mainGoal = "resolveTest:t3-main";
|
||||||
String prereq = "t3:prereq";
|
String prereq = "resolveTest:t3-prereq";
|
||||||
String preGoal = "t3:preGoal";
|
String preGoal = "resolveTest:t3-preGoal";
|
||||||
String postGoal = "t3:postGoal";
|
String postGoal = "resolveTest:t3-postGoal";
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
PreGoal pg = new PreGoal();
|
||||||
|
pg.setAttain( preGoal );
|
||||||
|
pg.setName( mainGoal );
|
||||||
|
|
||||||
bindings.addPreGoal( new DefaultGoalDecorator( mainGoal, preGoal ) );
|
List preGoals = new LinkedList();
|
||||||
bindings.addPostGoal( new DefaultGoalDecorator( mainGoal, postGoal ) );
|
preGoals.add( pg );
|
||||||
|
|
||||||
|
PostGoal pog = new PostGoal();
|
||||||
|
pog.setAttain( postGoal );
|
||||||
|
pog.setName( mainGoal );
|
||||||
|
|
||||||
|
List postGoals = new LinkedList();
|
||||||
|
postGoals.add( pog );
|
||||||
|
|
||||||
Map messages = new TreeMap();
|
Map messages = new TreeMap();
|
||||||
|
|
||||||
|
@ -156,48 +152,47 @@ public class GoalResolutionPhaseTest
|
||||||
order.add( mainGoal );
|
order.add( mainGoal );
|
||||||
order.add( postGoal );
|
order.add( postGoal );
|
||||||
|
|
||||||
runTest( mainGoal, bindings, order, messages );
|
runTest( mainGoal, preGoals, postGoals, order, messages );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<!-- Test main with prereq which has preGoal and postGoal -->
|
* <!-- Test main with prereq which has preGoal and postGoal --> <mojo>
|
||||||
<mojo>
|
* <id>resolveTest:t4-prereq-preGoal </id>
|
||||||
<id>t4:prereq-preGoal</id>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </instantiationStrategy> </mojo> <mojo> <id>resolveTest:t4-prereq </id>
|
||||||
</mojo>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<mojo>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<id>t4:prereq</id>
|
* </instantiationStrategy> </mojo> <mojo> <id>resolveTest:t4-main </id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
</mojo>
|
* </instantiationStrategy> <prereqs> <prereq>resolveTest:t4-prereq
|
||||||
<mojo>
|
* </prereq> </prereqs> </mojo> <mojo> <id>resolveTest:t4-prereq-postGoal
|
||||||
<id>t4:main</id>
|
* </id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<prereqs>
|
* </instantiationStrategy> </mojo> <!-- End of test -->
|
||||||
<prereq>t4:prereq</prereq>
|
*/
|
||||||
</prereqs>
|
public void testT4_ShouldFind_PreGoal_Prereq_PostGoal_MainGoal() throws Exception
|
||||||
</mojo>
|
|
||||||
<mojo>
|
|
||||||
<id>t4:prereq-postGoal</id>
|
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
|
||||||
</mojo>
|
|
||||||
<!-- End of test -->
|
|
||||||
*/
|
|
||||||
public void testT4_ShouldFind_PreGoal_Prereq_PostGoal_MainGoal()
|
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
String mainGoal = "t4:main";
|
String mainGoal = "resolveTest:t4-main";
|
||||||
String prereq = "t4:prereq";
|
String prereq = "resolveTest:t4-prereq";
|
||||||
String preGoal = "t4:prereq-preGoal";
|
String preGoal = "resolveTest:t4-prereq-preGoal";
|
||||||
String postGoal = "t4:prereq-postGoal";
|
String postGoal = "resolveTest:t4-prereq-postGoal";
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
PreGoal pg = new PreGoal();
|
||||||
|
pg.setAttain( preGoal );
|
||||||
|
pg.setName( prereq );
|
||||||
|
|
||||||
bindings.addPreGoal( new DefaultGoalDecorator( prereq, preGoal ) );
|
List preGoals = new LinkedList();
|
||||||
bindings.addPostGoal( new DefaultGoalDecorator( prereq, postGoal ) );
|
preGoals.add( pg );
|
||||||
|
|
||||||
|
PostGoal pog = new PostGoal();
|
||||||
|
pog.setAttain( postGoal );
|
||||||
|
pog.setName( prereq );
|
||||||
|
|
||||||
|
List postGoals = new LinkedList();
|
||||||
|
postGoals.add( pog );
|
||||||
|
|
||||||
Map messages = new TreeMap();
|
Map messages = new TreeMap();
|
||||||
|
|
||||||
|
@ -213,44 +208,36 @@ public class GoalResolutionPhaseTest
|
||||||
order.add( postGoal );
|
order.add( postGoal );
|
||||||
order.add( mainGoal );
|
order.add( mainGoal );
|
||||||
|
|
||||||
runTest( mainGoal, bindings, order, messages );
|
runTest( mainGoal, preGoals, postGoals, order, messages );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<!-- Test main with prereq and preGoal which has the same prereq -->
|
* <!-- Test main with prereq and preGoal which has the same prereq -->
|
||||||
<mojo>
|
* <mojo> <id>resolveTest:t5-prereq </id>
|
||||||
<id>t5:prereq</id>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* </instantiationStrategy> </mojo> <mojo> <id>resolveTest:t5-preGoal </id>
|
||||||
</mojo>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<mojo>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<id>t5:preGoal</id>
|
* </instantiationStrategy> <prereqs> <prereq>resolveTest:t5-prereq
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
* </prereq> </prereqs> </mojo> <mojo> <id>resolveTest:t5-main </id>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
* <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin
|
||||||
<prereqs>
|
* </implementation> <instantiationStrategy>singleton
|
||||||
<prereq>t5:prereq</prereq>
|
* </instantiationStrategy> <prereqs> <prereq>resolveTest:t5-prereq
|
||||||
</prereqs>
|
* </prereq> </prereqs> </mojo> <!-- End of test -->
|
||||||
</mojo>
|
*/
|
||||||
<mojo>
|
public void testT5_ShouldFind_Prereq_PreGoal_MainGoal() throws Exception
|
||||||
<id>t5:main</id>
|
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
|
||||||
<prereqs>
|
|
||||||
<prereq>t5:prereq</prereq>
|
|
||||||
</prereqs>
|
|
||||||
</mojo>
|
|
||||||
<!-- End of test -->
|
|
||||||
*/
|
|
||||||
public void testT5_ShouldFind_Prereq_PreGoal_MainGoal()
|
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
String mainGoal = "t5:main";
|
String mainGoal = "resolveTest:t5-main";
|
||||||
String prereq = "t5:prereq";
|
String prereq = "resolveTest:t5-prereq";
|
||||||
String preGoal = "t5:preGoal";
|
String preGoal = "resolveTest:t5-preGoal";
|
||||||
|
|
||||||
GoalDecoratorBindings bindings = new GoalDecoratorBindings();
|
PreGoal pg = new PreGoal();
|
||||||
|
pg.setAttain( preGoal );
|
||||||
|
pg.setName( mainGoal );
|
||||||
|
|
||||||
bindings.addPreGoal( new DefaultGoalDecorator( mainGoal, preGoal ) );
|
List preGoals = new LinkedList();
|
||||||
|
preGoals.add( pg );
|
||||||
|
|
||||||
Map messages = new TreeMap();
|
Map messages = new TreeMap();
|
||||||
|
|
||||||
|
@ -264,16 +251,23 @@ public class GoalResolutionPhaseTest
|
||||||
order.add( preGoal );
|
order.add( preGoal );
|
||||||
order.add( mainGoal );
|
order.add( mainGoal );
|
||||||
|
|
||||||
runTest( mainGoal, bindings, order, messages );
|
runTest( mainGoal, preGoals, Collections.EMPTY_LIST, order, messages );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runTest( String mainGoal, GoalDecoratorBindings bindings,
|
private void runTest( String mainGoal, List preGoals, List postGoals, List expectedOrder, Map messages )
|
||||||
List expectedOrder, Map messages )
|
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
MavenGoalExecutionContext context = createGoalExecutionContext( mainGoal );
|
ArtifactRepository localRepository = new ArtifactRepository( "local", getTestRepoURL() );
|
||||||
|
|
||||||
context.setGoalDecoratorBindings( bindings );
|
Model model = new Model();
|
||||||
|
model.setPreGoals( preGoals );
|
||||||
|
model.setPostGoals( postGoals );
|
||||||
|
|
||||||
|
MavenProject project = new MavenProject( model );
|
||||||
|
project.setProperties( new TreeMap() );
|
||||||
|
|
||||||
|
MavenGoalExecutionContext context = createGoalExecutionContext( project, localRepository, mainGoal );
|
||||||
|
context.setGoalName( mainGoal );
|
||||||
|
|
||||||
GoalResolutionPhase phase = new GoalResolutionPhase();
|
GoalResolutionPhase phase = new GoalResolutionPhase();
|
||||||
|
|
||||||
|
@ -281,8 +275,6 @@ public class GoalResolutionPhaseTest
|
||||||
|
|
||||||
List goals = context.getResolvedGoals();
|
List goals = context.getResolvedGoals();
|
||||||
|
|
||||||
System.out.println( "Resolved goals: " + goals );
|
|
||||||
|
|
||||||
assertNotNull( goals );
|
assertNotNull( goals );
|
||||||
|
|
||||||
assertEquals( expectedOrder.size(), goals.size() );
|
assertEquals( expectedOrder.size(), goals.size() );
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<id>decorTest</id>
|
<id>resolveTest</id>
|
||||||
<mojos>
|
<mojos>
|
||||||
<!-- Test main with preGoal and postGoal -->
|
<!-- Test main with preGoal and postGoal -->
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t1:preGoal</id>
|
<id>resolveTest:t1-preGoal</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t1:main</id>
|
<id>resolveTest:t1-main</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t1:postGoal</id>
|
<id>resolveTest:t1-postGoal</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
|
@ -21,41 +21,41 @@
|
||||||
|
|
||||||
<!-- Test main with prereq -->
|
<!-- Test main with prereq -->
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t2:prereq</id>
|
<id>resolveTest:t2-prereq</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t2:main</id>
|
<id>resolveTest:t2-main</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
<prereqs>
|
<prereqs>
|
||||||
<prereq>t2:prereq</prereq>
|
<prereq>resolveTest:t2-prereq</prereq>
|
||||||
</prereqs>
|
</prereqs>
|
||||||
</mojo>
|
</mojo>
|
||||||
<!-- End of test -->
|
<!-- End of test -->
|
||||||
|
|
||||||
<!-- Test main with prereq, preGoal and postGoal -->
|
<!-- Test main with prereq, preGoal and postGoal -->
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t3:preGoal</id>
|
<id>resolveTest:t3-preGoal</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t3:prereq</id>
|
<id>resolveTest:t3-prereq</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t3:main</id>
|
<id>resolveTest:t3-main</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
<prereqs>
|
<prereqs>
|
||||||
<prereq>t3:prereq</prereq>
|
<prereq>resolveTest:t3-prereq</prereq>
|
||||||
</prereqs>
|
</prereqs>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t3:postGoal</id>
|
<id>resolveTest:t3-postGoal</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
|
@ -63,25 +63,25 @@
|
||||||
|
|
||||||
<!-- Test main with prereq which has preGoal and postGoal -->
|
<!-- Test main with prereq which has preGoal and postGoal -->
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t4:prereq-preGoal</id>
|
<id>resolveTest:t4-prereq-preGoal</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t4:prereq</id>
|
<id>resolveTest:t4-prereq</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t4:main</id>
|
<id>resolveTest:t4-main</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
<prereqs>
|
<prereqs>
|
||||||
<prereq>t4:prereq</prereq>
|
<prereq>resolveTest:t4-prereq</prereq>
|
||||||
</prereqs>
|
</prereqs>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t4:prereq-postGoal</id>
|
<id>resolveTest:t4-prereq-postGoal</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
|
@ -90,24 +90,24 @@
|
||||||
|
|
||||||
<!-- Test main with prereq and preGoal which has the same prereq -->
|
<!-- Test main with prereq and preGoal which has the same prereq -->
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t5:prereq</id>
|
<id>resolveTest:t5-prereq</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t5:preGoal</id>
|
<id>resolveTest:t5-preGoal</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
<prereqs>
|
<prereqs>
|
||||||
<prereq>t5:prereq</prereq>
|
<prereq>resolveTest:t5-prereq</prereq>
|
||||||
</prereqs>
|
</prereqs>
|
||||||
</mojo>
|
</mojo>
|
||||||
<mojo>
|
<mojo>
|
||||||
<id>t5:main</id>
|
<id>resolveTest:t5-main</id>
|
||||||
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
<implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
|
||||||
<instantiationStrategy>singleton</instantiationStrategy>
|
<instantiationStrategy>singleton</instantiationStrategy>
|
||||||
<prereqs>
|
<prereqs>
|
||||||
<prereq>t5:prereq</prereq>
|
<prereq>resolveTest:t5-prereq</prereq>
|
||||||
</prereqs>
|
</prereqs>
|
||||||
</mojo>
|
</mojo>
|
||||||
<!-- End of test -->
|
<!-- End of test -->
|
||||||
|
|
Loading…
Reference in New Issue