执行以下的ant target,你只能得到以下的结果,永远得不到"END STARTUP TOMCAT 4.1",除非tomcat结束了
[echo] STARTUP TOMCAT 4.1
[exec] Using CATALINA_BASE: C:/Tomcat4.1
[exec] Using CATALINA_HOME: C:/Tomcat4.1
[exec] Using CATALINA_TMPDIR: C:/Tomcat4.1\temp
[exec] Using JAVA_HOME: C:/j2sdk1.4.2_02
二、有个强人给了一个解决办法,自写tomcat的任务
-----[build.xml]----------------
-----[StartServerTask.java]----------------
package org.rogerCompany;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
* An Ant Task that does the following :
*
* create a java thread,
*
* start another Ant target in that thread. This target must be a
* blocking target.
*
*
*/
public class StartServerTask extends Task {
/**
* Helper class
*/
private StartServerHelper helper;
/**
* Initialization
*/
public void init() {
this.helper = new StartServerHelper(this);
}
/**
* @see Task#execute()
*/
public void execute() throws BuildException {
this.helper.execute();
}
/**
* Ant will automatically call this method when the "startTarget" attribute
* of our task is used.
*
* @param theStartTarget the Ant target to call
*/
public void setStartTarget(String theStartTarget) {
this.helper.setStartTarget(theStartTarget);
}
}
-----[StartServerHelper.java]----------------
package org.rogerCompany;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.CallTarget;
/**
* A helper class for an Ant Task that does the following :
* create a java thread,
*
* start another Ant target in that thread. This target must be a
* blocking target.
*
*/
public class StartServerHelper implements Runnable {
/**
* The Ant target name that will start the blocking target.
*/
private String startTarget;
/**
* The tasks that wraps around this helper class
*/
private Task task;
/**
* @param theTask the Ant task that is calling this helper
*/
public StartServerHelper(Task theTask) {
this.task = theTask;
}
/**
* @see Task#execute()
*/
public void execute() throws BuildException {
// Verify that a start target has been specified
if (this.startTarget == null) {
throw new BuildException("A startTarget Ant target name must " +
"be specified");
}
// Call the target in another thread. The called
// target must be blocking.
Thread thread = new Thread(this);
thread.start();
// We're done ... Ant will continue processing other tasks
}
/**
* The thread that calls the Ant target that starts, for example, a server.
* Must be a blocking target.
*/
public void run() {
// Call the Ant target using the "antcall" task.
CallTarget callee;
callee = (CallTarget) (this.task.getProject().createTask("antcall"));
callee.setOwningTarget(this.task.getOwningTarget());
callee.setTaskName(this.task.getTaskName());
callee.setLocation(this.task.getLocation());
callee.init();
callee.setTarget(this.startTarget);
callee.execute();
// Should never reach this point as the target is blocking, unless the
// server is stopped.
}
/**
* @param theStartTarget the Ant target to call
*/
public void setStartTarget(String theStartTarget) {
this.startTarget = theStartTarget;
}
}