use of org.apache.tools.ant.taskdefs.Java in project ant by apache.
the class BorlandDeploymentTool method verifyBorlandJarV4.
/**
* Verify the produced jar file by invoking the Borland verify tool
* @param sourceJar java.io.File representing the produced jar file
*/
private void verifyBorlandJarV4(File sourceJar) {
Java javaTask = null;
log("verify BAS " + sourceJar, Project.MSG_INFO);
try {
String args = verifyArgs;
args += " " + sourceJar.getPath();
javaTask = new Java(getTask());
javaTask.setTaskName("verify");
javaTask.setClassname(VERIFY);
Commandline.Argument arguments = javaTask.createArg();
arguments.setLine(args);
Path classpath = getCombinedClasspath();
if (classpath != null) {
javaTask.setClasspath(classpath);
javaTask.setFork(true);
}
log("Calling " + VERIFY + " for " + sourceJar.toString(), Project.MSG_VERBOSE);
javaTask.execute();
} catch (Exception e) {
// TO DO : delete the file if it is not a valid file.
String msg = "Exception while calling " + VERIFY + " Details: " + e.toString();
throw new BuildException(msg, e);
}
}
use of org.apache.tools.ant.taskdefs.Java in project ci.ant by WASdev.
the class InstallLibertyTask method installLiberty.
protected void installLiberty(File jarFile) throws Exception {
Java java = (Java) getProject().createTask("java");
java.setJar(jarFile);
java.setFork(true);
java.createArg().setValue("-acceptLicense");
java.createArg().setValue(baseDir);
int exitCode = java.executeJava();
if (exitCode != 0) {
throw new BuildException("Error installing Liberty.");
}
}
use of org.apache.tools.ant.taskdefs.Java in project ant by apache.
the class WLJspc method execute.
/**
* Run the task.
* @throws BuildException if there is an error.
*/
@Override
public void execute() throws BuildException {
if (!destinationDirectory.isDirectory()) {
throw new BuildException("destination directory %s is not valid", destinationDirectory.getPath());
}
if (!sourceDirectory.isDirectory()) {
throw new BuildException("src directory %s is not valid", sourceDirectory.getPath());
}
if (destinationPackage == null) {
throw new BuildException("package attribute must be present.", getLocation());
}
pathToPackage = this.destinationPackage.replace('.', File.separatorChar);
// get all the files in the sourceDirectory
DirectoryScanner ds = super.getDirectoryScanner(sourceDirectory);
// use the systemclasspath as well, to include the ant jar
if (compileClasspath == null) {
compileClasspath = new Path(getProject());
}
compileClasspath = compileClasspath.concatSystemClasspath();
String[] files = ds.getIncludedFiles();
// Weblogic.jspc calls System.exit() ... have to fork
// Therefore, takes loads of time
// Can pass directories at a time (*.jsp) but easily runs out of
// memory on hefty dirs (even on a Sun)
Java helperTask = new Java(this);
helperTask.setFork(true);
helperTask.setClassname("weblogic.jspc");
helperTask.setTaskName(getTaskName());
// CheckStyle:MagicNumber OFF
String[] args = new String[12];
// CheckStyle:MagicNumber ON
int j = 0;
// TODO this array stuff is a remnant of prev trials.. gotta remove.
args[j++] = "-d";
args[j++] = destinationDirectory.getAbsolutePath().trim();
args[j++] = "-docroot";
args[j++] = sourceDirectory.getAbsolutePath().trim();
args[j++] = "-keepgenerated";
// Call compiler as class... dont want to fork again
// Use classic compiler -- can be parameterised?
args[j++] = "-compilerclass";
args[j++] = "sun.tools.javac.Main";
// Weblogic jspc does not seem to work unless u explicitly set this...
// Does not take the classpath from the env....
// Am i missing something about the Java task??
args[j++] = "-classpath";
args[j++] = compileClasspath.toString();
this.scanDir(files);
log("Compiling " + filesToDo.size() + " JSP files");
for (String filename : filesToDo) {
// TODO
// All this to get package according to weblogic standards
// Can be written better... this is too hacky!
// Careful.. similar code in scanDir, but slightly different!!
File jspFile = new File(filename);
args[j] = "-package";
String parents = jspFile.getParent();
if (parents == null || "".equals(parents)) {
args[j + 1] = destinationPackage;
} else {
parents = this.replaceString(parents, File.separator, "_.");
args[j + 1] = destinationPackage + "." + "_" + parents;
}
args[j + 2] = sourceDirectory + File.separator + filename;
helperTask.clearArgs();
// CheckStyle:MagicNumber OFF
for (int x = 0; x < j + 3; x++) {
helperTask.createArg().setValue(args[x]);
}
// CheckStyle:MagicNumber ON
helperTask.setClasspath(compileClasspath);
if (helperTask.executeJava() != 0) {
log(filename + " failed to compile", Project.MSG_WARN);
}
}
}
use of org.apache.tools.ant.taskdefs.Java in project ant by apache.
the class GenericHotDeploymentTool method setTask.
/**
* Sets the parent task.
* @param task An ServerDeploy object representing the parent task.
* @ant.attribute ignored="true"
*/
@Override
public void setTask(ServerDeploy task) {
super.setTask(task);
java = new Java(task);
}
use of org.apache.tools.ant.taskdefs.Java in project ant by apache.
the class WebLogicHotDeploymentTool method deploy.
/**
* Perform the actual deployment.
* For this implementation, a JVM is spawned and the weblogic.deploy
* tools is executed.
* @exception BuildException if the attributes are invalid or incomplete.
*/
@Override
public void deploy() {
Java java = new Java(getTask());
java.setFork(true);
java.setFailonerror(true);
java.setClasspath(getClasspath());
java.setClassname(WEBLOGIC_DEPLOY_CLASS_NAME);
java.createArg().setLine(getArguments());
java.execute();
}
Aggregations