private String writeEmulatorStartScriptUnix ( ) throws MojoExecutionException { String filename = SCRIPT_FOLDER + "/android-maven-plugin-emulator-start.sh" ; File sh ; sh = new File ( "/bin/bash" ) ; if ( ! sh . exists ( ) ) { sh = new File ( "/usr/bin/bash" ) ; } if ( ! sh . exists ( ) ) { sh = new File ( "/bin/sh" ) ; } File file = new File ( filename ) ; PrintWriter writer = null ; try { writer = new PrintWriter ( new FileWriter ( file ) ) ; writer . println ( "#!" + sh . getAbsolutePath ( ) ) ; writer . print ( assembleStartCommandLine ( ) ) ; writer . print ( " 1>/dev/null 2>&1 &" ) ; // redirect outputs and run as background task } catch ( IOException e ) { getLog ( ) . error ( "Failure writing file " + filename ) ; } finally { if ( writer != null ) { writer . flush ( ) ; writer . close ( ) ; } } file . setExecutable ( true ) ; return filename ; }
Writes the script to start the emulator in the background for unix based environments .