mirror of https://github.com/apache/maven.git
setup a simple, backwards compatible mechanism to start implementing the new plugin instantiation
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163624 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5a296f03c8
commit
b80f5242b2
|
@ -329,9 +329,7 @@ public class DefaultPluginManager
|
|||
throw new PluginExecutionException( "Unable to execute goal: " + goalName, e );
|
||||
}
|
||||
|
||||
PluginExecutionRequest request;
|
||||
|
||||
PluginExecutionResponse response;
|
||||
PluginExecutionRequest request = null;
|
||||
|
||||
MojoDescriptor mojoDescriptor = getMojoDescriptor( goalName );
|
||||
if ( mojoDescriptor == null )
|
||||
|
@ -374,15 +372,6 @@ public class DefaultPluginManager
|
|||
throw new PluginExecutionException( "Unable to resolve required dependencies for goal", e );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
request = new PluginExecutionRequest( createParameters( mojoDescriptor, session ) );
|
||||
}
|
||||
catch ( PluginConfigurationException e )
|
||||
{
|
||||
throw new PluginExecutionException( "Error configuring plugin for execution.", e );
|
||||
}
|
||||
|
||||
Plugin plugin = null;
|
||||
|
||||
try
|
||||
|
@ -391,6 +380,15 @@ public class DefaultPluginManager
|
|||
|
||||
plugin.setLog( session.getLog() );
|
||||
|
||||
if ( plugin.supportsNewMojoParadigm() )
|
||||
{
|
||||
// TODO: construct request
|
||||
}
|
||||
else
|
||||
{
|
||||
request = new PluginExecutionRequest( createParameters( mojoDescriptor, session ) );
|
||||
}
|
||||
|
||||
// !! This is ripe for refactoring to an aspect.
|
||||
// Event monitoring.
|
||||
String event = MavenEvents.MOJO_EXECUTION;
|
||||
|
@ -399,7 +397,14 @@ public class DefaultPluginManager
|
|||
dispatcher.dispatchStart( event, goalName );
|
||||
try
|
||||
{
|
||||
plugin.execute( request );
|
||||
if ( plugin.supportsNewMojoParadigm() )
|
||||
{
|
||||
plugin.execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.execute( request );
|
||||
}
|
||||
|
||||
dispatcher.dispatchEnd( event, goalName );
|
||||
}
|
||||
|
@ -411,6 +416,10 @@ public class DefaultPluginManager
|
|||
// End event monitoring.
|
||||
|
||||
}
|
||||
catch ( PluginConfigurationException e )
|
||||
{
|
||||
throw new PluginExecutionException( "Error configuring plugin for execution.", e );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new PluginExecutionException( "Error looking up plugin: ", e );
|
||||
|
|
|
@ -29,6 +29,7 @@ public abstract class AbstractPlugin
|
|||
|
||||
/**
|
||||
* Default behaviour to mimic old behaviour.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public void execute( PluginExecutionRequest request )
|
||||
|
@ -64,9 +65,9 @@ public abstract class AbstractPlugin
|
|||
|
||||
public Log getLog()
|
||||
{
|
||||
synchronized(this)
|
||||
synchronized ( this )
|
||||
{
|
||||
if(log == null)
|
||||
if ( log == null )
|
||||
{
|
||||
log = new SystemStreamLog();
|
||||
}
|
||||
|
@ -74,4 +75,16 @@ public abstract class AbstractPlugin
|
|||
|
||||
return log;
|
||||
}
|
||||
|
||||
public void execute()
|
||||
throws PluginExecutionException
|
||||
{
|
||||
if ( supportsNewMojoParadigm() )
|
||||
throw new PluginExecutionException( "You must override execute() if you implement the new paradigm" );
|
||||
}
|
||||
|
||||
public boolean supportsNewMojoParadigm()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,16 @@ public interface Plugin
|
|||
{
|
||||
String ROLE = Plugin.class.getName();
|
||||
|
||||
void execute()
|
||||
throws PluginExecutionException;
|
||||
|
||||
/** @deprecated */
|
||||
void execute( PluginExecutionRequest request )
|
||||
throws PluginExecutionException;
|
||||
|
||||
// TODO: not sure about this here, and may want a getLog on here as well/instead
|
||||
void setLog( Log log );
|
||||
|
||||
/** @deprecated */
|
||||
boolean supportsNewMojoParadigm();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue