maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r932966 - in /maven/maven-3/trunk: maven-core/src/main/java/org/apache/maven/execution/ maven-core/src/main/java/org/apache/maven/lifecycle/ maven-core/src/main/java/org/apache/maven/lifecycle/internal/ maven-embedder/src/main/java/org/apac...
Date Sun, 11 Apr 2010 18:10:07 GMT
Author: bentmann
Date: Sun Apr 11 18:10:07 2010
New Revision: 932966

URL: http://svn.apache.org/viewvc?rev=932966&view=rev
Log:
o Improved logging for forked executions

Modified:
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
    maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java?rev=932966&r1=932965&r2=932966&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java
Sun Apr 11 18:10:07 2010
@@ -99,4 +99,19 @@ public class AbstractExecutionListener
         // default does nothing
     }
 
+    public void forkedProjectStarted( ExecutionEvent event )
+    {
+        // default does nothing
+    }
+
+    public void forkedProjectSucceeded( ExecutionEvent event )
+    {
+        // default does nothing
+    }
+
+    public void forkedProjectFailed( ExecutionEvent event )
+    {
+        // default does nothing
+    }
+
 }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java?rev=932966&r1=932965&r2=932966&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java
Sun Apr 11 18:10:07 2010
@@ -57,4 +57,10 @@ public interface ExecutionListener
 
     void forkFailed( ExecutionEvent event );
 
+    void forkedProjectStarted( ExecutionEvent event );
+
+    void forkedProjectSucceeded( ExecutionEvent event );
+
+    void forkedProjectFailed( ExecutionEvent event );
+
 }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java?rev=932966&r1=932965&r2=932966&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java
Sun Apr 11 18:10:07 2010
@@ -143,4 +143,28 @@ public interface LifecycleEventCatapult
         }
     };
 
+    static final LifecycleEventCatapult FORKED_PROJECT_STARTED = new LifecycleEventCatapult()
+    {
+        public void fire( ExecutionListener listener, ExecutionEvent event )
+        {
+            listener.forkedProjectStarted( event );
+        }
+    };
+
+    static final LifecycleEventCatapult FORKED_PROJECT_SUCCEEDED = new LifecycleEventCatapult()
+    {
+        public void fire( ExecutionListener listener, ExecutionEvent event )
+        {
+            listener.forkedProjectSucceeded( event );
+        }
+    };
+
+    static final LifecycleEventCatapult FORKED_PROJECT_FAILED = new LifecycleEventCatapult()
+    {
+        public void fire( ExecutionListener listener, ExecutionEvent event )
+        {
+            listener.forkedProjectFailed( event );
+        }
+    };
+
 }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java?rev=932966&r1=932965&r2=932966&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
Sun Apr 11 18:10:07 2010
@@ -130,8 +130,6 @@ public class MojoExecutor
             try
             {
                 pluginManager.executeMojo( session, mojoExecution );
-
-                DefaultLifecycleExecutor.fireEvent( session, mojoExecution, LifecycleEventCatapult.MOJO_SUCCEEDED
);
             }
             catch ( MojoFailureException e )
             {
@@ -230,8 +228,20 @@ public class MojoExecutor
                         session.getProjects().set( index, executedProject );
                         projectIndex.getProjects().put( fork.getKey(), executedProject );
 
+                        DefaultLifecycleExecutor.fireEvent( session, mojoExecution,
+                                                            LifecycleEventCatapult.FORKED_PROJECT_STARTED
);
+
                         execute( session, fork.getValue(), projectIndex, dependencyContext
);
 
+                        DefaultLifecycleExecutor.fireEvent( session, mojoExecution,
+                                                            LifecycleEventCatapult.FORKED_PROJECT_SUCCEEDED
);
+                    }
+                    catch ( LifecycleExecutionException e )
+                    {
+                        DefaultLifecycleExecutor.fireEvent( session, mojoExecution,
+                                                            LifecycleEventCatapult.FORKED_PROJECT_FAILED
);
+
+                        throw e;
                     }
                     finally
                     {

Modified: maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java?rev=932966&r1=932965&r2=932966&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java
(original)
+++ maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java
Sun Apr 11 18:10:07 2010
@@ -261,17 +261,11 @@ class ExecutionEventLogger
     {
         if ( logger.isInfoEnabled() )
         {
-            MojoExecution me = event.getMojoExecution();
             StringBuilder buffer = new StringBuilder( 128 );
 
             buffer.append( "--- " );
-            buffer.append( me.getArtifactId() ).append( ':' ).append( me.getVersion() );
-            buffer.append( ':' ).append( me.getGoal() );
-            if ( me.getExecutionId() != null )
-            {
-                buffer.append( " (" ).append( me.getExecutionId() ).append( ')' );
-            }
-            buffer.append( " @ " ).append( event.getProject().getArtifactId() );
+            append( buffer, event.getMojoExecution() );
+            append( buffer, event.getProject() );
             buffer.append( " ---" );
 
             logger.info( "" );
@@ -282,18 +276,63 @@ class ExecutionEventLogger
     @Override
     public void forkStarted( ExecutionEvent event )
     {
-        if ( logger.isDebugEnabled() )
+        if ( logger.isInfoEnabled() )
         {
-            logger.debug( "Forking execution for " + event.getMojoExecution().getMojoDescriptor().getId()
);
+            StringBuilder buffer = new StringBuilder( 128 );
+
+            buffer.append( ">>> " );
+            append( buffer, event.getMojoExecution() );
+            append( buffer, event.getProject() );
+            buffer.append( " >>>" );
+
+            logger.info( "" );
+            logger.info( buffer.toString() );
         }
     }
 
     @Override
     public void forkSucceeded( ExecutionEvent event )
     {
-        if ( logger.isDebugEnabled() )
+        if ( logger.isInfoEnabled() )
+        {
+            StringBuilder buffer = new StringBuilder( 128 );
+
+            buffer.append( "<<< " );
+            append( buffer, event.getMojoExecution() );
+            append( buffer, event.getProject() );
+            buffer.append( " <<<" );
+
+            logger.info( "" );
+            logger.info( buffer.toString() );
+        }
+    }
+
+    private void append( StringBuilder buffer, MojoExecution me )
+    {
+        buffer.append( me.getArtifactId() ).append( ':' ).append( me.getVersion() );
+        buffer.append( ':' ).append( me.getGoal() );
+        if ( me.getExecutionId() != null )
+        {
+            buffer.append( " (" ).append( me.getExecutionId() ).append( ')' );
+        }
+    }
+
+    private void append( StringBuilder buffer, MavenProject project )
+    {
+        buffer.append( " @ " ).append( project.getArtifactId() );
+    }
+
+    @Override
+    public void forkedProjectStarted( ExecutionEvent event )
+    {
+        if ( logger.isInfoEnabled() && event.getMojoExecution().getForkedExecutions().size()
> 1 )
         {
-            logger.debug( "Completed forked execution for " + event.getMojoExecution().getMojoDescriptor().getId()
);
+            logger.info( chars( ' ', LINE_LENGTH ) );
+            logger.info( chars( '>', LINE_LENGTH ) );
+
+            logger.info( "Forking " + event.getProject().getName() + " " + event.getProject().getVersion()
);
+
+            logger.info( chars( '>', LINE_LENGTH ) );
         }
     }
 



Mime
View raw message