/** * Set the name of the executable program. * @param value the name of the executable program. */ public void setExecutable(String value) { this.executable = value; cmdl.setExecutable(value); }
/** * Set the source-file, to execute as single file source programs, a feature, available * since Java 11. * * @param sourceFile The path to the source file * @since Ant 1.10.5 */ public void setSourceFile(final String sourceFile) { this.executableType = ExecutableType.SOURCE_FILE; javaCommand.setExecutable(sourceFile); }
/** * Set the executable to run. All file separators in the string * are converted to the platform specific value. * @param executable the String executable name. */ public void setExecutable(String executable) { setExecutable(executable, true); }
/** * Set a jar file to execute via the -jar option. * @param jarpathname the pathname of the jar to execute. */ public void setJar(String jarpathname) { javaCommand.setExecutable(jarpathname); executableType = ExecutableType.JAR; }
/** * Set the executable used to start the new JVM. * @param vm the executable to use. */ public void setVm(String vm) { vmCommand.setExecutable(vm); }
/** * Set the classname to execute. * @param classname the fully qualified classname. */ public void setClassname(String classname) { if (executableType == ExecutableType.MODULE) { javaCommand.setExecutable(createModuleClassPair( parseModuleFromModuleClassPair(javaCommand.getExecutable()), classname), false); } else { javaCommand.setExecutable(classname); executableType = ExecutableType.CLASS; } }
/** * Set the module to execute. * @param module the module name. * @since 1.9.7 */ public void setModule(final String module) { if (executableType == null) { javaCommand.setExecutable(module); } else { switch (executableType) { case JAR: javaCommand.setExecutable(module, false); break; case CLASS: javaCommand.setExecutable(createModuleClassPair(module, javaCommand.getExecutable()), false); break; case MODULE: javaCommand.setExecutable(createModuleClassPair(module, parseClassFromModuleClassPair(javaCommand.getExecutable())), false); break; default: } } executableType = ExecutableType.MODULE; }
/** {@inheritDoc} */ @Override protected boolean run(Commandline cmd, ProjectComponent log) throws BuildException { ExecuteJava ej = new ExecuteJava(); Class<?> c = getN2aClass(); if (c == null) { throw new BuildException( "Couldn't load Kaffe's Native2Ascii class"); } cmd.setExecutable(c.getName()); ej.setJavaCommand(cmd); ej.execute(log.getProject()); // otherwise ExecuteJava has thrown an exception return true; }
/** * Create a command line from a string. * @param toProcess the line: the first element becomes the executable, the rest * the arguments. */ public Commandline(String toProcess) { super(); String[] tmp = translateCommandline(toProcess); if (tmp != null && tmp.length > 0) { setExecutable(tmp[0]); for (int i = 1; i < tmp.length; i++) { createArgument().setValue(tmp[i]); } } }
/** * Run the compilation. * @return true if the compilation succeeded * @exception BuildException if the compilation has problems. */ @Override public boolean execute() throws BuildException { attributes.log("Using kjc compiler", Project.MSG_VERBOSE); Commandline cmd = setupKjcCommand(); cmd.setExecutable("at.dms.kjc.Main"); ExecuteJava ej = new ExecuteJava(); ej.setJavaCommand(cmd); return ej.fork(getJavac()) == 0; }
/** * Do the work. * * @throws BuildException in a number of circumstances: * <ul> * <li>if failIfExecFails is set to true and the process cannot be started</li> * <li>the java13command launcher can send build exceptions</li> * <li>this list is not exhaustive or limitative</li> * </ul> */ @Override public void execute() throws BuildException { // Quick fail if this is not a valid OS for the command if (!isValidOs()) { return; } File savedDir = dir; // possibly altered in prepareExec cmdl.setExecutable(resolveExecutable(executable, searchPath)); checkConfiguration(); try { runExec(prepareExec()); } finally { dir = savedDir; } }
/** * 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()); } }
/** * Performs a compile using the sj compiler from Symantec. * @return true if the compilation succeeded * @throws BuildException on error */ @Override public boolean execute() throws BuildException { attributes.log("Using symantec java compiler", Project.MSG_VERBOSE); Commandline cmd = setupJavacCommand(); String exec = getJavac().getExecutable(); cmd.setExecutable(exec == null ? "sj" : exec); int firstFileName = cmd.size() - compileList.length; return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; }
/** * Executes the task. * <p> * Builds a command line to execute ccm and then calls Exec's run method * to execute the command line. * </p> * @throws BuildException on error */ @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); // build the command line from what we got the format // 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()); } }
/** * Check to see if the element is checked out in the current view. */ private boolean lsCheckout() { Commandline cmdl = new Commandline(); // build the command line from what we got the format is // cleartool lsco [options...] [viewpath ...] // as specified in the CLEARTOOL.EXE help cmdl.setExecutable(getClearToolCommand()); cmdl.createArgument().setValue(COMMAND_LSCO); cmdl.createArgument().setValue("-cview"); cmdl.createArgument().setValue("-short"); cmdl.createArgument().setValue("-d"); // viewpath cmdl.createArgument().setValue(getViewPath()); String result = runS(cmdl); return result != null && !result.isEmpty(); }
/** * Executes the task. * <p> * Builds a command line to execute cleartool and then calls Exec's run method * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { setViewPath(aProj.getBaseDir().getPath()); } // build the command line from what we got. the format is // cleartool checkin [options...] [viewpath ...] // as specified in the CLEARTOOL.EXE help commandLine.setExecutable(getClearToolCommand()); commandLine.createArgument().setValue(COMMAND_CHECKIN); checkOptions(commandLine); if (!getFailOnErr()) { getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation()); } }
/** * Builds a command line to execute ss. * @return The constructed commandline. */ protected Commandline buildCmdLine() { Commandline commandLine = new Commandline(); // first off, make sure that we've got a command and a vssdir ... if (getVsspath() == null) { String msg = "vsspath attribute must be set!"; throw new BuildException(msg, getLocation()); } // build the command line from what we got the format is // ss CP VSS items [-H] [-I-] [-Y] [-?] // as specified in the SS.EXE help commandLine.setExecutable(getSSCommand()); commandLine.createArgument().setValue(COMMAND_CP); // VSS items commandLine.createArgument().setValue(getVsspath()); // -I- or -I-Y or -I-N commandLine.createArgument().setValue(getAutoresponse()); // -Y commandLine.createArgument().setValue(getLogin()); return commandLine; }
/** * Builds a command line to execute ss. * @return The constructed commandline. */ Commandline buildCmdLine() { Commandline commandLine = new Commandline(); // first off, make sure that we've got a command and a vssdir... if (getVsspath() == null) { String msg = "vsspath attribute must be set!"; throw new BuildException(msg, getLocation()); } // build the command line from what we got // the format is: // ss Create VSS items [-C] [-H] [-I-] [-N] [-O] [-S] [-Y] [-?] // as specified in the SS.EXE help commandLine.setExecutable(getSSCommand()); commandLine.createArgument().setValue(COMMAND_CREATE); // VSS items commandLine.createArgument().setValue(getVsspath()); // -C commandLine.createArgument().setValue(getComment()); // -I- or -I-Y or -I-N commandLine.createArgument().setValue(getAutoresponse()); // -O- commandLine.createArgument().setValue(getQuiet()); // -Y commandLine.createArgument().setValue(getLogin()); return commandLine; }
/** * Performs a compile using the Javac externally. * @return true if the compilation succeeded * @throws BuildException on error */ @Override public boolean execute() throws BuildException { attributes.log("Using external javac compiler", Project.MSG_VERBOSE); Commandline cmd = new Commandline(); cmd.setExecutable(getJavac().getJavacExecutable()); if (!assumeJava11() && !assumeJava12()) { setupModernJavacCommandlineSwitches(cmd); } else { setupJavacCommandlineSwitches(cmd, true); } int firstFileName = assumeJava11() ? -1 : cmd.size(); logAndAddFilesToCompile(cmd); //On VMS platform, we need to create a special java options file //containing the arguments and classpath for the javac command. //The special file is supported by the "-V" switch on the VMS JVM. if (Os.isFamily("openvms")) { return execOnVMS(cmd, firstFileName); } return executeExternalCompile(cmd.getCommandline(), firstFileName, true) == 0; }
/** * Builds a command line to execute ss. * @return The constructed commandline. */ protected Commandline buildCmdLine() { Commandline commandLine = new Commandline(); // first off, make sure that we've got a command and a localPath ... if (getLocalpath() == null) { String msg = "localPath attribute must be set!"; throw new BuildException(msg, getLocation()); } // build the command line from what we got the format is // ss Add VSS items [-B] [-C] [-D-] [-H] [-I-] [-K] [-N] [-O] [-R] [-W] [-Y] [-?] // as specified in the SS.EXE help commandLine.setExecutable(getSSCommand()); commandLine.createArgument().setValue(COMMAND_ADD); // VSS items commandLine.createArgument().setValue(getLocalpath()); // -I- or -I-Y or -I-N commandLine.createArgument().setValue(getAutoresponse()); // -R commandLine.createArgument().setValue(getRecursive()); // -W commandLine.createArgument().setValue(getWritable()); // -Y commandLine.createArgument().setValue(getLogin()); // -C commandLine.createArgument().setValue(getComment()); return commandLine; }