You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Tom Rodriguez <tr...@parc.xerox.com> on 1999/11/15 23:10:56 UTC

PATCH: jakarta-tools/ant/src/main/org/apache/tools/ant/Main.java

This is a little patch to ant to make it hang around in loop waiting for
you to type a target name instead of just executing once and then
exiting.  This way you don't pay java startup costs each compile and
with hotspot your compiles get faster over time.  If you just hit return
it'll do the last target you selected or the default target.  I use it
all the time for development and thought I'd share it.  ant is a very
cool tool.  I'd like to see it get more functionality but even the
simple version is great.

tom

Index: Main.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tools/ant/src/main/org/apache/tools/ant/Main.java,v
retrieving revision 1.4
diff -c -r1.4 Main.java
*** Main.java	1999/11/01 04:54:26	1.4
--- Main.java	1999/11/15 22:06:12
***************
*** 1,6 ****
--- 1,8 ----
  package org.apache.tools.ant;
  
  import java.io.File;
+ import java.io.BufferedReader;
+ import java.io.InputStreamReader;
  import java.util.Properties;
  import java.util.Enumeration;
  
***************
*** 24,29 ****
--- 26,35 ----
      private static String target = null;
      private static Properties definedProps = new Properties();
  
+     /** Are we running in daemon mode?
+      */
+     private static boolean daemon = false;
+ 
      /**
       * Command line entry point. This method kicks off the building
       * of a project object and executes a build using either a given
***************
*** 62,67 ****
--- 68,75 ----
                  arg = arg.substring(2, arg.length());
                  String value = args[++i];
                  definedProps.put(arg, value);
+ 	    } else if (arg.equals("-daemon")) {
+ 		daemon = true;
              } else if (arg.startsWith("-")) {
  		// we don't have any more args to recognize!
  		String msg = "Unknown arg: " + arg;
***************
*** 91,97 ****
  
  	// ok, so if we've made it here, let's run the damn build allready
          
! 	runBuild();
      }
  
      /**
--- 99,119 ----
  
  	// ok, so if we've made it here, let's run the damn build allready
          
! 	if (daemon == true) {
! 	    BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
! 	    while (true) {
! 		try {
! 		    String command = br.readLine();
! 		    if (!command.equals(""))
! 			target = command;
! 		} catch (java.io.IOException ioe) {
! 		    ioe.printStackTrace();
! 		}
! 		runBuild();
! 	    }
! 	} else {
! 	    runBuild();
! 	}
      }
  
      /**

Re: PATCH: jakarta-tools/ant/src/main/org/apache/tools/ant/Main.java

Posted by Tom Rodriguez <tr...@parc.xerox.com>.
> Thanks for the great comments! :) I like the patch that you submitted
> and will get it rolled in. I'm not quite sure about calling the flag
> "-daemon" -- maybe "-interactive / -i"?

I'm not wedded to the name.  I've probably just spent too much time
using unix.  -interactive sounds good.

tom

Re: PATCH: jakarta-tools/ant/src/main/org/apache/tools/ant/Main.java

Posted by James Duncan Davidson <ja...@eng.sun.com>.

> This is a little patch to ant to make it hang around in loop waiting for
> you to type a target name instead of just executing once and then
> exiting.  This way you don't pay java startup costs each compile and
> with hotspot your compiles get faster over time.  If you just hit return
> it'll do the last target you selected or the default target.  I use it
> all the time for development and thought I'd share it.  ant is a very
> cool tool.  I'd like to see it get more functionality but even the
> simple version is great.

Thanks for the great comments! :) I like the patch that you submitted
and will get it rolled in. I'm not quite sure about calling the flag
"-daemon" -- maybe "-interactive / -i"?

.duncan

-- 
James Davidson                                     duncan@eng.sun.com 
Java + XML / Portable Code + Portable Data                 !try; do()