Sorry for the subject pun. Here's what's going on ... I'm trying to run a java task inside one of my targets, and I have the fork set to true (it's a jar), but the stupid thing won't fork. Is there some issue regarding this?
Please be more specific. What do you mean by not forking?
Tony Yan<br /> <br />IBM Certified Developer XML and Related Technology<br />Sun Certified Web Component Developer For J2EE Platform<br />Sun Certified Programmer For Java 2 Platform
Joined: May 29, 2003
Well, basically, it's not forking! My build script blocks until my java task finishes (program is exited) even though I have forking enabled.
Joined: Apr 10, 2002
I tried some bogus ant script with forking enabled. Yes, i got what you got too. It is still a single threaded behavior. I wonder if this is normal or a bug. It is said that forking starts a new java vm to run javac. Does that mean it will be on its own Thread? Any one got ideas?
Joined: Jan 07, 1999
As far as I understand, "fork" is intended to run a task in its own VM mainly so that if the task crashes or exits the VM, it won't crash the whole build. With this in mind, the sequencing of the build process still requires that prerequisite tasks are preformed before dependent ones, so the build has to wait for the "forked" tasks to complete. I'm not sure the Ant build specification would even make sense if some tasks could run asynchronously. When would it make sense to run a dependent task - as soon as the asynchronous task has started? Wait for five seconds and hope it has finished? Spin checking modification times until some external resource has been updated? Something else? On the other hand, if you really need something like this, there are plenty of examples of custom tasks which do start asynchronous processing - all the ones which start a server, for example. They don't usually use "fork", though, just run a small in-VM task which executes an external OS-level program as a background process, then immediately returns to the calling build script.
This is a sample of how I try to javac in 1.1.8 with 1.4 as my standard VM for ANT (through IDEA). If anyone knows how to ensure that the VM for the java task is 1.1.8 please share, I am having trouble getting the java command to run in 1.1.8. The help pages on ANT's java task say to set fork="true" to run in a different VM than the main ANT VM. But can't figure out to saw what VM that is.