/** * @return Returns the source-file to execute, if this command line has * been {@link #setSourceFile(String) configured for single file source program * execution}. Else returns null. * @since Ant 1.10.5 */ public String getSourceFile() { return this.executableType == ExecutableType.SOURCE_FILE ? this.javaCommand.getExecutable() : null; }
/** * Get the name of the jar to be run. * @return the pathname of the jar file to run via -jar option * or <tt>null</tt> if there is no jar to run. * @see #getClassname() */ public String getJar() { if (executableType == ExecutableType.JAR) { return javaCommand.getExecutable(); } return null; }
/** * Get the name of the class to be run. * @return the name of the class to run or <tt>null</tt> if there is no class. * @see #getJar() */ public String getClassname() { if (executableType != null) { switch (executableType) { case CLASS: return javaCommand.getExecutable(); case MODULE: return parseClassFromModuleClassPair(javaCommand.getExecutable()); default: } } return null; }
/** * Get the name of the module to be run. * @return the name of the module to run or <tt>null</tt> if there is no module. * @see #getJar() * @see #getClassname() * @since 1.9.7 */ public String getModule() { if (executableType == ExecutableType.MODULE) { return parseModuleFromModuleClassPair(javaCommand.getExecutable()); } return null; }
/** * 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); } }
/** * Has the user set all necessary attributes? * @throws BuildException if there are missing required parameters. */ protected void checkConfiguration() throws BuildException { if (cmdl.getExecutable() == null) { throw new BuildException("no executable specified", getLocation()); } if (dir != null && !dir.exists()) { throw new BuildException("The directory " + dir + " does not exist"); } if (dir != null && !dir.isDirectory()) { throw new BuildException(dir + " is not a directory"); } if (spawn && incompatibleWithSpawn) { getProject().log("spawn does not allow attributes related to input, " + "output, error, result", Project.MSG_ERR); getProject().log("spawn also does not allow timeout", Project.MSG_ERR); getProject().log("finally, spawn is not compatible " + "with a nested I/O <redirector>", Project.MSG_ERR); throw new BuildException("You have used an attribute " + "or nested element which is not compatible with spawn"); } setupRedirector(); }
/** * 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; }
final String classname = javaCommand.getExecutable();
log("Applied " + cmdl.getExecutable() + " to " + totalFiles + " file" + (totalFiles != 1 ? "s" : "") + " and " + totalDirs + " director" + (totalDirs != 1 ? "ies" : "y") + ".",
/** * Execute the given command, and return it's output * @param cmdline command line to execute * @return output of the command line */ protected String runS(Commandline cmdline) { String outV = "opts.cc.runS.output" + pcnt++; ExecTask exe = new ExecTask(this); Commandline.Argument arg = exe.createArg(); exe.setExecutable(cmdline.getExecutable()); arg.setLine(Commandline.toString(cmdline.getArguments())); exe.setOutputproperty(outV); exe.execute(); return getProject().getProperty(outV); }
int returncode = exe.execute(); if (Execute.isFailure(returncode)) { String msg = "'" + toExecute.getExecutable() + "' failed with exit code " + returncode; if (failOnError) {
cmdl.setClassname(javaCommand.getExecutable()); for (String arg : javaCommand.getArguments()) { cmdl.createArgument().setValue(arg);
StringBuilder commandBuilder = new StringBuilder(commandLine.getVmCommand().getExecutable()); if (commandLine.getBootclasspath() != null) { commandBuilder.append(" -Xbootclasspath:bootclasspath");
.getExecutable(), "read, execute"));