Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 58313 invoked from network); 22 Jul 2002 05:41:47 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 22 Jul 2002 05:41:47 -0000 Received: (qmail 2212 invoked by uid 97); 22 Jul 2002 05:42:10 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 2149 invoked by uid 97); 22 Jul 2002 05:42:09 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 2138 invoked by uid 97); 22 Jul 2002 05:42:09 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 22 Jul 2002 05:41:39 -0000 Message-ID: <20020722054139.70072.qmail@icarus.apache.org> From: patrickl@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher LaunchCommand.java LaunchTask.java Launcher.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N patrickl 2002/07/21 22:41:39 Modified: daemon/src/bin launcher.xml daemon/src/java/org/apache/commons/launcher LaunchCommand.java LaunchTask.java Launcher.java Log: Added the "debug" attribute to the task. This attribute, when set to true, will run the target application in the JDB debugger. Revision Changes Path 1.5 +30 -26 jakarta-commons-sandbox/daemon/src/bin/launcher.xml Index: launcher.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/bin/launcher.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- launcher.xml 20 Jul 2002 15:21:30 -0000 1.4 +++ launcher.xml 22 Jul 2002 05:41:38 -0000 1.5 @@ -4,12 +4,17 @@ By default, the sample application will be launched in the background. To run it in the foreground, execute the Launcher with a "-Dwait=true" - argument. Also, to run the sample application in JPDA mode, execute the - Launcher with a "-Ddebug=true" argument. + argument. + + To run the sample application in the JDB debugger, execute the Launcher with + a "-Ddebug=true" argument. + + To run the sample application in JPDA mode, execute the Launcher with a + "-Djpda=true" argument. --> - + @@ -24,14 +29,23 @@ - - + + + + - - + + + + + + + + + @@ -56,17 +70,7 @@ - - - - - - - - - - + depends="setjdb,setjpda"> - + debug="${jdb}" + requiretools="true" + redirectoutput="true" + output="${app.home}/logs/ant.log" + displayMinimizedWindow="true" + disposeMinimizedWindow="true" + minimizedWindowTitle="Ant"> + 1.4 +54 -0 jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchCommand.java Index: LaunchCommand.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchCommand.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- LaunchCommand.java 20 Jul 2002 15:21:30 -0000 1.3 +++ LaunchCommand.java 22 Jul 2002 05:41:39 -0000 1.4 @@ -83,6 +83,11 @@ private String classpath = null; /** + * Cached debug flag. + */ + private boolean debug = false; + + /** * Cached displayMinimizedWindow flag. */ private boolean displayMinimizedWindow = false; @@ -93,6 +98,11 @@ private boolean disposeMinimizedWindow = true; /** + * Cached failOnError flag. + */ + private boolean failOnError = true; + + /** * Cached main class name. */ private String mainClassName = null; @@ -167,6 +177,17 @@ } /** + * Get the debug flag. + * + * @return the debug flag + */ + public boolean getDebug() { + + return debug; + + } + + /** * Get the displayMinimizedWindow flag. * * @return the displayMinimizedWindow flag @@ -189,6 +210,17 @@ } /** + * Get the failOnError flag. + * + * @return the failOnError flag + */ + public boolean getFailonerror() { + + return failOnError; + + } + + /** * Get the title for the minimized window that will be displayed in the * Windows taskbar. * @@ -357,6 +389,17 @@ } /** + * Set the debug flag. + * + * @param debug the debug flag + */ + public void setDebug(boolean debug) { + + this.debug = debug; + + } + + /** * Set the displayMinimizedWindow flag. Note that this flag has no effect * on non-Windows platforms. On Windows platform, setting this flag to true * will cause a minimized window to be displayed in the Windows task bar @@ -392,6 +435,17 @@ public void setDisposeminimizedwindow(boolean disposeMinimizedWindow) { this.disposeMinimizedWindow = displayMinimizedWindow; + + } + + /** + * Set the failOnError flag. + * + * @param failOnError the failOnError flag + */ + public void setFailonerror(boolean failOnError) { + + this.failOnError = failOnError; } 1.18 +33 -2 jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchTask.java Index: LaunchTask.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchTask.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- LaunchTask.java 22 Jul 2002 04:59:06 -0000 1.17 +++ LaunchTask.java 22 Jul 2002 05:41:39 -0000 1.18 @@ -136,6 +136,11 @@ private Path classpath = null; /** + * Cached debug flag. + */ + private boolean debug = false; + + /** * Cached displayMinimizedWindow flag. */ private boolean displayMinimizedWindow = false; @@ -426,8 +431,10 @@ boolean filteredRedirect = redirect; File filteredOutputFile = outputFile; boolean filteredAppendOutput = appendOutput; + boolean filteredDebug = debug; boolean filteredDisplayMinimizedWindow = displayMinimizedWindow; boolean filteredDisposeMinimizedWindow = disposeMinimizedWindow; + boolean filteredFailOnError = failOnError; String filteredMinimizedWindowTitle = minimizedWindowTitle; File filteredMinimizedWindowIcon = minimizedWindowIcon; boolean filteredUseSystemIn = useSystemIn; @@ -460,8 +467,10 @@ command.setRedirectoutput(filteredRedirect); command.setOutput(filteredOutputFile); command.setAppendoutput(filteredAppendOutput); + command.setDebug(filteredDebug); command.setDisplayminimizedwindow(filteredDisplayMinimizedWindow); command.setDisposeminimizedwindow(filteredDisposeMinimizedWindow); + command.setFailonerror(filteredFailOnError); command.setMinimizedwindowtitle(filteredMinimizedWindowTitle); command.setMinimizedwindowicon(filteredMinimizedWindowIcon); command.setUsesystemin(filteredUseSystemIn); @@ -475,8 +484,10 @@ filteredRedirect = command.getRedirectoutput(); filteredOutputFile = command.getOutput(); filteredAppendOutput = command.getAppendoutput(); + filteredDebug = command.getDebug(); filteredDisplayMinimizedWindow = command.getDisplayminimizedwindow(); filteredDisposeMinimizedWindow = command.getDisposeminimizedwindow(); + filteredFailOnError = command.getFailonerror(); filteredMinimizedWindowTitle = command.getMinimizedwindowtitle(); filteredMinimizedWindowIcon = command.getMinimizedwindowicon(); filteredUseSystemIn = command.getUsesystemin(); @@ -500,6 +511,11 @@ } } + // Force child JVM into foreground if running using JDB + if (filteredDebug) { + filteredWaitForChild = true; + filteredUseSystemIn = true; + } // Prepend this package's classpath if (filteredClasspath != null) { @@ -572,7 +588,10 @@ // Assemble child command String[] cmd = new String[5 + jvmArgs.size() + sysProps.size() + appArgs.size()]; int nextCmdArg = 0; - cmd[nextCmdArg++] = Launcher.getJavaCommand(); + if (filteredDebug) + cmd[nextCmdArg++] = Launcher.getJDBCommand(); + else + cmd[nextCmdArg++] = Launcher.getJavaCommand(); // Add jvmArgs to command for (int i = 0; i < jvmArgs.size(); i++) cmd[nextCmdArg++] = (String)jvmArgs.get(i); @@ -628,7 +647,7 @@ stdout.join(); stderr.join(); int exitValue = proc.exitValue(); - if (failOnError && exitValue != 0) + if (filteredFailOnError && exitValue != 0) throw new BuildException(Launcher.getLocalizedString("child.failed", this.getClass().getName()) + " " + exitValue); } // Need to check if the launching process has stopped because @@ -730,6 +749,18 @@ public void setClasspathref(Reference ref) { createClasspath().setRefid(ref); + + } + + /** + * Set the debug flag. Setting this flag to true will cause this + * task to run the child JVM using the JDB debugger. + * + * @param debug the debug flag + */ + public void setDebug(boolean debug) { + + this.debug = debug; } 1.13 +28 -0 jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/Launcher.java Index: Launcher.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/Launcher.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Launcher.java 22 Jul 2002 04:59:06 -0000 1.12 +++ Launcher.java 22 Jul 2002 05:41:39 -0000 1.13 @@ -123,6 +123,11 @@ private static String javaCmd = null; /** + * Cached JDB command + */ + private static String jdbCmd = null; + + /** * Shared lock. */ private static Object lock = new Object(); @@ -606,6 +611,29 @@ } return javaCmd; + + } + + /** + * Get the full path of the JDB command to execute. + * + * @return a string suitable for executing a child JDB debugger + */ + public static synchronized String getJDBCommand() { + + if (jdbCmd == null) { + + String osname = System.getProperty("os.name").toLowerCase(); + String commandName = null; + if (osname.indexOf("windows") >= 0) + commandName = "jdb.exe"; + else + commandName = "jdb"; + jdbCmd = new File(System.getProperty("java.home")).getParent() + File.separator + "bin" + File.separator + commandName; + + } + + return jdbCmd; } -- To unsubscribe, e-mail: For additional commands, e-mail: