Refine search
/** * check the file given by getFile(). */ private void doit() { Commandline commandLine = new Commandline(); // build the command line from what we got the format is // ccm co /t .. files // as specified in the CCM.EXE help commandLine.setExecutable(getCcmCommand()); commandLine.createArgument().setValue(getCcmAction()); checkOptions(commandLine); int result = run(commandLine); if (Execute.isFailure(result)) { throw new BuildException("Failed executing: " + commandLine, getLocation()); } }
private void verifyArguments(Commandline cmd) { if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { for (String arg : cmd.getArguments()) { if ("-Xnew".equals(arg)) { throw new BuildException("JDK9 has removed support for -Xnew"); } } } }
/** * Run the command. * @param cmd the command line to use. * @param out the output stream handler to use. * @return the exit code of the command. */ protected int runCmd(Commandline cmd, ExecuteStreamHandler out) { try { Project aProj = getProject(); Execute exe = new Execute(out); exe.setAntRun(aProj); exe.setWorkingDirectory(aProj.getBaseDir()); exe.setCommandline(cmd.getCommandline()); return exe.execute(); } catch (IOException e) { String msg = "Failed executing: " + cmd.toString() + ". Exception: " + e.getMessage(); throw new BuildException(msg, getLocation()); } }
/** * Return the command line as a string. * @return the command line. */ @Override public String toString() { return toString(getCommandline()); }
/** * Return a String that describes the arguments suitable for * verbose output before a call to <code>Runtime.exec(String[])</code>. * @param line the Commandline whose arguments to describe. * @return a string that describes the arguments. * @since Ant 1.5 */ public static String describeArguments(Commandline line) { return describeArguments(line.getArguments()); }
/** * 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 void generalJavadocArguments(final Commandline toExecute) { if (doctitle != null) { toExecute.createArgument().setValue("-doctitle"); toExecute.createArgument().setValue(expand(doctitle.getText())); toExecute.createArgument().setValue("-header"); toExecute.createArgument().setValue(expand(header.getText())); toExecute.createArgument().setValue("-footer"); toExecute.createArgument().setValue(expand(footer.getText())); toExecute.createArgument().setValue("-bottom"); toExecute.createArgument().setValue(expand(bottom.getText())); classpath = new Path(getProject()).concatSystemClasspath("last"); } else { classpath = classpath.concatSystemClasspath("ignore"); if (classpath.size() > 0) { toExecute.createArgument().setValue("-classpath"); toExecute.createArgument().setPath(classpath); toExecute.createArgument().setValue("-version"); toExecute.createArgument().setValue("-author"); throw new BuildException("destdir attribute must be set!");
/** * The file containing the diff output; required. * @param file the file containing the diff output */ public void setPatchfile(File file) { if (!file.exists()) { throw new BuildException("patchfile " + file + " doesn\'t exist", getLocation()); } cmd.createArgument().setValue("-i"); cmd.createArgument().setFile(file); havePatchfile = true; }
static Commandline setupJavahCommand(Javah javah) { Commandline cmd = new Commandline(); cmd.createArgument().setValue("-d"); cmd.createArgument().setFile(javah.getDestdir()); cmd.createArgument().setValue("-o"); cmd.createArgument().setFile(javah.getOutputfile()); cmd.createArgument().setValue("-classpath"); cmd.createArgument().setPath(javah.getClasspath()); cmd.createArgument().setValue("-verbose"); cmd.createArgument().setValue("-old"); cmd.createArgument().setValue("-force"); throw new BuildException( "stubs only available in old mode.", javah.getLocation()); cmd.createArgument().setValue("-stubs"); bcp = bcp.concatSystemBootClasspath("ignore"); if (bcp.size() > 0) { cmd.createArgument().setValue("-bootclasspath"); cmd.createArgument().setPath(bcp); cmd.addArguments(javah.getCurrentArgs());
Commandline cmd = new Commandline(); Path classpath = new Path(project); if (!p.isEmpty()) { classpath.append(p); cmd.setExecutable(exec == null ? "gcj" : exec); cmd.createArgument().setValue("-d"); cmd.createArgument().setFile(destDir); throw new BuildException( "Can't make output directories. Maybe permission is wrong."); cmd.createArgument().setValue("-classpath"); cmd.createArgument().setPath(classpath); cmd.createArgument().setValue("--encoding=" + encoding); cmd.createArgument().setValue("-g1"); cmd.createArgument().setValue("-O"); cmd.createArgument().setValue("-C"); cmd.createArgument().setValue("-fsource=" + source); cmd.createArgument().setValue("-ftarget=" + target);
if (Commandline.toString(args).length() > COMMAND_LINE_LIMIT && firstFileName >= 0) { try { throw new BuildException("Error creating temporary file", e, location); final Execute exe = new Execute( new LogStreamHandler(attributes, Project.MSG_INFO, exe.setVMLauncher(true); exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(commandArray); exe.execute(); return exe.getExitValue(); } catch (final IOException e) { throw new BuildException("Error running " + args[0] + " compiler", e, location);
cmdl.setClassname(javaCommand.getExecutable()); for (String arg : javaCommand.getArguments()) { cmdl.createArgument().setValue(arg); cmdl.createClasspath(pc.getProject()).append(classpath); = new Execute(redirector.createHandler(), timeout == null ? null : new ExecuteWatchdog(timeout)); exe.setAntRun(pc.getProject()); if (Os.isFamily("openvms")) { setupCommandLineForVMS(exe, cmdl.getCommandline()); } else { exe.setCommandline(cmdl.getCommandline()); return rc; } catch (IOException e) { throw new BuildException(e); } finally { timedOut = exe.killedProcess();
Path p = getClasspath(); if (getJspc().getClasspath() != null) { getProject().log("using user supplied classpath: " + p, Project.MSG_DEBUG); } else { getProject().log("using system classpath: " + p, Project.MSG_DEBUG); java.setDir(getProject().getBaseDir()); java.setClassname("org.apache.jasper.JspC"); for (String arg : cmd.getJavaCommand().getArguments()) { java.createArg().setValue(arg); throw (BuildException) ex; throw new BuildException("Error running jsp compiler: ", ex, getJspc().getLocation()); } finally {
toExecute.createArgument().setValue("-tag"); toExecute.createArgument().setValue(ta.getParameter()); } else { new FileReader(tagDefFile))) { in.lines().forEach(line -> { toExecute.createArgument().setValue("-tag"); toExecute.createArgument().setValue(line); }); } catch (final IOException ioe) { throw new BuildException("Couldn't read tag file from " + tagDefFile.getAbsolutePath(), ioe); toExecute.createArgument().setValue("-taglet"); toExecute.createArgument().setValue(tagletInfo .getName()); if (tagletInfo.getPath() != null) { final Path tagletPath = tagletInfo.getPath() .concatSystemClasspath("ignore"); if (!tagletPath.isEmpty()) { toExecute.createArgument() .setValue("-tagletpath"); toExecute.createArgument().setPath(tagletPath); : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE); if (sourceArg != null) { toExecute.createArgument().setValue("-source"); toExecute.createArgument().setValue(sourceArg);
Commandline commandLine = new Commandline(); commandLine.setExecutable(getExecutable(PCLI_EXE)); commandLine.createArgument().setValue("lvf"); commandLine.createArgument().setValue("-z"); commandLine.createArgument().setValue("-aw"); if (getWorkspace() != null) { commandLine.createArgument().setValue("-sp" + getWorkspace()); commandLine.createArgument().setValue("-pr" + getRepository()); commandLine.createArgument().setValue("-id" + uid); commandLine.createArgument().setValue(getPvcsproject()); commandLine.createArgument().setValue(projectName); 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, if (Execute.isFailure(result) && !ignorerc) { String msg = "Failed executing: " + commandLine.toString(); throw new BuildException(msg, getLocation()); commandLine.clearArgs(); commandLine.setExecutable(getExecutable(GET_EXE));
optionsTmpFile = FILE_UTILS.createTempFile( "javadocOptions", "", null, true, true); final String[] listOpt = toExecute.getArguments(); toExecute.clearArgs(); toExecute.createArgument().setValue( "@" + optionsTmpFile.getAbsolutePath()); try (BufferedWriter optionsListWriter = new BufferedWriter( for (final String opt : listOpt) { if (opt.startsWith("-J-")) { toExecute.createArgument().setValue(opt); } else if (opt.startsWith("-")) { optionsListWriter.write(opt); optionsTmpFile.delete(); throw new BuildException( "Error creating or writing temporary file for javadoc options", ex, getLocation());
/** * helper method to execute our command on VMS. * @param cmd Commandline * @param firstFileName int * @return boolean */ private boolean execOnVMS(Commandline cmd, int firstFileName) { File vmsFile = null; try { vmsFile = JavaEnvUtils.createVmsJavaOptionFile(cmd.getArguments()); String[] commandLine = {cmd.getExecutable(), "-V", vmsFile.getPath()}; return 0 == executeExternalCompile(commandLine, firstFileName, true); } catch (IOException e) { throw new BuildException( "Failed to create a temporary file for \"-V\" switch"); } finally { FileUtils.delete(vmsFile); } }
/** * Execute the created command line. * * @throws BuildException on error. */ @Override public void execute() throws BuildException { int result = 0; buildCmdLine(); result = run(commandLine); if (result == ERROR_EXIT_STATUS) { // This is the exit status String msg = "Failed executing: " + commandLine.toString(); throw new BuildException(msg, getLocation()); } }
} else { loader = getRmic().getProject().createClassLoader(getRmic().getClasspath()); c = Class.forName(WLRMIC_CLASSNAME, true, loader); doRmic.invoke(null, (Object) cmd.getArguments()); return true; } catch (ClassNotFoundException ex) { throw new BuildException(ERROR_NO_WLRMIC_ON_CLASSPATH, getRmic().getLocation()); } catch (Exception ex) { if (ex instanceof BuildException) { throw (BuildException) ex; } else { throw new BuildException(ERROR_WLRMIC_FAILED, ex, getRmic().getLocation());
private Commandline setupKaffehCommand(Javah javah) { Commandline cmd = new Commandline(); cmd.setExecutable(JavaEnvUtils.getJdkExecutable("kaffeh")); if (javah.getDestdir() != null) { cmd.createArgument().setValue("-d"); cmd.createArgument().setFile(javah.getDestdir()); } if (javah.getOutputfile() != null) { cmd.createArgument().setValue("-o"); cmd.createArgument().setFile(javah.getOutputfile()); } Path cp = new Path(javah.getProject()); if (javah.getBootclasspath() != null) { cp.append(javah.getBootclasspath()); } cp = cp.concatSystemBootClasspath("ignore"); if (javah.getClasspath() != null) { cp.append(javah.getClasspath()); } if (cp.size() > 0) { cmd.createArgument().setValue("-classpath"); cmd.createArgument().setPath(cp); } if (!javah.getOld()) { cmd.createArgument().setValue("-jni"); } cmd.addArguments(javah.getCurrentArgs()); javah.logAndAddFiles(cmd); return cmd; }