use of org.apache.tools.ant.taskdefs.ExecTask in project ant by apache.
the class BorlandGenerateClient method executeForkV5.
/**
* launch the generate client using system api.
* @throws BuildException if there is an error.
*/
protected void executeForkV5() throws BuildException {
try {
log("mode : fork " + BorlandDeploymentTool.BES, Project.MSG_DEBUG);
ExecTask execTask = new ExecTask(this);
execTask.setDir(new File("."));
execTask.setExecutable("iastool");
if (debug) {
execTask.createArg().setValue("-debug");
}
execTask.createArg().setValue("-genclient");
execTask.createArg().setValue("-jars");
// ejb jar file
execTask.createArg().setValue(ejbjarfile.getAbsolutePath());
// client jar file
execTask.createArg().setValue("-target");
execTask.createArg().setValue(clientjarfile.getAbsolutePath());
// classpath
execTask.createArg().setValue("-cp");
execTask.createArg().setValue(classpath.toString());
log("Calling iastool", Project.MSG_VERBOSE);
execTask.execute();
} catch (Exception e) {
// Have to catch this because of the semantics of calling main()
throw new BuildException("Exception while calling generateclient", e);
}
}
use of org.apache.tools.ant.taskdefs.ExecTask in project ant by apache.
the class BorlandGenerateClient method executeForkV4.
/**
* launch the generate client using system api.
* @throws BuildException if there is an error.
*/
protected void executeForkV4() throws BuildException {
try {
log("mode : fork " + BorlandDeploymentTool.BAS, Project.MSG_DEBUG);
ExecTask execTask = new ExecTask(this);
execTask.setDir(new File("."));
execTask.setExecutable("iastool");
execTask.createArg().setValue("generateclient");
if (debug) {
execTask.createArg().setValue("-trace");
}
execTask.createArg().setValue("-short");
execTask.createArg().setValue("-jarfile");
// ejb jar file
execTask.createArg().setValue(ejbjarfile.getAbsolutePath());
// client jar file
execTask.createArg().setValue("-single");
execTask.createArg().setValue("-clientjarfile");
execTask.createArg().setValue(clientjarfile.getAbsolutePath());
log("Calling iastool", Project.MSG_VERBOSE);
execTask.execute();
} catch (Exception e) {
// Have to catch this because of the semantics of calling main()
throw new BuildException("Exception while calling generateclient", e);
}
}
use of org.apache.tools.ant.taskdefs.ExecTask in project ant by apache.
the class BorlandDeploymentTool method verifyBorlandJarV5.
/**
* Verify the produced jar file by invoking the Borland iastool tool
* @param sourceJar java.io.File representing the produced jar file
*/
private void verifyBorlandJarV5(File sourceJar) {
log("verify BES " + sourceJar, Project.MSG_INFO);
try {
ExecTask execTask = new ExecTask(getTask());
execTask.setDir(new File("."));
execTask.setExecutable("iastool");
// classpath
if (getCombinedClasspath() != null) {
execTask.createArg().setValue("-VBJclasspath");
execTask.createArg().setValue(getCombinedClasspath().toString());
}
if (java2iiopdebug) {
execTask.createArg().setValue("-debug");
}
execTask.createArg().setValue("-verify");
execTask.createArg().setValue("-src");
// ejb jar file to verify
execTask.createArg().setValue(sourceJar.getPath());
log("Calling iastool", Project.MSG_VERBOSE);
execTask.execute();
} catch (Exception e) {
// Have to catch this because of the semantics of calling main()
throw new BuildException("Exception while calling generateclient Details: ", e);
}
}
use of org.apache.tools.ant.taskdefs.ExecTask in project ant by apache.
the class Cab method execute.
/**
* execute this task.
* @throws BuildException on error.
*/
@Override
public void execute() throws BuildException {
checkConfiguration();
Vector<String> files = getFileList();
// quick exit if the target is up to date
if (isUpToDate(files)) {
return;
}
log("Building " + archiveType + ": " + cabFile.getAbsolutePath());
if (!Os.isFamily("windows")) {
log("Using listcab/libcabinet", Project.MSG_VERBOSE);
StringBuilder sb = new StringBuilder();
files.forEach(f -> sb.append(f).append("\n"));
sb.append("\n").append(cabFile.getAbsolutePath()).append("\n");
try {
Process p = Execute.launch(getProject(), new String[] { "listcab" }, null, baseDir != null ? baseDir : getProject().getBaseDir(), true);
OutputStream out = p.getOutputStream();
// Create the stream pumpers to forward listcab's stdout and stderr to the log
// note: listcab is an interactive program, and issues prompts for every new line.
// Therefore, make it show only with verbose logging turned on.
LogOutputStream outLog = new LogOutputStream(this, Project.MSG_VERBOSE);
LogOutputStream errLog = new LogOutputStream(this, Project.MSG_ERR);
StreamPumper outPump = new StreamPumper(p.getInputStream(), outLog);
StreamPumper errPump = new StreamPumper(p.getErrorStream(), errLog);
// Pump streams asynchronously
new Thread(outPump).start();
new Thread(errPump).start();
out.write(sb.toString().getBytes());
out.flush();
out.close();
// A wild default for when the thread is interrupted
int result = DEFAULT_RESULT;
try {
// Wait for the process to finish
result = p.waitFor();
// Wait for the end of output and error streams
outPump.waitFor();
outLog.close();
errPump.waitFor();
errLog.close();
} catch (InterruptedException ie) {
log("Thread interrupted: " + ie);
}
// Informative summary message in case of errors
if (Execute.isFailure(result)) {
log("Error executing listcab; error code: " + result);
}
} catch (IOException ex) {
throw new BuildException("Problem creating " + cabFile + " " + ex.getMessage(), getLocation());
}
} else {
try {
File listFile = createListFile(files);
ExecTask exec = createExec();
File outFile = null;
// die if cabarc fails
exec.setFailonerror(true);
exec.setDir(baseDir);
if (!doVerbose) {
outFile = FILE_UTILS.createTempFile("ant", "", null, true, true);
exec.setOutput(outFile);
}
exec.setExecutable("cabarc");
exec.createArg().setValue("-r");
exec.createArg().setValue("-p");
if (!doCompress) {
exec.createArg().setValue("-m");
exec.createArg().setValue("none");
}
if (cmdOptions != null) {
exec.createArg().setLine(cmdOptions);
}
exec.createArg().setValue("n");
exec.createArg().setFile(cabFile);
exec.createArg().setValue("@" + listFile.getAbsolutePath());
exec.execute();
if (outFile != null) {
outFile.delete();
}
listFile.delete();
} catch (IOException ioe) {
throw new BuildException("Problem creating " + cabFile + " " + ioe.getMessage(), getLocation());
}
}
}
use of org.apache.tools.ant.taskdefs.ExecTask in project ant by apache.
the class ClearCase method runS.
/**
* 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);
}
Aggregations