You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2014/02/06 22:44:04 UTC

[2/2] git commit: Move ThreadOutputMuxer to sit along with the multithreaded Builder implementation

Move ThreadOutputMuxer to sit along with the multithreaded Builder implementation


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/097cc8d2
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/097cc8d2
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/097cc8d2

Branch: refs/heads/master
Commit: 097cc8d25f9261434c6de5e449ca442e45044d00
Parents: 0c5678f
Author: Jason van Zyl <ja...@tesla.io>
Authored: Thu Feb 6 16:39:15 2014 -0500
Committer: Jason van Zyl <ja...@tesla.io>
Committed: Thu Feb 6 16:39:15 2014 -0500

----------------------------------------------------------------------
 .../lifecycle/internal/ProjectBuildList.java    |   2 +-
 .../lifecycle/internal/ThreadOutputMuxer.java   | 474 ------------------
 .../multithreaded/MultiThreadedBuilder.java     |   1 -
 .../multithreaded/ThreadOutputMuxer.java        | 477 +++++++++++++++++++
 .../internal/ThreadOutputMuxerTest.java         | 163 -------
 .../multithreaded/ThreadOutputMuxerTest.java    | 167 +++++++
 6 files changed, 645 insertions(+), 639 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/097cc8d2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectBuildList.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectBuildList.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectBuildList.java
index acea697..ee596ec 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectBuildList.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectBuildList.java
@@ -119,7 +119,7 @@ public class ProjectBuildList
         return items.size();
     }
 
