/** * Return a String that describes the command and arguments suitable for * verbose output before a call to <code>Runtime.exec(String[])</code>. * @return a string that describes the command and arguments. * @since Ant 1.5 */ public String describeCommand() { return describeCommand(this); }
/** * Return a String that describes the command and arguments suitable for * verbose output before a call to <code>Runtime.exec(String[])</code>. * @return the description string. * @since Ant 1.5 */ public String describeCommand() { return Commandline.describeCommand(getCommandline()); }
/** * Return a String that describes the java command and arguments * for in-VM executions. * * <p>The class name is the executable in this context.</p> * @return the description string. * @since Ant 1.5 */ public String describeJavaCommand() { return Commandline.describeCommand(getJavaCommand()); }
/** * Return a String that describes the command and arguments suitable for * verbose output before a call to <code>Runtime.exec(String[])</code>. * @param line the Commandline to describe. * @return a string that describes the command and arguments. * @since Ant 1.5 */ public static String describeCommand(Commandline line) { return describeCommand(line.getCommandline()); }
private String executeToString(Execute execute) { String cmdLine = Commandline.describeCommand(execute .getCommandline()); StringBuilder buf = removeCvsPassword(cmdLine); String[] variableArray = execute.getEnvironment(); if (variableArray != null) { buf.append(Arrays.stream(variableArray).map(variable -> String.format("%n\t%s", variable)) .collect(Collectors.joining("", String.format("%n%nenvironment:%n"), ""))); } return buf.toString(); }
/** * Launches the given command in a new process. * * @param project * The project that the command is part of. * @param cmd * The command to execute. * @param env * The environment for the new process. If null, the * environment of the current process is used. * @return the created Process. * @throws IOException * if attempting to run a command in a specific directory. */ public Process exec(Project project, String[] cmd, String[] env) throws IOException { if (project != null) { project.log("Execute:CommandLauncher: " + Commandline.describeCommand(cmd), Project.MSG_DEBUG); } return Runtime.getRuntime().exec(cmd, env); }
if (project != null) { project.log("Execute:Java13CommandLauncher: " + Commandline.describeCommand(cmd), Project.MSG_DEBUG);
/** * Run the command using the given Execute instance. This may be * overridden by subclasses. * * @param exe instance of Execute to run. * * @throws BuildException if the new process could not be started * only if failIfExecFails is set to true (the default). */ protected void runExec(Execute exe) throws BuildException { // show the command log(cmdl.describeCommand(), Project.MSG_VERBOSE); exe.setCommandline(cmdl.getCommandline()); try { runExecute(exe); } catch (IOException e) { if (failIfExecFails) { throw new BuildException("Execute failed: " + e.toString(), e, getLocation()); } log("Execute failed: " + e.toString(), Project.MSG_ERR); } finally { // close the output file if required logFlush(); } }
/** {@inheritDoc} */ @Override public boolean execute() throws BuildException { getRmic().log("Using Kaffe rmic", Project.MSG_VERBOSE); Commandline cmd = setupRmicCommand(); Class<?> c = getRmicClass(); if (c == null) { StringBuilder buf = new StringBuilder( "Cannot use Kaffe rmic, as it is not available. None of "); for (String className : RMIC_CLASSNAMES) { if (buf.length() > 0) { buf.append(", "); } buf.append(className); } buf.append( " have been found. A common solution is to set the environment variable JAVA_HOME or CLASSPATH."); throw new BuildException(buf.toString(), getRmic().getLocation()); } cmd.setExecutable(c.getName()); if (!c.getName().equals(RMIC_CLASSNAMES[RMIC_CLASSNAMES.length - 1])) { //NOSONAR // only supported since Kaffe 1.1.2 cmd.createArgument().setValue("-verbose"); getRmic().log(Commandline.describeCommand(cmd)); } ExecuteJava ej = new ExecuteJava(); ej.setJavaCommand(cmd); return ej.fork(getRmic()) == 0; }
log(Commandline.describeCommand(command), Project.MSG_VERBOSE); exe.setCommandline(command); if (redirectorElement != null) { System.arraycopy(b, currentOffset, cb, 0, currentAmount); String[] command = getCommandline(cs, cb); log(Commandline.describeCommand(command), Project.MSG_VERBOSE); exe.setCommandline(command); if (redirectorElement != null) {
/** * A utility method that runs an external command. Writes the output and * error streams of the command to the project log. * * @param task The task that the command is part of. Used for logging * @param cmdline The command to execute. * @throws BuildException if the command does not exit successfully. */ public static void runCommand(Task task, String... cmdline) throws BuildException { try { task.log(Commandline.describeCommand(cmdline), Project.MSG_VERBOSE); Execute exe = new Execute( new LogStreamHandler(task, Project.MSG_INFO, Project.MSG_ERR)); exe.setAntRun(task.getProject()); exe.setCommandline(cmdline); int retval = exe.execute(); if (isFailure(retval)) { throw new BuildException(cmdline[0] + " failed with return code " + retval, task.getLocation()); } } catch (IOException exc) { throw new BuildException("Could not launch " + cmdline[0] + ": " + exc, task.getLocation()); } }
for (String srcFile : fileNames) { String[] command = getCommandline(srcFile, base); log(Commandline.describeCommand(command), Project.MSG_VERBOSE); exe.setCommandline(command); log(Commandline.describeCommand(command), Project.MSG_VERBOSE); exe.setCommandline(command);
log(toExecute.describeCommand(), Project.MSG_VERBOSE); try { int returncode = exe.execute();
OutputStream fos = Files.newOutputStream(tmp.toPath()); tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log"); log(commandLine.describeCommand(), Project.MSG_VERBOSE); try { result = runCmd(commandLine, new PumpStreamHandler(fos,
commandLine2.createArgument().setValue(getTask()); log(commandLine.describeCommand(), Project.MSG_DEBUG);
toExecute.createArgument().setValue("@" + packageList); log(toExecute.describeCommand(), Project.MSG_VERBOSE);
log(commandline.describeCommand(), Project.MSG_DEBUG); execTask.setCommandline(commandline.getCommandline()); int result = execTask.execute();
private String executeToString(Execute execute) { StringBuffer stringBuffer = new StringBuffer(Commandline.describeCommand(execute .getCommandline())); String newLine = StringUtils.LINE_SEP; String[] variableArray = execute.getEnvironment(); if (variableArray != null) { stringBuffer.append(newLine); stringBuffer.append(newLine); stringBuffer.append("environment:"); stringBuffer.append(newLine); for (int z = 0; z < variableArray.length; z++) { stringBuffer.append(newLine); stringBuffer.append("\t"); stringBuffer.append(variableArray[z]); } } return stringBuffer.toString(); }
private String executeToString(Execute execute) { StringBuffer stringBuffer = new StringBuffer(Commandline.describeCommand(execute .getCommandline())); String newLine = StringUtils.LINE_SEP; String[] variableArray = execute.getEnvironment(); if (variableArray != null) { stringBuffer.append(newLine); stringBuffer.append(newLine); stringBuffer.append("environment:"); stringBuffer.append(newLine); for (int z = 0; z < variableArray.length; z++) { stringBuffer.append(newLine); stringBuffer.append("\t"); stringBuffer.append(variableArray[z]); } } return stringBuffer.toString(); }
logger.debug(Commandline.describeCommand(cmdArray)); if (environment != null && environment.size() > 0) { ProcessBuilder processBuilder = new ProcessBuilder(cmdArray);