mbenson     2004/04/23 08:47:31

  Modified:    src/main/org/apache/tools/ant Tag: ANT_16_BRANCH Main.java
               .        Tag: ANT_16_BRANCH WHATSNEW
  Log:
  Merge -projecthelp bugfix and -nice option to 1.6 branch.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.95.2.7  +45 -6     ant/src/main/org/apache/tools/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Main.java,v
  retrieving revision 1.95.2.6
  retrieving revision 1.95.2.7
  diff -u -r1.95.2.6 -r1.95.2.7
  --- Main.java 9 Mar 2004 17:01:29 -0000       1.95.2.6
  +++ Main.java 23 Apr 2004 15:47:31 -0000      1.95.2.7
  @@ -115,6 +115,11 @@
       private static boolean isLogFileUsed = false;
   
       /**
  +     * optional thread priority
  +     */
  +    private Integer threadPriority=null;
  +
  +    /**
        * Prints the message of the Throwable if it (the message) is not
        * <code>null</code>.
        *
  @@ -396,6 +401,23 @@
                   }
               } else if (arg.equals("-k") || arg.equals("-keep-going")) {
                   keepGoingMode = true;
  +            } else if (arg.equals("-nice")) {
  +                try {
  +                    threadPriority=Integer.decode(args[i + 1]);
  +                } catch (ArrayIndexOutOfBoundsException aioobe) {
  +                    throw new BuildException(
  +                            "You must supply a niceness value (1-10)"+
  +                            " after the -nice option");
  +                } catch (NumberFormatException e) {
  +                    throw new BuildException("Unrecognized niceness value: " 
+
  +                            args[i + 1]);
  +                }
  +                i++;
  +                if(threadPriority.intValue()<Thread.MIN_PRIORITY ||
  +                        threadPriority.intValue()>Thread.MAX_PRIORITY) {
  +                    throw new BuildException(
  +                            "Niceness value is out of the range 1-10");
  +                }
               } else if (arg.startsWith("-")) {
                   // we don't have any more args to recognize!
                   String msg = "Unknown argument: " + arg;
  @@ -484,20 +506,19 @@
        * Helper to get the parent file for a given file.
        * <p>
        * Added to simulate File.getParentFile() from JDK 1.2.
  +     * @deprecated
        *
        * @param file   File to find parent of. Must not be <code>null</code>.
        * @return       Parent file or null if none
        */
       private File getParentFile(File file) {
  -        String filename = file.getAbsolutePath();
  -        file = new File(filename);
  -        filename = file.getParent();
  +        File parent = file.getParentFile();
   
  -        if (filename != null && msgOutputLevel >= Project.MSG_VERBOSE) {
  -            System.out.println("Searching in " + filename);
  +        if (parent != null && msgOutputLevel >= Project.MSG_VERBOSE) {
  +            System.out.println("Searching in " + parent.getAbsolutePath());
           }
   
  -        return (filename == null) ? null : new File(filename);
  +        return parent;
       }
   
       /**
  @@ -594,9 +615,23 @@
                   System.setOut(new PrintStream(new DemuxOutputStream(project, 
false)));
                   System.setErr(new PrintStream(new DemuxOutputStream(project, 
true)));
   
  +
                   if (!projectHelp) {
                       project.fireBuildStarted();
                   }
  +
  +                // set the thread priorities
  +                if (threadPriority != null) {
  +                    try {
  +                        project.log("Setting Ant's thread priority to "
  +                                + threadPriority,Project.MSG_VERBOSE);
  +                        
Thread.currentThread().setPriority(threadPriority.intValue());
  +                    } catch (SecurityException swallowed) {
  +                        //we cannot set the priority here.
  +                        project.log("A security manager refused to set the 
-nice value");
  +                    }
  +                }
  +
                   project.init();
                   project.setUserProperty("ant.version", getAntVersion());
   
  @@ -649,6 +684,8 @@
           } finally {
               if (!projectHelp) {
                   project.fireBuildFinished(error);
  +            } else if (error != null) {
  +                project.log(error.toString(), Project.MSG_ERR);
               }
           }
       }
  @@ -788,6 +825,8 @@
           msg.append("  -inputhandler <class>  the class which will handle 
input requests" + lSep);
           msg.append("  -find <file>           (s)earch for buildfile towards 
the root of" + lSep);
           msg.append("    -s  <file>           the filesystem and use it" + 
lSep);
  +        msg.append("  -nice  number          A niceness value for the main 
thread:" + lSep +
  +                   "                         1 (lowest) to 10 (highest); 5 
is the default" + lSep);
           System.out.println(msg.toString());
       }
   
  
  
  
  No                   revision
  No                   revision
  1.503.2.85 +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.84
  retrieving revision 1.503.2.85
  diff -u -r1.503.2.84 -r1.503.2.85
  --- WHATSNEW  23 Apr 2004 15:41:38 -0000      1.503.2.84
  +++ WHATSNEW  23 Apr 2004 15:47:31 -0000      1.503.2.85
  @@ -73,6 +73,9 @@
   * I/O-intensive processes hung when executed via <exec spawn="true">.
     Bugzilla reports 23893/26852.
   
  +* -projecthelp swallowed (configuration) errors silently.
  +  Bugzilla report 27732.
  +
   Other changes:
   --------------
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to