import org.apache.tools.ant.types.Environment; //导入方法依赖的package包/类
/**
* Helper method invoked by execute() for each websphere jar to be built.
* Encapsulates the logic of constructing a java task for calling
* websphere.ejbdeploy and executing it.
*
* @param sourceJar java.io.File representing the source (EJB1.1) jarfile.
* @param destJar java.io.File representing the destination, websphere
* jarfile.
*/
private void buildWebsphereJar(File sourceJar, File destJar) {
try {
if (ejbdeploy) {
Java javaTask = new Java(getTask());
// Set the JvmArgs
javaTask.createJvmarg().setValue("-Xms64m");
javaTask.createJvmarg().setValue("-Xmx128m");
// Set the Environment variable
Environment.Variable var = new Environment.Variable();
var.setKey("websphere.lib.dir");
File libdir = new File(websphereHome, "lib");
var.setValue(libdir.getAbsolutePath());
javaTask.addSysproperty(var);
// Set the working directory
javaTask.setDir(websphereHome);
// Set the Java class name
javaTask.setTaskName("ejbdeploy");
javaTask.setClassname("com.ibm.etools.ejbdeploy.EJBDeploy");
javaTask.createArg().setValue(sourceJar.getPath());
javaTask.createArg().setValue(tempdir);
javaTask.createArg().setValue(destJar.getPath());
javaTask.createArg().setLine(getOptions());
if (getCombinedClasspath() != null
&& getCombinedClasspath().toString().length() > 0) {
javaTask.createArg().setValue("-cp");
javaTask.createArg().setValue(getCombinedClasspath().toString());
}
Path classpath = wasClasspath;
if (classpath == null) {
classpath = getCombinedClasspath();
}
javaTask.setFork(true);
if (classpath != null) {
javaTask.setClasspath(classpath);
}
log("Calling websphere.ejbdeploy for " + sourceJar.toString(),
Project.MSG_VERBOSE);
javaTask.execute();
}
} catch (Exception e) {
// Have to catch this because of the semantics of calling main()
throw new BuildException(
"Exception while calling ejbdeploy. Details: " + e.toString(),
e);
}
}