3333
3434import java .io .File ;
3535import java .io .IOException ;
36+ import java .io .InputStream ;
3637import java .util .List ;
3738import java .util .ArrayList ;
3839import java .util .Arrays ;
@@ -70,7 +71,7 @@ public static void findBuildPaths() throws Exception {
7071 arduinoPath = new File (buildPath , "build/linux/work/arduino" );
7172 }
7273 if (OSUtils .isWindows ()) {
73- arduinoPath = new File (buildPath , "build/windows/work/arduino .exe" );
74+ arduinoPath = new File (buildPath , "build/windows/work/arduino_debug .exe" );
7475 }
7576 if (OSUtils .isMacOS ()) {
7677 arduinoPath = new File (buildPath ,
@@ -82,10 +83,20 @@ public static void findBuildPaths() throws Exception {
8283 System .out .println ("found arduino: " + arduinoPath );
8384 }
8485
86+ private void consume (InputStream s ) {
87+ new Thread (() -> {
88+ try {
89+ IOUtils .copy (s , System .out );
90+ } catch (IOException e ) {
91+ e .printStackTrace ();
92+ }
93+ }).start ();
94+ }
95+
8596 public Process runArduino (boolean output , boolean success , File wd , String [] extraArgs ) throws IOException , InterruptedException {
8697 Runtime rt = Runtime .getRuntime ();
8798
88- List <String > args = new ArrayList <String >();
99+ List <String > args = new ArrayList <>();
89100 args .add (arduinoPath .getAbsolutePath ());
90101 args .addAll (Arrays .asList (getBaseArgs ()));
91102 args .addAll (Arrays .asList (extraArgs ));
@@ -94,8 +105,8 @@ public Process runArduino(boolean output, boolean success, File wd, String[] ext
94105
95106 Process pr = rt .exec (args .toArray (new String [0 ]), null , wd );
96107 if (output ) {
97- IOUtils . copy (pr .getInputStream (), System . out );
98- IOUtils . copy (pr .getErrorStream (), System . out );
108+ consume (pr .getInputStream ());
109+ consume (pr .getErrorStream ());
99110 }
100111 pr .waitFor ();
101112 if (success )
0 commit comments