mirror of
https://github.com/apache/maven.git
synced 2025-02-08 11:05:37 +00:00
o Added first-pass logging and event-monitoring impls. Converted all System.out calls in maven-component plugins to use logger.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163457 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c42b64caf
commit
dfbae27c44
@ -21,6 +21,11 @@
|
|||||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- maven component -->
|
<!-- maven component -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven-model</artifactId>
|
<artifactId>maven-model</artifactId>
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||||
import org.apache.maven.lifecycle.goal.GoalNotFoundException;
|
import org.apache.maven.lifecycle.goal.GoalNotFoundException;
|
||||||
import org.apache.maven.lifecycle.session.MavenSessionPhaseManager;
|
import org.apache.maven.lifecycle.session.MavenSessionPhaseManager;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
import org.apache.maven.monitor.event.MavenEvents;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
@ -103,7 +105,26 @@ public MavenExecutionResponse handleProject( MavenExecutionRequest request )
|
|||||||
|
|
||||||
resolveParameters( request );
|
resolveParameters( request );
|
||||||
|
|
||||||
MavenExecutionResponse response = lifecycleExecutor.execute( request.getGoals(), session );
|
// !! This is ripe for refactoring to an aspect.
|
||||||
|
// Event monitoring.
|
||||||
|
EventDispatcher dispatcher = request.getEventDispatcher();
|
||||||
|
String event = MavenEvents.PROJECT_EXECUTION;
|
||||||
|
|
||||||
|
dispatcher.dispatchStart( event, project.getId() );
|
||||||
|
|
||||||
|
MavenExecutionResponse response = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Actual meat of the code.
|
||||||
|
response = lifecycleExecutor.execute( request.getGoals(), session );
|
||||||
|
|
||||||
|
dispatcher.dispatchEnd( event, project.getId() );
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
dispatcher.dispatchError( event, project.getId(), e );
|
||||||
|
}
|
||||||
|
// End event monitoring.
|
||||||
|
|
||||||
// TODO: is this perhaps more appropriate in the CLI?
|
// TODO: is this perhaps more appropriate in the CLI?
|
||||||
if ( response.isExecutionFailure() )
|
if ( response.isExecutionFailure() )
|
||||||
@ -133,79 +154,95 @@ public MavenExecutionResponse handleProject( MavenExecutionRequest request )
|
|||||||
public MavenExecutionResponse handleReactor( MavenReactorExecutionRequest request )
|
public MavenExecutionResponse handleReactor( MavenReactorExecutionRequest request )
|
||||||
throws ReactorException
|
throws ReactorException
|
||||||
{
|
{
|
||||||
List projects = new ArrayList();
|
EventDispatcher dispatcher = request.getEventDispatcher();
|
||||||
|
String event = MavenEvents.REACTOR_EXECUTION;
|
||||||
getLogger().info( "Starting the reactor..." );
|
|
||||||
|
|
||||||
|
dispatcher.dispatchStart( event, request.getBaseDirectory().getPath() );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List files = request.getProjectFiles();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
|
getLogger().info( "Starting the reactor..." );
|
||||||
{
|
|
||||||
File file = (File) iterator.next();
|
|
||||||
|
|
||||||
MavenProject project = getProject( file, request.getLocalRepository() );
|
|
||||||
|
|
||||||
projects.add( project );
|
|
||||||
}
|
|
||||||
|
|
||||||
projects = projectBuilder.getSortedProjects( projects );
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
|
||||||
}
|
|
||||||
catch ( ProjectBuildingException e )
|
|
||||||
{
|
|
||||||
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
|
||||||
}
|
|
||||||
catch ( CycleDetectedException e )
|
|
||||||
{
|
|
||||||
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
|
||||||
}
|
|
||||||
|
|
||||||
getLogger().info( "Our processing order:" );
|
|
||||||
|
|
||||||
for ( Iterator iterator = projects.iterator(); iterator.hasNext(); )
|
|
||||||
{
|
|
||||||
MavenProject project = (MavenProject) iterator.next();
|
|
||||||
|
|
||||||
getLogger().info( project.getName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( Iterator iterator = projects.iterator(); iterator.hasNext(); )
|
|
||||||
{
|
|
||||||
MavenProject project = (MavenProject) iterator.next();
|
|
||||||
|
|
||||||
System.out.println( "\n\n\n" );
|
|
||||||
|
|
||||||
line();
|
|
||||||
|
|
||||||
getLogger().info( "Building " + project.getName() );
|
|
||||||
|
|
||||||
line();
|
|
||||||
|
|
||||||
MavenProjectExecutionRequest projectExecutionRequest = request.createProjectExecutionRequest( project );
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MavenExecutionResponse response = handleProject( projectExecutionRequest );
|
List files = request.getProjectFiles();
|
||||||
|
|
||||||
if ( response.isExecutionFailure() )
|
for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
|
||||||
{
|
{
|
||||||
return response;
|
File file = (File) iterator.next();
|
||||||
|
|
||||||
|
MavenProject project = getProject( file, request.getLocalRepository() );
|
||||||
|
|
||||||
|
projects.add( project );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
projects = projectBuilder.getSortedProjects( projects );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new ReactorException( "Error executing project within the reactor", e );
|
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
||||||
|
}
|
||||||
|
catch ( ProjectBuildingException e )
|
||||||
|
{
|
||||||
|
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
||||||
|
}
|
||||||
|
catch ( CycleDetectedException e )
|
||||||
|
{
|
||||||
|
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
getLogger().info( "Our processing order:" );
|
||||||
|
|
||||||
// TODO: not really satisfactory
|
for ( Iterator iterator = projects.iterator(); iterator.hasNext(); )
|
||||||
return null;
|
{
|
||||||
|
MavenProject project = (MavenProject) iterator.next();
|
||||||
|
|
||||||
|
getLogger().info( project.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator iterator = projects.iterator(); iterator.hasNext(); )
|
||||||
|
{
|
||||||
|
MavenProject project = (MavenProject) iterator.next();
|
||||||
|
|
||||||
|
System.out.println( "\n\n\n" );
|
||||||
|
|
||||||
|
line();
|
||||||
|
|
||||||
|
getLogger().info( "Building " + project.getName() );
|
||||||
|
|
||||||
|
line();
|
||||||
|
|
||||||
|
MavenProjectExecutionRequest projectExecutionRequest = request.createProjectExecutionRequest( project );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MavenExecutionResponse response = handleProject( projectExecutionRequest );
|
||||||
|
|
||||||
|
if ( response.isExecutionFailure() )
|
||||||
|
{
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
throw new ReactorException( "Error executing project within the reactor", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatcher.dispatchEnd( event, request.getBaseDirectory().getPath() );
|
||||||
|
|
||||||
|
// TODO: not really satisfactory
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch ( ReactorException e )
|
||||||
|
{
|
||||||
|
dispatcher.dispatchError( event, request.getBaseDirectory().getPath(), e );
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MavenProject getProject( File pom, ArtifactRepository localRepository )
|
public MavenProject getProject( File pom, ArtifactRepository localRepository )
|
||||||
@ -232,7 +269,7 @@ public MavenProject getProject( File pom, ArtifactRepository localRepository )
|
|||||||
|
|
||||||
protected MavenSession createSession( MavenExecutionRequest request )
|
protected MavenSession createSession( MavenExecutionRequest request )
|
||||||
{
|
{
|
||||||
return new MavenSession( container, pluginManager, request.getLocalRepository(), request.getGoals() );
|
return new MavenSession( container, pluginManager, request.getLocalRepository(), request.getEventDispatcher(), request.getLog(), request.getGoals() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,8 +33,13 @@
|
|||||||
import org.apache.maven.execution.MavenInitializingExecutionRequest;
|
import org.apache.maven.execution.MavenInitializingExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenProjectExecutionRequest;
|
import org.apache.maven.execution.MavenProjectExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenReactorExecutionRequest;
|
import org.apache.maven.execution.MavenReactorExecutionRequest;
|
||||||
|
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||||
|
import org.apache.maven.monitor.event.DefaultEventMonitor;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
import org.apache.maven.monitor.logging.DefaultLog;
|
||||||
import org.codehaus.classworlds.ClassWorld;
|
import org.codehaus.classworlds.ClassWorld;
|
||||||
import org.codehaus.plexus.embed.ArtifactEnabledEmbedder;
|
import org.codehaus.plexus.embed.ArtifactEnabledEmbedder;
|
||||||
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -109,6 +114,8 @@ public static int main( String[] args, ClassWorld classWorld )
|
|||||||
|
|
||||||
File projectFile = new File( userDir, POMv4 );
|
File projectFile = new File( userDir, POMv4 );
|
||||||
|
|
||||||
|
EventDispatcher eventDispatcher = new DefaultEventDispatcher();
|
||||||
|
|
||||||
if ( projectFile.exists() )
|
if ( projectFile.exists() )
|
||||||
{
|
{
|
||||||
if ( commandLine.hasOption( CLIManager.REACTOR ) )
|
if ( commandLine.hasOption( CLIManager.REACTOR ) )
|
||||||
@ -118,6 +125,7 @@ public static int main( String[] args, ClassWorld classWorld )
|
|||||||
String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );
|
String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );
|
||||||
|
|
||||||
request = new MavenReactorExecutionRequest( localRepository,
|
request = new MavenReactorExecutionRequest( localRepository,
|
||||||
|
eventDispatcher,
|
||||||
mavenProperties,
|
mavenProperties,
|
||||||
commandLine.getArgList(),
|
commandLine.getArgList(),
|
||||||
includes,
|
includes,
|
||||||
@ -127,6 +135,7 @@ public static int main( String[] args, ClassWorld classWorld )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
request = new MavenProjectExecutionRequest( localRepository,
|
request = new MavenProjectExecutionRequest( localRepository,
|
||||||
|
eventDispatcher,
|
||||||
mavenProperties,
|
mavenProperties,
|
||||||
commandLine.getArgList(),
|
commandLine.getArgList(),
|
||||||
projectFile );
|
projectFile );
|
||||||
@ -134,7 +143,7 @@ public static int main( String[] args, ClassWorld classWorld )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
request = new MavenInitializingExecutionRequest( localRepository, mavenProperties, commandLine.getArgList() );
|
request = new MavenInitializingExecutionRequest( localRepository, eventDispatcher, mavenProperties, commandLine.getArgList() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
@ -146,6 +155,14 @@ public static int main( String[] args, ClassWorld classWorld )
|
|||||||
|
|
||||||
embedder.start( classWorld );
|
embedder.start( classWorld );
|
||||||
|
|
||||||
|
Logger logger = embedder.getContainer().getLogger();
|
||||||
|
if( logger != null )
|
||||||
|
{
|
||||||
|
request.setLog( new DefaultLog( logger ) );
|
||||||
|
|
||||||
|
request.addEventMonitor( new DefaultEventMonitor( logger ) );
|
||||||
|
}
|
||||||
|
|
||||||
// TODO [BP]: doing this here as it is CLI specific, though it doesn't feel like the right place.
|
// TODO [BP]: doing this here as it is CLI specific, though it doesn't feel like the right place.
|
||||||
WagonManager wagonManager = (WagonManager) embedder.lookup( WagonManager.ROLE );
|
WagonManager wagonManager = (WagonManager) embedder.lookup( WagonManager.ROLE );
|
||||||
|
|
||||||
|
@ -18,7 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
import org.apache.maven.monitor.event.EventMonitor;
|
||||||
|
import org.apache.maven.monitor.logging.Log;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -41,13 +44,19 @@ public abstract class AbstractMavenExecutionRequest
|
|||||||
|
|
||||||
protected MavenSession session;
|
protected MavenSession session;
|
||||||
|
|
||||||
public AbstractMavenExecutionRequest( ArtifactRepository localRepository, Properties parameters, List goals )
|
private Log log;
|
||||||
|
|
||||||
|
private EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public AbstractMavenExecutionRequest( ArtifactRepository localRepository, EventDispatcher eventDispatcher, Properties parameters, List goals )
|
||||||
{
|
{
|
||||||
this.localRepository = localRepository;
|
this.localRepository = localRepository;
|
||||||
|
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
|
|
||||||
this.goals = goals;
|
this.goals = goals;
|
||||||
|
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository getLocalRepository()
|
public ArtifactRepository getLocalRepository()
|
||||||
@ -83,4 +92,25 @@ public void setSession( MavenSession session )
|
|||||||
{
|
{
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLog(Log log)
|
||||||
|
{
|
||||||
|
this.log = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Log getLog()
|
||||||
|
{
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEventMonitor(EventMonitor monitor)
|
||||||
|
{
|
||||||
|
eventDispatcher.addEventMonitor(monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventDispatcher getEventDispatcher()
|
||||||
|
{
|
||||||
|
return eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
import org.apache.maven.monitor.event.EventMonitor;
|
||||||
|
import org.apache.maven.monitor.logging.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,4 +44,12 @@ public interface MavenExecutionRequest
|
|||||||
MavenSession getSession();
|
MavenSession getSession();
|
||||||
|
|
||||||
List getProjectFiles() throws IOException;
|
List getProjectFiles() throws IOException;
|
||||||
|
|
||||||
|
void setLog( Log log );
|
||||||
|
|
||||||
|
Log getLog();
|
||||||
|
|
||||||
|
void addEventMonitor( EventMonitor monitor );
|
||||||
|
|
||||||
|
EventDispatcher getEventDispatcher();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -29,9 +30,9 @@
|
|||||||
public class MavenInitializingExecutionRequest
|
public class MavenInitializingExecutionRequest
|
||||||
extends AbstractMavenExecutionRequest
|
extends AbstractMavenExecutionRequest
|
||||||
{
|
{
|
||||||
public MavenInitializingExecutionRequest( ArtifactRepository localRepository, Properties properties, List goals )
|
public MavenInitializingExecutionRequest( ArtifactRepository localRepository, EventDispatcher eventDispatcher, Properties properties, List goals )
|
||||||
{
|
{
|
||||||
super( localRepository, properties, goals );
|
super( localRepository, eventDispatcher, properties, goals );
|
||||||
|
|
||||||
type = "initializing";
|
type = "initializing";
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -34,11 +35,12 @@ public class MavenProjectExecutionRequest
|
|||||||
private File pom;
|
private File pom;
|
||||||
|
|
||||||
public MavenProjectExecutionRequest( ArtifactRepository localRepository,
|
public MavenProjectExecutionRequest( ArtifactRepository localRepository,
|
||||||
|
EventDispatcher eventDispatcher,
|
||||||
Properties properties,
|
Properties properties,
|
||||||
List goals,
|
List goals,
|
||||||
File pom )
|
File pom )
|
||||||
{
|
{
|
||||||
super( localRepository, properties, goals );
|
super( localRepository, eventDispatcher, properties, goals );
|
||||||
|
|
||||||
this.pom = pom;
|
this.pom = pom;
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
@ -39,10 +40,11 @@ public class MavenReactorExecutionRequest
|
|||||||
|
|
||||||
private File baseDirectory;
|
private File baseDirectory;
|
||||||
|
|
||||||
public MavenReactorExecutionRequest( ArtifactRepository localRepository, Properties properties, List goals,
|
public MavenReactorExecutionRequest( ArtifactRepository localRepository, EventDispatcher eventDispatcher,
|
||||||
String includes, String excludes, File baseDirectory )
|
Properties properties, List goals, String includes,
|
||||||
|
String excludes, File baseDirectory )
|
||||||
{
|
{
|
||||||
super( localRepository, properties, goals );
|
super( localRepository, eventDispatcher, properties, goals );
|
||||||
|
|
||||||
this.includes = includes;
|
this.includes = includes;
|
||||||
|
|
||||||
@ -76,6 +78,6 @@ public List getProjectFiles()
|
|||||||
|
|
||||||
public MavenProjectExecutionRequest createProjectExecutionRequest( MavenProject project )
|
public MavenProjectExecutionRequest createProjectExecutionRequest( MavenProject project )
|
||||||
{
|
{
|
||||||
return new MavenProjectExecutionRequest( localRepository, parameters, goals, project.getFile() );
|
return new MavenProjectExecutionRequest( localRepository, getEventDispatcher(), parameters, goals, project.getFile() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.model.PostGoal;
|
import org.apache.maven.model.PostGoal;
|
||||||
import org.apache.maven.model.PreGoal;
|
import org.apache.maven.model.PreGoal;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
import org.apache.maven.monitor.logging.Log;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.repository.RepositoryUtils;
|
import org.apache.maven.repository.RepositoryUtils;
|
||||||
@ -61,9 +63,15 @@ public class MavenSession
|
|||||||
|
|
||||||
private Map postGoalMappings;
|
private Map postGoalMappings;
|
||||||
|
|
||||||
|
private EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
private Log log;
|
||||||
|
|
||||||
public MavenSession( PlexusContainer container,
|
public MavenSession( PlexusContainer container,
|
||||||
PluginManager pluginManager,
|
PluginManager pluginManager,
|
||||||
ArtifactRepository localRepository,
|
ArtifactRepository localRepository,
|
||||||
|
EventDispatcher eventDispatcher,
|
||||||
|
Log log,
|
||||||
List goals )
|
List goals )
|
||||||
{
|
{
|
||||||
this.container = container;
|
this.container = container;
|
||||||
@ -72,6 +80,10 @@ public MavenSession( PlexusContainer container,
|
|||||||
|
|
||||||
this.localRepository = localRepository;
|
this.localRepository = localRepository;
|
||||||
|
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
|
||||||
|
this.log = log;
|
||||||
|
|
||||||
this.dag = new DAG();
|
this.dag = new DAG();
|
||||||
|
|
||||||
this.goals = goals;
|
this.goals = goals;
|
||||||
@ -159,6 +171,16 @@ public void release( Object component )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EventDispatcher getEventDispatcher()
|
||||||
|
{
|
||||||
|
return eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Log getLog()
|
||||||
|
{
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
//!! this should probably not be done here as there are request types that
|
//!! this should probably not be done here as there are request types that
|
||||||
// have no project
|
// have no project
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.goal.GoalExecutionException;
|
import org.apache.maven.lifecycle.goal.GoalExecutionException;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
import org.apache.maven.monitor.event.MavenEvents;
|
||||||
import org.apache.maven.plugin.PluginExecutionResponse;
|
import org.apache.maven.plugin.PluginExecutionResponse;
|
||||||
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;
|
||||||
@ -229,25 +231,44 @@ private void executePhase( String phase, MavenSession session, MavenExecutionRes
|
|||||||
// only execute up to the given phase
|
// only execute up to the given phase
|
||||||
int index = phases.indexOf( phaseMap.get( phase ) );
|
int index = phases.indexOf( phaseMap.get( phase ) );
|
||||||
|
|
||||||
|
EventDispatcher dispatcher = session.getEventDispatcher();
|
||||||
|
|
||||||
for ( int j = 0; j <= index; j++ )
|
for ( int j = 0; j <= index; j++ )
|
||||||
{
|
{
|
||||||
Phase p = (Phase) phases.get( j );
|
Phase p = (Phase) phases.get( j );
|
||||||
|
|
||||||
if ( p.getGoals() != null )
|
String event = MavenEvents.PHASE_EXECUTION;
|
||||||
|
|
||||||
|
// !! This is ripe for refactoring to an aspect.
|
||||||
|
// Event monitoring.
|
||||||
|
dispatcher.dispatchStart( event, p.getId() );
|
||||||
|
try
|
||||||
{
|
{
|
||||||
for ( Iterator i = p.getGoals().iterator(); i.hasNext(); )
|
if ( p.getGoals() != null )
|
||||||
{
|
{
|
||||||
String goal = (String) i.next();
|
for ( Iterator i = p.getGoals().iterator(); i.hasNext(); )
|
||||||
|
|
||||||
PluginExecutionResponse pluginResponse = executeMojo( goal, session );
|
|
||||||
|
|
||||||
if ( pluginResponse.isExecutionFailure() )
|
|
||||||
{
|
{
|
||||||
response.setExecutionFailure( goal, pluginResponse.getFailureResponse() );
|
String goal = (String) i.next();
|
||||||
return;
|
|
||||||
|
PluginExecutionResponse pluginResponse = executeMojo( goal, session );
|
||||||
|
|
||||||
|
if ( pluginResponse.isExecutionFailure() )
|
||||||
|
{
|
||||||
|
response.setExecutionFailure( goal, pluginResponse.getFailureResponse() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatcher.dispatchEnd( event, p.getId() );
|
||||||
}
|
}
|
||||||
|
catch ( LifecycleExecutionException e )
|
||||||
|
{
|
||||||
|
dispatcher.dispatchError( event, p.getId(), e );
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
// End event monitoring.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package org.apache.maven.monitor.event;
|
||||||
|
|
||||||
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public class DefaultEventMonitor
|
||||||
|
extends AbstractSelectiveEventMonitor
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String[] START_EVENTS = {
|
||||||
|
MavenEvents.MOJO_EXECUTION
|
||||||
|
};
|
||||||
|
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
|
public DefaultEventMonitor( Logger logger )
|
||||||
|
{
|
||||||
|
super( START_EVENTS, MavenEvents.NO_EVENTS, MavenEvents.NO_EVENTS );
|
||||||
|
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doStartEvent( String event, String target, long time )
|
||||||
|
{
|
||||||
|
logger.info( "[" + target + "]" );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package org.apache.maven.monitor.logging;
|
||||||
|
|
||||||
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public class DefaultLog
|
||||||
|
implements Log
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
|
public DefaultLog( Logger logger )
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug( CharSequence content )
|
||||||
|
{
|
||||||
|
logger.debug( content.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug( CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
logger.debug( content.toString(), error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug( Throwable error )
|
||||||
|
{
|
||||||
|
logger.debug( "", error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info( CharSequence content )
|
||||||
|
{
|
||||||
|
logger.info( content.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info( CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
logger.info( content.toString(), error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info( Throwable error )
|
||||||
|
{
|
||||||
|
logger.info( "", error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn( CharSequence content )
|
||||||
|
{
|
||||||
|
logger.warn( content.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn( CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
logger.warn( content.toString(), error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn( Throwable error )
|
||||||
|
{
|
||||||
|
logger.warn( "", error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error( CharSequence content )
|
||||||
|
{
|
||||||
|
logger.error( content.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error( CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
logger.error( content.toString(), error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error( Throwable error )
|
||||||
|
{
|
||||||
|
logger.error( "", error );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,6 +29,8 @@
|
|||||||
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
|
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.goal.GoalExecutionException;
|
import org.apache.maven.lifecycle.goal.GoalExecutionException;
|
||||||
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
import org.apache.maven.monitor.event.MavenEvents;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.Parameter;
|
import org.apache.maven.plugin.descriptor.Parameter;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
@ -279,9 +281,11 @@ public PluginExecutionResponse executeMojo( MavenSession session, String goalNam
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getLogger().info( "[" + mojoDescriptor.getId() + "]" );
|
// getLogger().info( "[" + mojoDescriptor.getId() + "]" );
|
||||||
|
|
||||||
request = new PluginExecutionRequest( DefaultPluginManager.createParameters( mojoDescriptor, session ) );
|
request = new PluginExecutionRequest( DefaultPluginManager.createParameters( mojoDescriptor, session ) );
|
||||||
|
|
||||||
|
request.setLog( session.getLog() );
|
||||||
}
|
}
|
||||||
catch ( PluginConfigurationException e )
|
catch ( PluginConfigurationException e )
|
||||||
{
|
{
|
||||||
@ -296,7 +300,24 @@ public PluginExecutionResponse executeMojo( MavenSession session, String goalNam
|
|||||||
{
|
{
|
||||||
plugin = (Plugin) container.lookup( Plugin.ROLE, goalName );
|
plugin = (Plugin) container.lookup( Plugin.ROLE, goalName );
|
||||||
|
|
||||||
plugin.execute( request, response );
|
// !! This is ripe for refactoring to an aspect.
|
||||||
|
// Event monitoring.
|
||||||
|
String event = MavenEvents.MOJO_EXECUTION;
|
||||||
|
EventDispatcher dispatcher = session.getEventDispatcher();
|
||||||
|
|
||||||
|
dispatcher.dispatchStart( event, goalName );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
plugin.execute( request, response );
|
||||||
|
|
||||||
|
dispatcher.dispatchEnd( event, goalName );
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
session.getEventDispatcher().dispatchError( event, goalName, e );
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
// End event monitoring.
|
||||||
|
|
||||||
releaseComponents( mojoDescriptor, request );
|
releaseComponents( mojoDescriptor, request );
|
||||||
|
|
||||||
@ -455,7 +476,7 @@ public void contextualize( Context context )
|
|||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
artifactFilter = new ExclusionSetFilter( new String[]{"maven-core", "maven-artifact", "maven-model",
|
artifactFilter = new ExclusionSetFilter( new String[]{"maven-core", "maven-artifact", "maven-model",
|
||||||
"maven-plugin", "plexus-container-api",
|
"maven-monitor", "maven-plugin", "plexus-container-api",
|
||||||
"plexus-container-default", "plexus-artifact-container",
|
"plexus-container-default", "plexus-artifact-container",
|
||||||
"classworlds"} );
|
"classworlds"} );
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
|
import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
|
||||||
|
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||||
|
import org.apache.maven.monitor.logging.DefaultLog;
|
||||||
|
import org.apache.maven.monitor.logging.Log;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
@ -130,7 +133,9 @@ protected MavenGoalExecutionContext createGoalExecutionContext( MavenProject pro
|
|||||||
{
|
{
|
||||||
List goals = new ArrayList();
|
List goals = new ArrayList();
|
||||||
|
|
||||||
MavenSession session = new MavenSession( getContainer(), pluginManager, localRepository, goals );
|
Log log = new DefaultLog(getContainer().getLogger());
|
||||||
|
|
||||||
|
MavenSession session = new MavenSession( getContainer(), pluginManager, localRepository, new DefaultEventDispatcher(), log, goals );
|
||||||
|
|
||||||
session.setProject( project );
|
session.setProject( project );
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ public class MBoot
|
|||||||
|
|
||||||
String[] builds = new String[] {
|
String[] builds = new String[] {
|
||||||
"maven-model",
|
"maven-model",
|
||||||
|
"maven-monitor",
|
||||||
"maven-plugin",
|
"maven-plugin",
|
||||||
"maven-artifact",
|
"maven-artifact",
|
||||||
"maven-script/maven-script-marmalade",
|
"maven-script/maven-script-marmalade",
|
||||||
|
11
maven-monitor/pom.xml
Normal file
11
maven-monitor/pom.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-component</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</project>
|
@ -0,0 +1,62 @@
|
|||||||
|
package org.apache.maven.monitor.event;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public abstract class AbstractSelectiveEventMonitor
|
||||||
|
implements EventMonitor
|
||||||
|
{
|
||||||
|
|
||||||
|
private List boundStartEvents;
|
||||||
|
private List boundErrorEvents;
|
||||||
|
private List boundEndEvents;
|
||||||
|
|
||||||
|
protected AbstractSelectiveEventMonitor(String[] startEvents, String[] endEvents, String[] errorEvents)
|
||||||
|
{
|
||||||
|
this.boundStartEvents = Arrays.asList( startEvents );
|
||||||
|
|
||||||
|
this.boundEndEvents = Arrays.asList( endEvents );
|
||||||
|
|
||||||
|
this.boundErrorEvents = Arrays.asList( errorEvents );
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void startEvent( String eventName, String target, long timestamp )
|
||||||
|
{
|
||||||
|
if( boundStartEvents.contains( eventName ) )
|
||||||
|
{
|
||||||
|
doStartEvent( eventName, target, timestamp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doStartEvent( String eventName, String target, long timestamp )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void endEvent( String eventName, String target, long timestamp )
|
||||||
|
{
|
||||||
|
if( boundEndEvents.contains( eventName ) )
|
||||||
|
{
|
||||||
|
doEndEvent( eventName, target, timestamp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doEndEvent( String eventName, String target, long timestamp )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void errorEvent( String eventName, String target, long timestamp, Throwable cause )
|
||||||
|
{
|
||||||
|
if( boundErrorEvents.contains( eventName ) )
|
||||||
|
{
|
||||||
|
doErrorEvent( eventName, target, timestamp, cause );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doErrorEvent( String eventName, String target, long timestamp, Throwable cause )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package org.apache.maven.monitor.event;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public class DefaultEventDispatcher
|
||||||
|
implements EventDispatcher
|
||||||
|
{
|
||||||
|
|
||||||
|
private List eventMonitors = new ArrayList();
|
||||||
|
|
||||||
|
public void addEventMonitor( EventMonitor monitor )
|
||||||
|
{
|
||||||
|
eventMonitors.add( monitor );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispatchStart( String event, String target )
|
||||||
|
{
|
||||||
|
for ( Iterator it = eventMonitors.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
EventMonitor monitor = (EventMonitor) it.next();
|
||||||
|
monitor.startEvent( event, target, System.currentTimeMillis() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispatchEnd( String event, String target )
|
||||||
|
{
|
||||||
|
for ( Iterator it = eventMonitors.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
EventMonitor monitor = (EventMonitor) it.next();
|
||||||
|
monitor.endEvent( event, target, System.currentTimeMillis() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispatchError( String event, String target, Throwable cause )
|
||||||
|
{
|
||||||
|
for ( Iterator it = eventMonitors.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
EventMonitor monitor = (EventMonitor) it.next();
|
||||||
|
monitor.errorEvent( event, target, System.currentTimeMillis(), cause );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.apache.maven.monitor.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public interface EventDispatcher
|
||||||
|
{
|
||||||
|
|
||||||
|
void addEventMonitor( EventMonitor monitor );
|
||||||
|
|
||||||
|
void dispatchStart( String event, String target );
|
||||||
|
|
||||||
|
void dispatchEnd( String event, String target );
|
||||||
|
|
||||||
|
void dispatchError( String event, String target, Throwable cause );
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.apache.maven.monitor.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public interface EventMonitor
|
||||||
|
{
|
||||||
|
|
||||||
|
void startEvent( String eventName, String target, long timestamp );
|
||||||
|
|
||||||
|
void endEvent( String eventName, String target, long timestamp );
|
||||||
|
|
||||||
|
void errorEvent( String eventName, String target, long timestamp, Throwable cause );
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package org.apache.maven.monitor.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public final class MavenEvents
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String PHASE_EXECUTION = "phase-execute";
|
||||||
|
public static final String MOJO_EXECUTION = "mojo-execute";
|
||||||
|
public static final String PROJECT_EXECUTION = "project-execute";
|
||||||
|
public static final String REACTOR_EXECUTION = "reactor-execute";
|
||||||
|
|
||||||
|
public static final String[] ALL_EVENTS = {
|
||||||
|
PHASE_EXECUTION,
|
||||||
|
MOJO_EXECUTION,
|
||||||
|
PROJECT_EXECUTION,
|
||||||
|
REACTOR_EXECUTION
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final String[] NO_EVENTS = {};
|
||||||
|
|
||||||
|
private MavenEvents()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package org.apache.maven.monitor.logging;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public interface Log
|
||||||
|
{
|
||||||
|
|
||||||
|
void debug( CharSequence content );
|
||||||
|
|
||||||
|
void debug( CharSequence content, Throwable error );
|
||||||
|
|
||||||
|
void debug( Throwable error );
|
||||||
|
|
||||||
|
void info( CharSequence content );
|
||||||
|
|
||||||
|
void info( CharSequence content, Throwable error );
|
||||||
|
|
||||||
|
void info( Throwable error );
|
||||||
|
|
||||||
|
void warn( CharSequence content );
|
||||||
|
|
||||||
|
void warn( CharSequence content, Throwable error );
|
||||||
|
|
||||||
|
void warn( Throwable error );
|
||||||
|
|
||||||
|
void error( CharSequence content );
|
||||||
|
|
||||||
|
void error( CharSequence content, Throwable error );
|
||||||
|
|
||||||
|
void error( Throwable error );
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package org.apache.maven.monitor.logging;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public class SystemStreamLog
|
||||||
|
implements Log
|
||||||
|
{
|
||||||
|
|
||||||
|
public void debug( CharSequence content )
|
||||||
|
{
|
||||||
|
print( "debug", content );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug( CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
print( "debug", content, error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug( Throwable error )
|
||||||
|
{
|
||||||
|
print( "debug", error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info( CharSequence content )
|
||||||
|
{
|
||||||
|
print( "info", content );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info( CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
print( "info", content, error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info( Throwable error )
|
||||||
|
{
|
||||||
|
print( "info", error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn( CharSequence content )
|
||||||
|
{
|
||||||
|
print( "warn", content );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn( CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
print( "warn", content, error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn( Throwable error )
|
||||||
|
{
|
||||||
|
print( "warn", error );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error( CharSequence content )
|
||||||
|
{
|
||||||
|
System.err.println( "[error] " + content.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error( CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
StringWriter sWriter = new StringWriter();
|
||||||
|
PrintWriter pWriter = new PrintWriter( sWriter );
|
||||||
|
|
||||||
|
error.printStackTrace( pWriter );
|
||||||
|
|
||||||
|
System.err.println( "[error] " + content.toString() + "\n\n" + sWriter.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error( Throwable error )
|
||||||
|
{
|
||||||
|
StringWriter sWriter = new StringWriter();
|
||||||
|
PrintWriter pWriter = new PrintWriter( sWriter );
|
||||||
|
|
||||||
|
error.printStackTrace( pWriter );
|
||||||
|
|
||||||
|
System.err.println( "[error] " + sWriter.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print( String prefix, CharSequence content )
|
||||||
|
{
|
||||||
|
System.out.println( "[" + prefix + "] " + content.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print( String prefix, Throwable error )
|
||||||
|
{
|
||||||
|
StringWriter sWriter = new StringWriter();
|
||||||
|
PrintWriter pWriter = new PrintWriter( sWriter );
|
||||||
|
|
||||||
|
error.printStackTrace( pWriter );
|
||||||
|
|
||||||
|
System.out.println( "[" + prefix + "] " + sWriter.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print( String prefix, CharSequence content, Throwable error )
|
||||||
|
{
|
||||||
|
StringWriter sWriter = new StringWriter();
|
||||||
|
PrintWriter pWriter = new PrintWriter( sWriter );
|
||||||
|
|
||||||
|
error.printStackTrace( pWriter );
|
||||||
|
|
||||||
|
System.out.println( "[" + prefix + "] " + content.toString() + "\n\n" + sWriter.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,14 +25,14 @@ public Set execute( MavenProject project ) throws Exception
|
|||||||
Build buildSection = project.getBuild();
|
Build buildSection = project.getBuild();
|
||||||
|
|
||||||
List resources = null;
|
List resources = null;
|
||||||
if(buildSection != null)
|
if ( buildSection != null )
|
||||||
{
|
{
|
||||||
resources = buildSection.getResources();
|
resources = buildSection.getResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map scriptFilesKeyedByBasedir = gatherScriptSourcesByBasedir(resources, getScriptFileExtension());
|
Map scriptFilesKeyedByBasedir = gatherScriptSourcesByBasedir( resources, getScriptFileExtension() );
|
||||||
|
|
||||||
Set mojoDescriptors = extractMojoDescriptors(scriptFilesKeyedByBasedir);
|
Set mojoDescriptors = extractMojoDescriptors( scriptFilesKeyedByBasedir );
|
||||||
|
|
||||||
return mojoDescriptors;
|
return mojoDescriptors;
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ protected Map gatherScriptSourcesByBasedir( List resources, String scriptFileExt
|
|||||||
{
|
{
|
||||||
Map sourcesByBasedir = new TreeMap();
|
Map sourcesByBasedir = new TreeMap();
|
||||||
|
|
||||||
if(resources != null)
|
if ( resources != null )
|
||||||
{
|
{
|
||||||
for ( Iterator it = resources.iterator(); it.hasNext(); )
|
for ( Iterator it = resources.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
@ -54,26 +54,26 @@ protected Map gatherScriptSourcesByBasedir( List resources, String scriptFileExt
|
|||||||
Resource resource = (Resource) it.next();
|
Resource resource = (Resource) it.next();
|
||||||
|
|
||||||
String resourceDir = resource.getDirectory();
|
String resourceDir = resource.getDirectory();
|
||||||
File dir = new File(resourceDir);
|
File dir = new File( resourceDir );
|
||||||
|
|
||||||
if(dir.exists())
|
if ( dir.exists() )
|
||||||
{
|
{
|
||||||
DirectoryScanner scanner = new DirectoryScanner();
|
DirectoryScanner scanner = new DirectoryScanner();
|
||||||
|
|
||||||
scanner.setBasedir(dir);
|
scanner.setBasedir( dir );
|
||||||
|
|
||||||
List includes = resource.getIncludes();
|
List includes = resource.getIncludes();
|
||||||
|
|
||||||
if(includes != null && !includes.isEmpty())
|
if ( includes != null && !includes.isEmpty() )
|
||||||
{
|
{
|
||||||
scanner.setIncludes((String[])includes.toArray(new String[includes.size()]));
|
scanner.setIncludes( (String[]) includes.toArray( new String[includes.size()] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
List excludes = resource.getExcludes();
|
List excludes = resource.getExcludes();
|
||||||
|
|
||||||
if(excludes != null && !excludes.isEmpty())
|
if ( excludes != null && !excludes.isEmpty() )
|
||||||
{
|
{
|
||||||
scanner.setExcludes((String[])excludes.toArray(new String[excludes.size()]));
|
scanner.setExcludes( (String[]) excludes.toArray( new String[excludes.size()] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner.addDefaultExcludes();
|
scanner.addDefaultExcludes();
|
||||||
@ -84,15 +84,15 @@ protected Map gatherScriptSourcesByBasedir( List resources, String scriptFileExt
|
|||||||
for ( int i = 0; i < relativePaths.length; i++ )
|
for ( int i = 0; i < relativePaths.length; i++ )
|
||||||
{
|
{
|
||||||
String relativePath = relativePaths[i];
|
String relativePath = relativePaths[i];
|
||||||
File scriptFile = new File(dir, relativePath);
|
File scriptFile = new File( dir, relativePath );
|
||||||
|
|
||||||
if(scriptFile.isFile() && relativePath.endsWith(scriptFileExtension))
|
if ( scriptFile.isFile() && relativePath.endsWith( scriptFileExtension ) )
|
||||||
{
|
{
|
||||||
sources.add(scriptFile);
|
sources.add( scriptFile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourcesByBasedir.put(resourceDir, sources);
|
sourcesByBasedir.put( resourceDir, sources );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ public Set execute( MavenProject project ) throws Exception
|
|||||||
|
|
||||||
File basedir = project.getBasedir();
|
File basedir = project.getBasedir();
|
||||||
|
|
||||||
System.out.println("Project basedir: " + basedir);
|
System.out.println( "Project basedir: " + basedir );
|
||||||
|
|
||||||
String sourceDir = null;
|
String sourceDir = null;
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ public Set execute( MavenProject project ) throws Exception
|
|||||||
sourceDir = src.getPath();
|
sourceDir = src.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Source directory for java mojo extraction: " + sourceDir);
|
System.out.println( "Source directory for java mojo extraction: " + sourceDir );
|
||||||
|
|
||||||
File sourceDirectoryFile = new File( sourceDir );
|
File sourceDirectoryFile = new File( sourceDir );
|
||||||
|
|
||||||
|
@ -46,13 +46,13 @@ public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory() throws Excep
|
|||||||
model.setArtifactId( "maven-unitTesting-plugin" );
|
model.setArtifactId( "maven-unitTesting-plugin" );
|
||||||
|
|
||||||
Build build = new Build();
|
Build build = new Build();
|
||||||
build.setSourceDirectory(new File(dir, "source").getPath());
|
build.setSourceDirectory( new File( dir, "source" ).getPath() );
|
||||||
|
|
||||||
model.setBuild(build);
|
model.setBuild( build );
|
||||||
|
|
||||||
MavenProject project = new MavenProject( model );
|
MavenProject project = new MavenProject( model );
|
||||||
|
|
||||||
project.setFile(new File(dir, "pom.xml"));
|
project.setFile( new File( dir, "pom.xml" ) );
|
||||||
|
|
||||||
Set results = extractor.execute( project );
|
Set results = extractor.execute( project );
|
||||||
assertEquals( 2, results.size() );
|
assertEquals( 2, results.size() );
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
<name>Maven Plugin Tools for Marmalade</name>
|
<name>Maven Plugin Tools for Marmalade</name>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>plexus</groupId>
|
<groupId>plexus</groupId>
|
||||||
<artifactId>plexus-container-default</artifactId>
|
<artifactId>plexus-container-default</artifactId>
|
||||||
|
@ -55,7 +55,7 @@ protected Set extractMojoDescriptors( Map sourceFilesKeyedByBasedir ) throws Exc
|
|||||||
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
|
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.currentThread().setContextClassLoader(MarmaladeMojoDescriptorExtractor.class.getClassLoader());
|
Thread.currentThread().setContextClassLoader( MarmaladeMojoDescriptorExtractor.class.getClassLoader() );
|
||||||
|
|
||||||
Set descriptors = new HashSet();
|
Set descriptors = new HashSet();
|
||||||
|
|
||||||
@ -63,24 +63,24 @@ protected Set extractMojoDescriptors( Map sourceFilesKeyedByBasedir ) throws Exc
|
|||||||
{
|
{
|
||||||
Map.Entry entry = (Map.Entry) mapIterator.next();
|
Map.Entry entry = (Map.Entry) mapIterator.next();
|
||||||
|
|
||||||
String basedir = (String)entry.getKey();
|
String basedir = (String) entry.getKey();
|
||||||
Set scriptFiles = (Set)entry.getValue();
|
Set scriptFiles = (Set) entry.getValue();
|
||||||
|
|
||||||
for ( Iterator it = scriptFiles.iterator(); it.hasNext(); )
|
for ( Iterator it = scriptFiles.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
File scriptFile = (File) it.next();
|
File scriptFile = (File) it.next();
|
||||||
|
|
||||||
MarmaladeScript script = parse(scriptFile);
|
MarmaladeScript script = parse( scriptFile );
|
||||||
|
|
||||||
MarmaladeTag rootTag = script.getRoot();
|
MarmaladeTag rootTag = script.getRoot();
|
||||||
if(rootTag instanceof MojoTag)
|
if ( rootTag instanceof MojoTag )
|
||||||
{
|
{
|
||||||
Map contextMap = new TreeMap();
|
Map contextMap = new TreeMap();
|
||||||
contextMap.put( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR, basedir );
|
contextMap.put( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR, basedir );
|
||||||
|
|
||||||
MarmaladeExecutionContext context = new DefaultContext(contextMap);
|
MarmaladeExecutionContext context = new DefaultContext( contextMap );
|
||||||
|
|
||||||
script.execute(context);
|
script.execute( context );
|
||||||
|
|
||||||
contextMap = context.getExternalizedVariables();
|
contextMap = context.getExternalizedVariables();
|
||||||
|
|
||||||
@ -90,7 +90,8 @@ protected Set extractMojoDescriptors( Map sourceFilesKeyedByBasedir ) throws Exc
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.out.println("This script is not a mojo. Its root tag is {element: " + rootTag.getTagInfo().getElement() + ", class: " + rootTag.getClass().getName() + "}");
|
System.out.println( "This script is not a mojo. Its root tag is {element: "
|
||||||
|
+ rootTag.getTagInfo().getElement() + ", class: " + rootTag.getClass().getName() + "}" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +100,7 @@ protected Set extractMojoDescriptors( Map sourceFilesKeyedByBasedir ) throws Exc
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Thread.currentThread().setContextClassLoader(oldCl);
|
Thread.currentThread().setContextClassLoader( oldCl );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,16 +110,16 @@ private MarmaladeScript parse( File scriptFile ) throws Exception
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
reader = new BufferedReader(new FileReader(scriptFile));
|
reader = new BufferedReader( new FileReader( scriptFile ) );
|
||||||
|
|
||||||
MarmaladeParsingContext parsingContext = new DefaultParsingContext();
|
MarmaladeParsingContext parsingContext = new DefaultParsingContext();
|
||||||
|
|
||||||
parsingContext.setInputLocation(scriptFile.getPath());
|
parsingContext.setInputLocation( scriptFile.getPath() );
|
||||||
parsingContext.setInput(reader);
|
parsingContext.setInput( reader );
|
||||||
|
|
||||||
ScriptParser parser = new ScriptParser();
|
ScriptParser parser = new ScriptParser();
|
||||||
|
|
||||||
ScriptBuilder builder = parser.parse(parsingContext);
|
ScriptBuilder builder = parser.parse( parsingContext );
|
||||||
|
|
||||||
MarmaladeScript script = builder.build();
|
MarmaladeScript script = builder.build();
|
||||||
|
|
||||||
@ -126,13 +127,13 @@ private MarmaladeScript parse( File scriptFile ) throws Exception
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if(reader != null)
|
if ( reader != null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,17 +45,18 @@ public void testShouldFindOneMojo() throws Exception
|
|||||||
Build build = new Build();
|
Build build = new Build();
|
||||||
|
|
||||||
Resource resource = new Resource();
|
Resource resource = new Resource();
|
||||||
resource.setDirectory(basedir.getPath());
|
resource.setDirectory( basedir.getPath() );
|
||||||
|
|
||||||
build.addResource(resource);
|
build.addResource( resource );
|
||||||
|
|
||||||
model.setBuild(build);
|
model.setBuild( build );
|
||||||
|
|
||||||
MavenProject project = new MavenProject( model );
|
MavenProject project = new MavenProject( model );
|
||||||
|
|
||||||
project.setFile(new File(basedir, "pom.xml"));
|
project.setFile( new File( basedir, "pom.xml" ) );
|
||||||
|
|
||||||
MarmaladeMojoDescriptorExtractor extractor = (MarmaladeMojoDescriptorExtractor) lookup(MojoDescriptorExtractor.ROLE, "marmalade");
|
MarmaladeMojoDescriptorExtractor extractor = (MarmaladeMojoDescriptorExtractor) lookup( MojoDescriptorExtractor.ROLE,
|
||||||
|
"marmalade" );
|
||||||
|
|
||||||
Set descriptors = extractor.execute( project );
|
Set descriptors = extractor.execute( project );
|
||||||
|
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
<name>Maven Plugin</name>
|
<name>Maven Plugin</name>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>qdox</groupId>
|
<groupId>qdox</groupId>
|
||||||
<artifactId>qdox</artifactId>
|
<artifactId>qdox</artifactId>
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.monitor.logging.Log;
|
||||||
|
import org.apache.maven.monitor.logging.SystemStreamLog;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -29,6 +32,8 @@ public class PluginExecutionRequest
|
|||||||
|
|
||||||
private Map context;
|
private Map context;
|
||||||
|
|
||||||
|
private Log log;
|
||||||
|
|
||||||
public PluginExecutionRequest( Map parameters )
|
public PluginExecutionRequest( Map parameters )
|
||||||
{
|
{
|
||||||
context = new HashMap();
|
context = new HashMap();
|
||||||
@ -60,4 +65,22 @@ public Object getContextValue( String key )
|
|||||||
{
|
{
|
||||||
return context.get( key );
|
return context.get( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLog( Log log )
|
||||||
|
{
|
||||||
|
this.log = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Log getLog()
|
||||||
|
{
|
||||||
|
synchronized(this)
|
||||||
|
{
|
||||||
|
if(log == null)
|
||||||
|
{
|
||||||
|
log = new SystemStreamLog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return log;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,4 +14,11 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<inceptionYear>2001</inceptionYear>
|
<inceptionYear>2001</inceptionYear>
|
||||||
<package>org.apache.maven.plugin.clean</package>
|
<package>org.apache.maven.plugin.clean</package>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.monitor.logging.Log;
|
||||||
import org.apache.maven.plugin.AbstractPlugin;
|
import org.apache.maven.plugin.AbstractPlugin;
|
||||||
import org.apache.maven.plugin.PluginExecutionRequest;
|
import org.apache.maven.plugin.PluginExecutionRequest;
|
||||||
import org.apache.maven.plugin.PluginExecutionResponse;
|
import org.apache.maven.plugin.PluginExecutionResponse;
|
||||||
@ -47,23 +48,37 @@ public class CleanPlugin
|
|||||||
|
|
||||||
private boolean failOnError;
|
private boolean failOnError;
|
||||||
|
|
||||||
|
private Log log;
|
||||||
|
|
||||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
outputDirectory = (String) request.getParameter( "outputDirectory" );
|
try
|
||||||
|
|
||||||
failOnError = Boolean.valueOf( (String) request.getParameter( "failedOnError" ) ).booleanValue();
|
|
||||||
|
|
||||||
if ( outputDirectory != null )
|
|
||||||
{
|
{
|
||||||
File dir = new File( outputDirectory );
|
outputDirectory = (String) request.getParameter( "outputDirectory" );
|
||||||
|
|
||||||
if ( dir.exists() && dir.isDirectory() )
|
failOnError = Boolean.valueOf( (String) request.getParameter( "failedOnError" ) ).booleanValue();
|
||||||
|
|
||||||
|
log = request.getLog();
|
||||||
|
|
||||||
|
if ( outputDirectory != null )
|
||||||
{
|
{
|
||||||
log( "Deleting directory " + dir.getAbsolutePath() );
|
File dir = new File( outputDirectory );
|
||||||
removeDir( dir );
|
|
||||||
|
if ( dir.exists() && dir.isDirectory() )
|
||||||
|
{
|
||||||
|
log( "Deleting directory " + dir.getAbsolutePath() );
|
||||||
|
removeDir( dir );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// clean up state.
|
||||||
|
failOnError = false;
|
||||||
|
outputDirectory = null;
|
||||||
|
log = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,6 +163,6 @@ protected void removeDir( File d ) throws Exception
|
|||||||
|
|
||||||
private void log( String message )
|
private void log( String message )
|
||||||
{
|
{
|
||||||
System.out.println( message );
|
log.info( message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
<inceptionYear>2001</inceptionYear>
|
<inceptionYear>2001</inceptionYear>
|
||||||
<package>org.apache.maven</package>
|
<package>org.apache.maven</package>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>plexus</groupId>
|
<groupId>plexus</groupId>
|
||||||
<artifactId>plexus</artifactId>
|
<artifactId>plexus</artifactId>
|
||||||
|
@ -119,7 +119,8 @@ public void execute( PluginExecutionRequest request, PluginExecutionResponse res
|
|||||||
message = "Warning! not present in repository!";
|
message = "Warning! not present in repository!";
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println( "classpathElements[ "+ i +" ] = " + classpathElements[i] + ": " + message );
|
// System.out.println( "classpathElements[ "+ i +" ] = " + classpathElements[i] + ": " + message );
|
||||||
|
request.getLog().debug( "classpathElements[ "+ i +" ] = " + classpathElements[i] + ": " + message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<package>org.apache.maven.plugin.war</package>
|
<package>org.apache.maven.plugin.war</package>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
@ -114,7 +114,7 @@ public void execute( PluginExecutionRequest request, PluginExecutionResponse res
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
System.out.println("webapp");
|
request.getLog().info("webapp");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -114,7 +114,7 @@ public void execute( PluginExecutionRequest request, PluginExecutionResponse res
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
System.out.println("war");
|
request.getLog().info("war");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,11 @@
|
|||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven-plugin</artifactId>
|
<artifactId>maven-plugin</artifactId>
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
<name>Maven Marmalade Mojo Support</name>
|
<name>Maven Marmalade Mojo Support</name>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven-plugin</artifactId>
|
<artifactId>maven-plugin</artifactId>
|
||||||
|
@ -38,7 +38,6 @@ protected void doExecute( MarmaladeExecutionContext context ) throws MarmaladeEx
|
|||||||
for ( Iterator it = children().iterator(); it.hasNext(); )
|
for ( Iterator it = children().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
MarmaladeTag child = (MarmaladeTag) it.next();
|
MarmaladeTag child = (MarmaladeTag) it.next();
|
||||||
System.out.println("Will execute: " + child);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,16 +104,16 @@ private MojoDescriptor buildDescriptor( MarmaladeExecutionContext context ) thro
|
|||||||
String basePath = (String) context.getVariable( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
|
String basePath = (String) context.getVariable( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
|
||||||
getExpressionEvaluator() );
|
getExpressionEvaluator() );
|
||||||
|
|
||||||
if(basePath != null)
|
if ( basePath != null )
|
||||||
{
|
{
|
||||||
if(basePath.endsWith("/"))
|
if ( basePath.endsWith( "/" ) )
|
||||||
{
|
{
|
||||||
basePath = basePath.substring(0, basePath.length()-2);
|
basePath = basePath.substring( 0, basePath.length() - 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
String implementationPath = getTagInfo().getSourceFile().substring( basePath.length() );
|
String implementationPath = getTagInfo().getSourceFile().substring( basePath.length() );
|
||||||
|
|
||||||
implementationPath = implementationPath.replace('\\', '/');
|
implementationPath = implementationPath.replace( '\\', '/' );
|
||||||
|
|
||||||
descriptor.setImplementation( implementationPath );
|
descriptor.setImplementation( implementationPath );
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,9 @@ protected void doExecute( MarmaladeExecutionContext context ) throws MarmaladeEx
|
|||||||
for ( Iterator it = children().iterator(); it.hasNext(); )
|
for ( Iterator it = children().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
MarmaladeTag child = (MarmaladeTag) it.next();
|
MarmaladeTag child = (MarmaladeTag) it.next();
|
||||||
if(!(child instanceof ExecuteTag))
|
if ( !(child instanceof ExecuteTag) )
|
||||||
{
|
{
|
||||||
child.execute(context);
|
child.execute( context );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,16 +59,16 @@ public Object getComponent()
|
|||||||
for ( Iterator it = children().iterator(); it.hasNext(); )
|
for ( Iterator it = children().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
MarmaladeTag child = (MarmaladeTag) it.next();
|
MarmaladeTag child = (MarmaladeTag) it.next();
|
||||||
if(child instanceof ExecuteTag)
|
if ( child instanceof ExecuteTag )
|
||||||
{
|
{
|
||||||
realRoot = child;
|
realRoot = child;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(realRoot == null)
|
if ( realRoot == null )
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("Mojo scripts MUST have a <execute> tag.");
|
throw new IllegalStateException( "Mojo scripts MUST have a <execute> tag." );
|
||||||
}
|
}
|
||||||
|
|
||||||
MarmaladeScript script = new MarmaladeScript( getTagInfo().getSourceFile(), realRoot );
|
MarmaladeScript script = new MarmaladeScript( getTagInfo().getSourceFile(), realRoot );
|
||||||
|
@ -51,7 +51,7 @@ public void testShouldProduceOutputWithRequest_Dot_ToStringInline() throws Excep
|
|||||||
MarmaladeMojo mojo = new MarmaladeMojo( script );
|
MarmaladeMojo mojo = new MarmaladeMojo( script );
|
||||||
|
|
||||||
PluginExecutionRequest request = new PluginExecutionRequest( Collections.EMPTY_MAP );
|
PluginExecutionRequest request = new PluginExecutionRequest( Collections.EMPTY_MAP );
|
||||||
request.setParameters(Collections.singletonMap("param", "paramValue"));
|
request.setParameters( Collections.singletonMap( "param", "paramValue" ) );
|
||||||
|
|
||||||
PluginExecutionResponse response = new PluginExecutionResponse();
|
PluginExecutionResponse response = new PluginExecutionResponse();
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public void testShouldProduceOutputWithRequest_Dot_ToStringInline() throws Excep
|
|||||||
|
|
||||||
Object result = request.getContextValue( "testvar" );
|
Object result = request.getContextValue( "testvar" );
|
||||||
|
|
||||||
assertEquals("paramValue/testval", result);
|
assertEquals( "paramValue/testval", result );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -12,6 +12,11 @@
|
|||||||
<name>Maven Script Support Root</name>
|
<name>Maven Script Support Root</name>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven-plugin</artifactId>
|
<artifactId>maven-plugin</artifactId>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user