public void executeScript(final File launchDirectory, final String script, final List<String> args, final File outputFile) throws ScriptException, IOException { final StringBuilder buf = new StringBuilder(); for (final Map.Entry<String, String> entry : this.factory.environment().entrySet()) { if (entry.getValue() != null) { buf.append("ENV['") .append(entry.getKey()) .append("']='") .append(entry.getValue()) .append("';"); } } buf.append(script); args.add(0, "-e"); args.add(1, buf.toString()); args.add(2, "--"); doExecute(launchDirectory, outputFile, args, false); } }
private void doExecute(final File launchDirectory, final File outputFile, final List<String> args, final boolean warn) throws ScriptException, IOException { final String currentDir; if (launchDirectory != null) { currentDir = System.getProperty("user.dir"); logger.debug("launch directory: " + launchDirectory.getAbsolutePath()); System.setProperty("user.dir", launchDirectory.getAbsolutePath()); } else { currentDir = null; } args.addAll(0, this.factory.switches.list); if (warn) { if (this.factory.jvmArgs.list.size() > 0) { this.logger.warn("have to ignore jvm arguments and properties in the current setup"); } if (this.factory.environment().size() > 0) { this.logger.warn("have to ignore environment settings in the current setup"); } } final PrintStream output = System.out; ClassLoader current = null; try { if (outputFile != null) { final PrintStream writer = new PrintStream(outputFile);