I have the following problem:

I want to run a Java class from within Ant, but I don't want to wait for
execution of the class to complete.

Example:

I have written a servlet-based application. After the compile portion of my
build completes, I want to start Tomcat and then execute my JUnit tasks.

Proposed Solution:

Add functionality to the Java task which allows the class to run in a
separate thread.

To access this functionality, an attribute (which I have been referring to
as "parallel") is set to true. The default value for this attribute is
false, so existing build xml will not need to be updated.


Here is a diff of my proposed changes. I wanted to get a feel for interest
in this change before completing the work. Please let me know what you think
(as if you wouldn't!).

Index: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java
,v
retrieving revision 1.24
diff -r1.24 Java.java
95a96,116
>     class ParallelThread extends Thread {
>         Java java;
>
>         ParallelThread(Java java) {
>             this.java = java;
>         }
>
>         public void run() {
>             java.run(java.cmdl.getCommandline());
>         }
>     }
>
>     boolean parallel = false;
>
>     /**
>      * Set the parallel flag.
>      */
>     public void setParallel(boolean s) {
>         this.parallel = s;
>     }
>
110,112c131,142
<             log("Forking " + cmdl.toString(), Project.MSG_VERBOSE);
<
<             return run(cmdl.getCommandline());
---
>             if (parallel) {
>                 log("Forking in parallel " + cmdl.toString(),
Project.MSG_VERBOSE);
>
>                 ParallelThread thread = new ParallelThread(this);
>                 thread.start();
>
>                 return 0;
>             } else {
>                 log("Forking " + cmdl.toString(), Project.MSG_VERBOSE);
>
>                 return run(cmdl.getCommandline());
>             }


Glenn.

Reply via email to