1 package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23 import java.io.OutputStream;
24 import org.apache.maven.shared.utils.cli.CommandLineException;
25 import org.apache.maven.shared.utils.cli.Commandline;
26
27
28
29
30
31
32
33
34 public class OutputStreamFlushableCommandline
35 extends Commandline
36 implements FlushReceiverProvider
37 {
38
39
40
41 private final class OutputStreamFlushReceiver
42 implements FlushReceiver
43 {
44 private final OutputStream outputStream;
45
46 private OutputStreamFlushReceiver( OutputStream outputStream )
47 {
48 this.outputStream = outputStream;
49 }
50
51 public void flush()
52 throws IOException
53 {
54 outputStream.flush();
55 }
56 }
57
58 private FlushReceiver flushReceiver;
59
60 @Override
61 public Process execute()
62 throws CommandLineException
63 {
64 Process process = super.execute();
65
66 if ( process.getOutputStream() != null )
67 {
68 flushReceiver = new OutputStreamFlushReceiver( process.getOutputStream() );
69 }
70
71 return process;
72 }
73
74 public FlushReceiver getFlushReceiver()
75 {
76 return flushReceiver;
77 }
78
79 }