Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 22749 invoked from network); 13 May 2005 21:57:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 May 2005 21:57:27 -0000 Received: (qmail 80412 invoked by uid 500); 13 May 2005 22:01:51 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 80156 invoked by uid 500); 13 May 2005 22:01:49 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 80143 invoked by uid 500); 13 May 2005 22:01:49 -0000 Received: (qmail 80140 invoked by uid 99); 13 May 2005 22:01:49 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 13 May 2005 15:01:49 -0700 Received: (qmail 22711 invoked by uid 1365); 13 May 2005 21:57:23 -0000 Date: 13 May 2005 21:57:23 -0000 Message-ID: <20050513215723.22710.qmail@minotaur.apache.org> From: stevel@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/main/org/apache/tools/ant Main.java X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org