public static void exec(String command, Path rootFolder) throws IOException, InterruptedException {
		System.out.printf("Executing command (%s)\n", command);

		boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
		ProcessBuilder builder = new ProcessBuilder();
		builder.redirectErrorStream(true);
		if (isWindows) {
			builder.command("cmd.exe", "/c", command);
		} else {
			builder.command("sh", "-c", command);
		}
		builder.directory(rootFolder.toFile());

		Process process = builder.start();
		StreamGobbler streamGobbler = new StreamGobbler(process.getInputStream(), System.out::println);
		Executors.newSingleThreadExecutor().submit(streamGobbler);
		int exitCode = process.waitFor();
		assert exitCode == 0;
	}
public static void exec ( String command , Path rootFolder ) throws IOException , InterruptedException { System . out . printf ( "Executing command (%s)\n" , command ) ; boolean isWindows = System . getProperty ( "os.name" ) . toLowerCase ( ) . startsWith ( "windows" ) ; ProcessBuilder builder = new ProcessBuilder ( ) ; builder . redirectErrorStream ( true ) ; if ( isWindows ) { builder . command ( "cmd.exe" , "/c" , command ) ; } else { builder . command ( "sh" , "-c" , command ) ; } builder . directory ( rootFolder . toFile ( ) ) ; Process process = builder . start ( ) ; StreamGobbler streamGobbler = new StreamGobbler ( process . getInputStream ( ) , System . out :: println ) ; Executors . newSingleThreadExecutor ( ) . submit ( streamGobbler ) ; int exitCode = process . waitFor ( ) ; assert exitCode == 0 ; }
@param command
@param rootFolder
@throws IOException
@throws InterruptedException