jvanzyl 2004/05/12 16:40:02
Added: maven-core/src/main/java/org/apache/maven/script
DefaultGoalDecorator.java GoalDecorator.java
MavenScript.java
Log:
o forgot some files
Revision Changes Path
1.1
maven-components/maven-core/src/main/java/org/apache/maven/script/DefaultGoalDecorator.java
Index: DefaultGoalDecorator.java
===================================================================
/* Created on Apr 6, 2004 */
package org.apache.maven.script;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
import org.codehaus.marmalade.MarmaladeScript;
import org.codehaus.marmalade.defaults.DefaultContext;
import java.util.Map;
/**
* Default implementation of a goal decorator.
*
* @author <a href="mailto:[EMAIL PROTECTED]">John Casey</a>
*/
public class DefaultGoalDecorator implements GoalDecorator
{
private String goal;
private MarmaladeScript script;
public DefaultGoalDecorator( String goal, MarmaladeScript script )
{
this.goal = goal;
this.script = script;
}
public String getGoal()
{
return goal;
}
public MarmaladeScript getScript()
{
return script;
}
public void execute( PluginExecutionRequest request, PluginExecutionResponse
response )
{
Map params = request.getParameters();
DefaultContext ctx = new DefaultContext( params );
try
{
script.execute( ctx );
}
catch ( Exception e )
{
response.setException( e );
}
}
}
1.1
maven-components/maven-core/src/main/java/org/apache/maven/script/GoalDecorator.java
Index: GoalDecorator.java
===================================================================
/* Created on Apr 5, 2004 */
package org.apache.maven.script;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
/**
* 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:[EMAIL PROTECTED]">John Casey</a>
*/
public interface GoalDecorator
{
String getGoal();
void execute( PluginExecutionRequest request, PluginExecutionResponse response );
}
1.1
maven-components/maven-core/src/main/java/org/apache/maven/script/MavenScript.java
Index: MavenScript.java
===================================================================
/* Created on Apr 9, 2004 */
package org.apache.maven.script;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author jdcasey
*/
public class MavenScript
{
public static final String PARSE_CTX_KEY = "maven-script";
private Map preGoals = new HashMap();
private Map postGoals = new HashMap();
private String defaultGoal = "jar:jar";
/**
*/
public MavenScript()
{
}
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.getGoal();
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;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]