-    ProjectSegment get( int index )
+    public ProjectSegment get( int index )
     {
         return items.get( index );
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/097cc8d2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ThreadOutputMuxer.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ThreadOutputMuxer.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ThreadOutputMuxer.java
deleted file mode 100644
index 0fde6d8..0000000
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ThreadOutputMuxer.java
+++ /dev/null
@@ -1,474 +0,0 @@
-package org.apache.maven.lifecycle.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @since 3.0
- * @author Kristian Rosenvold
- *         <p/>
- *         NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
- *         This class in particular may spontaneusly self-combust and be replaced by a plexus-compliant thread aware
- *         logger implementation at any time.
- */
-@SuppressWarnings( { "SynchronizationOnLocalVariableOrMethodParameter" } )
-public class ThreadOutputMuxer
-{
-    private final Iterator<ProjectSegment> projects;
-
-    private final ThreadLocal<ProjectSegment> projectBuildThreadLocal = new ThreadLocal<ProjectSegment>();
-
-    private final Map<ProjectSegment, ByteArrayOutputStream> streams =
-        new HashMap<ProjectSegment, ByteArrayOutputStream>();
-
-    private final Map<ProjectSegment, PrintStream> printStreams = new HashMap<ProjectSegment, PrintStream>();
-
-    private final ByteArrayOutputStream defaultOutputStreamForUnknownData = new ByteArrayOutputStream();
-
-    private final PrintStream defaultPringStream = new PrintStream( defaultOutputStreamForUnknownData );
-
-    private final Set<ProjectSegment> completedBuilds = Collections.synchronizedSet( new HashSet<ProjectSegment>() );
-
-    private volatile ProjectSegment currentBuild;
-
-    private final PrintStream originalSystemOUtStream;
-
-    private final ConsolePrinter printer;
-
-    /**
-     * A simple but safe solution for printing to the console.
-     */
-
-    class ConsolePrinter
-        implements Runnable
-    {
-        public volatile boolean running;
-
-        private final ProjectBuildList projectBuildList;
-
-        ConsolePrinter( ProjectBuildList projectBuildList )
-        {
-            this.projectBuildList = projectBuildList;
-        }
-
-        public void run()
-        {
-            running = true;
-            for ( ProjectSegment projectBuild : projectBuildList )
-            {
-                final PrintStream projectStream = printStreams.get( projectBuild );
-                ByteArrayOutputStream projectOs = streams.get( projectBuild );
-
-                do
-                {
-                    synchronized ( projectStream )
-                    {
-                        try
-                        {
-                            projectStream.wait( 100 );
-                        }
-                        catch ( InterruptedException e )
-                        {
-                            throw new RuntimeException( e );
-                        }
-                        try
-                        {
-                            projectOs.writeTo( originalSystemOUtStream );
-                        }
-                        catch ( IOException e )
-                        {
-                            throw new RuntimeException( e );
-                        }
-
-                        projectOs.reset();
-                    }
-                }
-                while ( !completedBuilds.contains( projectBuild ) );
-            }
-            running = false;
-        }
-
-        /*
-        Wait until we are sure the print-stream thread is running.
-         */
-
-        public void waitUntilRunning( boolean expect )
-        {
-            while ( !running == expect )
-            {
-                try
-                {
-                    Thread.sleep( 10 );
-                }
-                catch ( InterruptedException e )
-                {
-                    throw new RuntimeException( e );
-                }
-            }
-        }
-    }
-
-    public ThreadOutputMuxer( ProjectBuildList segmentChunks, PrintStream originalSystemOut )
-    {
-        projects = segmentChunks.iterator();
-        for ( ProjectSegment segmentChunk : segmentChunks )
-        {
-            final ByteArrayOutputStream value = new ByteArrayOutputStream();
-            streams.put( segmentChunk, value );
-            printStreams.put( segmentChunk, new PrintStream( value ) );
-        }
-        setNext();
-        this.originalSystemOUtStream = originalSystemOut;
-        System.setOut( new ThreadBoundPrintStream( this.originalSystemOUtStream ) );
-        printer = new ConsolePrinter( segmentChunks );
-        new Thread( printer ).start();
-        printer.waitUntilRunning( true );
-    }
-
-    public void close()
-    {
-        printer.waitUntilRunning( false );
-        System.setOut( this.originalSystemOUtStream );
-    }
-
-    private void setNext()
-    {
-        currentBuild = projects.hasNext() ? projects.next() : null;
-    }
-
-    private boolean ownsRealOutputStream( ProjectSegment projectBuild )
-    {
-        return projectBuild.equals( currentBuild );
-    }
-
-    private PrintStream getThreadBoundPrintStream()
-    {
-        ProjectSegment threadProject = projectBuildThreadLocal.get();
-        if ( threadProject == null )
-        {
-            return defaultPringStream;
-        }
-        if ( ownsRealOutputStream( threadProject ) )
-        {
-            return originalSystemOUtStream;
-        }
-        return printStreams.get( threadProject );
-    }
-
-    public void associateThreadWithProjectSegment( ProjectSegment projectBuild )
-    {
-        projectBuildThreadLocal.set( projectBuild );
-    }
-
-    public void setThisModuleComplete( ProjectSegment projectBuild )
-    {
-        completedBuilds.add( projectBuild );
-        PrintStream stream = printStreams.get( projectBuild );
-        synchronized ( stream )
-        {
-            stream.notifyAll();
-        }
-        disconnectThreadFromProject();
-    }
-
-    private void disconnectThreadFromProject()
-    {
-        projectBuildThreadLocal.remove();
-    }
-
-    private class ThreadBoundPrintStream
-        extends PrintStream
-    {
-
-        public ThreadBoundPrintStream( PrintStream systemOutStream )
-        {
-            super( systemOutStream );
-        }
-
-        private PrintStream getOutputStreamForCurrentThread()
-        {
-            return getThreadBoundPrintStream();
-        }
-
-        @Override
-        public void println()
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.println();
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( char c )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( c );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( char x )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.println( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( double d )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( d );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( double x )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.println( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( float f )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( f );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( float x )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.println( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( int i )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( i );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( int x )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.println( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( long l )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( l );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( long x )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( boolean b )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( b );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( boolean x )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( char s[] )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( s );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( char x[] )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( Object obj )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( obj );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( Object x )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.println( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void print( String s )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.print( s );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void println( String x )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.println( x );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void write( byte b[], int off, int len )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.write( b, off, len );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void close()
-        {
-            getOutputStreamForCurrentThread().close();
-        }
-
-        @Override
-        public void flush()
-        {
-            getOutputStreamForCurrentThread().flush();
-        }
-
-        @Override
-        public void write( int b )
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.write( b );
-                currentStream.notifyAll();
-            }
-        }
-
-        @Override
-        public void write( byte b[] )
-            throws IOException
-        {
-            final PrintStream currentStream = getOutputStreamForCurrentThread();
-            synchronized ( currentStream )
-            {
-                currentStream.write( b );
-                currentStream.notifyAll();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/maven/blob/097cc8d2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
index b89aa0e..c0104ef 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
@@ -37,7 +37,6 @@ import org.apache.maven.lifecycle.internal.ProjectSegment;
 import org.apache.maven.lifecycle.internal.ReactorBuildStatus;
 import org.apache.maven.lifecycle.internal.ReactorContext;
 import org.apache.maven.lifecycle.internal.TaskSegment;
-import org.apache.maven.lifecycle.internal.ThreadOutputMuxer;
 import org.apache.maven.lifecycle.internal.builder.Builder;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.component.annotations.Component;

http://git-wip-us.apache.org/repos/asf/maven/blob/097cc8d2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxer.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxer.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxer.java
new file mode 100644
index 0000000..8f1f493
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxer.java
@@ -0,0 +1,477 @@
+package org.apache.maven.lifecycle.internal.builder.multithreaded;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.lifecycle.internal.ProjectBuildList;
+import org.apache.maven.lifecycle.internal.ProjectSegment;
+
+/**
+ * @since 3.0
+ * @author Kristian Rosenvold
+ *         <p/>
+ *         NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
+ *         This class in particular may spontaneusly self-combust and be replaced by a plexus-compliant thread aware
+ *         logger implementation at any time.
+ */
+@SuppressWarnings( { "SynchronizationOnLocalVariableOrMethodParameter" } )
+public class ThreadOutputMuxer
+{
+    private final Iterator<ProjectSegment> projects;
+
+    private final ThreadLocal<ProjectSegment> projectBuildThreadLocal = new ThreadLocal<ProjectSegment>();
+
+    private final Map<ProjectSegment, ByteArrayOutputStream> streams =
+        new HashMap<ProjectSegment, ByteArrayOutputStream>();
+
+    private final Map<ProjectSegment, PrintStream> printStreams = new HashMap<ProjectSegment, PrintStream>();
+
+    private final ByteArrayOutputStream defaultOutputStreamForUnknownData = new ByteArrayOutputStream();
+
+    private final PrintStream defaultPringStream = new PrintStream( defaultOutputStreamForUnknownData );
+
+    private final Set<ProjectSegment> completedBuilds = Collections.synchronizedSet( new HashSet<ProjectSegment>() );
+
+    private volatile ProjectSegment currentBuild;
+
+    private final PrintStream originalSystemOUtStream;
+
+    private final ConsolePrinter printer;
+
+    /**
+     * A simple but safe solution for printing to the console.
+     */
+
+    class ConsolePrinter
+        implements Runnable
+    {
+        public volatile boolean running;
+
+        private final ProjectBuildList projectBuildList;
+
+        ConsolePrinter( ProjectBuildList projectBuildList )
+        {
+            this.projectBuildList = projectBuildList;
+        }
+
+        public void run()
+        {
+            running = true;
+            for ( ProjectSegment projectBuild : projectBuildList )
+            {
+                final PrintStream projectStream = printStreams.get( projectBuild );
+                ByteArrayOutputStream projectOs = streams.get( projectBuild );
+
+                do
+                {
+                    synchronized ( projectStream )
+                    {
+                        try
+                        {
+                            projectStream.wait( 100 );
+                        }
+                        catch ( InterruptedException e )
+                        {
+                            throw new RuntimeException( e );
+                        }
+                        try
+                        {
+                            projectOs.writeTo( originalSystemOUtStream );
+                        }
+                        catch ( IOException e )
+                        {
+                            throw new RuntimeException( e );
+                        }
+
+                        projectOs.reset();
+                    }
+                }
+                while ( !completedBuilds.contains( projectBuild ) );
+            }
+            running = false;
+        }
+
+        /*
+        Wait until we are sure the print-stream thread is running.
+         */
+
+        public void waitUntilRunning( boolean expect )
+        {
+            while ( !running == expect )
+            {
+                try
+                {
+                    Thread.sleep( 10 );
+                }
+                catch ( InterruptedException e )
+                {
+                    throw new RuntimeException( e );
+                }
+            }
+        }
+    }
+
+    public ThreadOutputMuxer( ProjectBuildList segmentChunks, PrintStream originalSystemOut )
+    {
+        projects = segmentChunks.iterator();
+        for ( ProjectSegment segmentChunk : segmentChunks )
+        {
+            final ByteArrayOutputStream value = new ByteArrayOutputStream();
+            streams.put( segmentChunk, value );
+            printStreams.put( segmentChunk, new PrintStream( value ) );
+        }
+        setNext();
+        this.originalSystemOUtStream = originalSystemOut;
+        System.setOut( new ThreadBoundPrintStream( this.originalSystemOUtStream ) );
+        printer = new ConsolePrinter( segmentChunks );
+        new Thread( printer ).start();
+        printer.waitUntilRunning( true );
+    }
+
+    public void close()
+    {
+        printer.waitUntilRunning( false );
+        System.setOut( this.originalSystemOUtStream );
+    }
+
+    private void setNext()
+    {
+        currentBuild = projects.hasNext() ? projects.next() : null;
+    }
+
+    private boolean ownsRealOutputStream( ProjectSegment projectBuild )
+    {
+        return projectBuild.equals( currentBuild );
+    }
+
+    private PrintStream getThreadBoundPrintStream()
+    {
+        ProjectSegment threadProject = projectBuildThreadLocal.get();
+        if ( threadProject == null )
+        {
+            return defaultPringStream;
+        }
+        if ( ownsRealOutputStream( threadProject ) )
+        {
+            return originalSystemOUtStream;
+        }
+        return printStreams.get( threadProject );
+    }
+
+    public void associateThreadWithProjectSegment( ProjectSegment projectBuild )
+    {
+        projectBuildThreadLocal.set( projectBuild );
+    }
+
+    public void setThisModuleComplete( ProjectSegment projectBuild )
+    {
+        completedBuilds.add( projectBuild );
+        PrintStream stream = printStreams.get( projectBuild );
+        synchronized ( stream )
+        {
+            stream.notifyAll();
+        }
+        disconnectThreadFromProject();
+    }
+
+    private void disconnectThreadFromProject()
+    {
+        projectBuildThreadLocal.remove();
+    }
+
+    private class ThreadBoundPrintStream
+        extends PrintStream
+    {
+
+        public ThreadBoundPrintStream( PrintStream systemOutStream )
+        {
+            super( systemOutStream );
+        }
+
+        private PrintStream getOutputStreamForCurrentThread()
+        {
+            return getThreadBoundPrintStream();
+        }
+
+        @Override
+        public void println()
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.println();
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( char c )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( c );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( char x )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.println( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( double d )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( d );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( double x )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.println( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( float f )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( f );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( float x )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.println( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( int i )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( i );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( int x )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.println( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( long l )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( l );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( long x )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( boolean b )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( b );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( boolean x )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( char s[] )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( s );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( char x[] )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( Object obj )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( obj );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( Object x )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.println( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void print( String s )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.print( s );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void println( String x )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.println( x );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void write( byte b[], int off, int len )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.write( b, off, len );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void close()
+        {
+            getOutputStreamForCurrentThread().close();
+        }
+
+        @Override
+        public void flush()
+        {
+            getOutputStreamForCurrentThread().flush();
+        }
+
+        @Override
+        public void write( int b )
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.write( b );
+                currentStream.notifyAll();
+            }
+        }
+
+        @Override
+        public void write( byte b[] )
+            throws IOException
+        {
+            final PrintStream currentStream = getOutputStreamForCurrentThread();
+            synchronized ( currentStream )
+            {
+                currentStream.write( b );
+                currentStream.notifyAll();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/097cc8d2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ThreadOutputMuxerTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ThreadOutputMuxerTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ThreadOutputMuxerTest.java
deleted file mode 100644
index f040566..0000000
--- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ThreadOutputMuxerTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.apache.maven.lifecycle.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to you 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;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.lifecycle.LifecycleNotFoundException;
-import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
-import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
-import org.apache.maven.plugin.InvalidPluginDescriptorException;
-import org.apache.maven.plugin.MojoNotFoundException;
-import org.apache.maven.plugin.PluginDescriptorParsingException;
-import org.apache.maven.plugin.PluginNotFoundException;
-import org.apache.maven.plugin.PluginResolutionException;
-import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
-import org.apache.maven.plugin.version.PluginVersionResolutionException;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-/**
- * @author Kristian Rosenvold
- */
-public class ThreadOutputMuxerTest
-    extends TestCase
-{
-
-    final String paid = "Paid";
-
-    final String in = "In";
-
-    final String full = "Full";
-
-    public void testSingleThreaded()
-        throws Exception
-    {
-        ProjectBuildList src = getProjectBuildList();
-        ProjectBuildList projectBuildList =
-            new ProjectBuildList( Arrays.asList( src.get( 0 ), src.get( 1 ), src.get( 2 ) ) );
-
-        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-        PrintStream systemOut = new PrintStream( byteArrayOutputStream );
-        ThreadOutputMuxer threadOutputMuxer = new ThreadOutputMuxer( projectBuildList, systemOut );
-
-        threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 0 ) );
-        System.out.print( paid );  // No, this does not print to system.out. It's part of the test
-        assertEquals( paid.length(), byteArrayOutputStream.size() );
-        threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 1 ) );
-        System.out.print( in );  // No, this does not print to system.out. It's part of the test
-        assertEquals( paid.length(), byteArrayOutputStream.size() );
-        threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 2 ) );
-        System.out.print( full ); // No, this does not print to system.out. It's part of the test
-        assertEquals( paid.length(), byteArrayOutputStream.size() );
-
-        threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 0 ) );
-        threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 1 ) );
-        threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 2 ) );
-        threadOutputMuxer.close();
-        assertEquals( ( paid + in + full ).length(), byteArrayOutputStream.size() );
-    }
-
-    public void testMultiThreaded()
-        throws Exception
-    {
-        ProjectBuildList projectBuildList = getProjectBuildList();
-
-        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-        PrintStream systemOut = new PrintStream( byteArrayOutputStream );
-        final ThreadOutputMuxer threadOutputMuxer = new ThreadOutputMuxer( projectBuildList, systemOut );
-
-        final List<String> stringList =
-            Arrays.asList( "Thinkin", "of", "a", "master", "plan", "Cuz", "ain’t", "nuthin", "but", "sweat", "inside",
-                           "my", "hand" );
-        Iterator<String> lyrics = stringList.iterator();
-
-        ExecutorService executor = Executors.newFixedThreadPool( 10 );
-        CompletionService<ProjectSegment> service = new ExecutorCompletionService<ProjectSegment>( executor );
-
-        List<Future<ProjectSegment>> futures = new ArrayList<Future<ProjectSegment>>();
-        for ( ProjectSegment projectBuild : projectBuildList )
-        {
-            final Future<ProjectSegment> buildFuture =
-                service.submit( new Outputter( threadOutputMuxer, projectBuild, lyrics.next() ) );
-            futures.add( buildFuture );
-        }
-
-        for ( Future<ProjectSegment> future : futures )
-        {
-            future.get();
-        }
-        int expectedLength = 0;
-        for ( int i = 0; i < projectBuildList.size(); i++ )
-        {
-            expectedLength += stringList.get( i ).length();
-        }
-
-        threadOutputMuxer.close();
-        final byte[] bytes = byteArrayOutputStream.toByteArray();
-        String result = new String( bytes );
-        assertEquals( result, expectedLength, bytes.length );
-
-
-    }
-
-    class Outputter
-        implements Callable<ProjectSegment>
-    {
-        private final ThreadOutputMuxer threadOutputMuxer;
-
-        private final ProjectSegment item;
-
-        private final String response;
-
-        Outputter( ThreadOutputMuxer threadOutputMuxer, ProjectSegment item, String response )
-        {
-            this.threadOutputMuxer = threadOutputMuxer;
-            this.item = item;
-            this.response = response;
-        }
-
-        public ProjectSegment call()
-            throws Exception
-        {
-            threadOutputMuxer.associateThreadWithProjectSegment( item );
-            System.out.print( response );
-            threadOutputMuxer.setThisModuleComplete( item );
-            return item;
-        }
-    }
-
-
-    private ProjectBuildList getProjectBuildList()
-        throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException,
-        NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
-        LifecyclePhaseNotFoundException, LifecycleNotFoundException
-    {
-        final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
-        return ProjectDependencyGraphStub.getProjectBuildList( session );
-    }
-}

http://git-wip-us.apache.org/repos/asf/maven/blob/097cc8d2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxerTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxerTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxerTest.java
new file mode 100644
index 0000000..dc75a94
--- /dev/null
+++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxerTest.java
@@ -0,0 +1,167 @@
+package org.apache.maven.lifecycle.internal.builder.multithreaded;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you 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;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.lifecycle.LifecycleNotFoundException;
+import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
+import org.apache.maven.lifecycle.internal.ProjectBuildList;
+import org.apache.maven.lifecycle.internal.ProjectSegment;
+import org.apache.maven.lifecycle.internal.builder.multithreaded.ThreadOutputMuxer;
+import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
+import org.apache.maven.plugin.InvalidPluginDescriptorException;
+import org.apache.maven.plugin.MojoNotFoundException;
+import org.apache.maven.plugin.PluginDescriptorParsingException;
+import org.apache.maven.plugin.PluginNotFoundException;
+import org.apache.maven.plugin.PluginResolutionException;
+import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class ThreadOutputMuxerTest
+    extends TestCase
+{
+
+    final String paid = "Paid";
+
+    final String in = "In";
+
+    final String full = "Full";
+
+    public void testSingleThreaded()
+        throws Exception
+    {
+        ProjectBuildList src = getProjectBuildList();
+        ProjectBuildList projectBuildList =
+            new ProjectBuildList( Arrays.asList( src.get( 0 ), src.get( 1 ), src.get( 2 ) ) );
+
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        PrintStream systemOut = new PrintStream( byteArrayOutputStream );
+        ThreadOutputMuxer threadOutputMuxer = new ThreadOutputMuxer( projectBuildList, systemOut );
+
+        threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 0 ) );
+        System.out.print( paid );  // No, this does not print to system.out. It's part of the test
+        assertEquals( paid.length(), byteArrayOutputStream.size() );
+        threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 1 ) );
+        System.out.print( in );  // No, this does not print to system.out. It's part of the test
+        assertEquals( paid.length(), byteArrayOutputStream.size() );
+        threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 2 ) );
+        System.out.print( full ); // No, this does not print to system.out. It's part of the test
+        assertEquals( paid.length(), byteArrayOutputStream.size() );
+
+        threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 0 ) );
+        threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 1 ) );
+        threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 2 ) );
+        threadOutputMuxer.close();
+        assertEquals( ( paid + in + full ).length(), byteArrayOutputStream.size() );
+    }
+
+    public void testMultiThreaded()
+        throws Exception
+    {
+        ProjectBuildList projectBuildList = getProjectBuildList();
+
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        PrintStream systemOut = new PrintStream( byteArrayOutputStream );
+        final ThreadOutputMuxer threadOutputMuxer = new ThreadOutputMuxer( projectBuildList, systemOut );
+
+        final List<String> stringList =
+            Arrays.asList( "Thinkin", "of", "a", "master", "plan", "Cuz", "ain’t", "nuthin", "but", "sweat", "inside",
+                           "my", "hand" );
+        Iterator<String> lyrics = stringList.iterator();
+
+        ExecutorService executor = Executors.newFixedThreadPool( 10 );
+        CompletionService<ProjectSegment> service = new ExecutorCompletionService<ProjectSegment>( executor );
+
+        List<Future<ProjectSegment>> futures = new ArrayList<Future<ProjectSegment>>();
+        for ( ProjectSegment projectBuild : projectBuildList )
+        {
+            final Future<ProjectSegment> buildFuture =
+                service.submit( new Outputter( threadOutputMuxer, projectBuild, lyrics.next() ) );
+            futures.add( buildFuture );
+        }
+
+        for ( Future<ProjectSegment> future : futures )
+        {
+            future.get();
+        }
+        int expectedLength = 0;
+        for ( int i = 0; i < projectBuildList.size(); i++ )
+        {
+            expectedLength += stringList.get( i ).length();
+        }
+
+        threadOutputMuxer.close();
+        final byte[] bytes = byteArrayOutputStream.toByteArray();
+        String result = new String( bytes );
+        assertEquals( result, expectedLength, bytes.length );
+
+
+    }
+
+    class Outputter
+        implements Callable<ProjectSegment>
+    {
+        private final ThreadOutputMuxer threadOutputMuxer;
+
+        private final ProjectSegment item;
+
+        private final String response;
+
+        Outputter( ThreadOutputMuxer threadOutputMuxer, ProjectSegment item, String response )
+        {
+            this.threadOutputMuxer = threadOutputMuxer;
+            this.item = item;
+            this.response = response;
+        }
+
+        public ProjectSegment call()
+            throws Exception
+        {
+            threadOutputMuxer.associateThreadWithProjectSegment( item );
+            System.out.print( response );
+            threadOutputMuxer.setThisModuleComplete( item );
+            return item;
+        }
+    }
+
+
+    private ProjectBuildList getProjectBuildList()
+        throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException,
+        NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
+        LifecyclePhaseNotFoundException, LifecycleNotFoundException
+    {
+        final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
+        return ProjectDependencyGraphStub.getProjectBuildList( session );
+    }
+}