stevel      2005/05/13 14:57:23

  Modified:    src/main/org/apache/tools/ant Main.java
  Log:
  added a special case that detects -cp and -lib calls in Main, and tells the 
caller that they have a probable version mismatch.
  
  Revision  Changes    Path
  1.118     +13 -21    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.117
  retrieving revision 1.118
  diff -u -r1.117 -r1.118
  --- Main.java 26 Feb 2005 21:16:58 -0000      1.117
  +++ Main.java 13 May 2005 21:57:23 -0000      1.118
  @@ -29,6 +29,7 @@
   import org.apache.tools.ant.input.DefaultInputHandler;
   import org.apache.tools.ant.input.InputHandler;
   import org.apache.tools.ant.launch.AntMain;
  +import org.apache.tools.ant.util.FileUtils;
   
   
   /**
  @@ -212,20 +213,8 @@
        */
       private static void handleLogfile() {
           if (isLogFileUsed) {
  -            if (out != null) {
  -                try {
  -                    out.close();
  -                } catch (final Exception e) {
  -                    //ignore
  -                }
  -            }
  -            if (err != null) {
  -                try {
  -                    err.close();
  -                } catch (final Exception e) {
  -                    //ignore
  -                }
  -            }
  +            FileUtils.close(out);
  +            FileUtils.close(err);
           }
       }
   
  @@ -424,6 +413,15 @@
                       throw new BuildException(
                               "Niceness value is out of the range 1-10");
                   }
  +            } else if (arg.equals("-cp") || arg.equals("-lib")) {
  +                //catch script/ant mismatch with a meaningful message
  +                //we could ignore it, but there are likely to be other
  +                //version problems, so we stamp down on the configuration now
  +                String msg = "Ant's Main method is being handed "
  +                        + "an option "+arg+" that is only for the launcher 
class."
  +                        + "\nThis can be caused by a version mismatch 
between "
  +                        + "the ant script/.bat file and Ant itself.";
  +                throw new BuildException(msg);
               } else if (arg.startsWith("-")) {
                   // we don't have any more args to recognize!
                   String msg = "Unknown argument: " + arg;
  @@ -476,13 +474,7 @@
                   System.out.println("Could not load property file "
                      + filename + ": " + e.getMessage());
               } finally {
  -                if (fis != null) {
  -                    try {
  -                        fis.close();
  -                    } catch (IOException e) {
  -                        // ignore
  -                    }
  -                }
  +                FileUtils.close(fis);
               }
   
               // ensure that -D properties take precedence
  
  
  

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

Reply via email to