cvs commit: ant/src/main/org/apache/tools/ant Main.java

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

cvs commit: ant/src/main/org/apache/tools/ant Main.java

Steve Loughran
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: cvs commit: ant/src/main/org/apache/tools/ant Main.java

peterreilly

[hidden email] wrote:

>stevel      2005/05/13 14:57:23
>
>  
>  @@ -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;
>
>  
>
I do not think that this will happen. The problem was that there was a
mismatch
between the script (1.6.3) and the ant jars (1.6.2) which includes
compatible versions
of the Main(ant.jar) and Launcher(ant-launcher.jar) classes.

The problem was that some linux distributions are including ant via the
jpackage project.
This uses a file - /etc/ant.conf, which describes where ant is located.
To cooperate with the
jpackage project, ant's ant script reads this file. The ant.conf file
overwrites the environment variable
ANT_HOME.
----- snippet from the ant.conf file ----
if $no_config ; then
  # Disable RPM layout
  rpm_mode=false
else
  # Use RPM layout
  rpm_mode=true

  # ANT_HOME for rpm layout
  ANT_HOME=/usr/share/ant
fi
--------------------------------------------

This ANT_HOME is then used in the rest of the 1.6.3 script - causing it
to use the locator.jar from ant.1.6.2.


I think that the jpackage people have updated the script to check if
ANT_HOME is set already before setting it,
but this is not in the ant.1.6.2 package release.


The ant script could check if ANT_HOME has been modified by the call to
ant.conf and warn the user.

Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: cvs commit: ant/src/main/org/apache/tools/ant Main.java

Steve Loughran
Peter Reilly wrote:

>
> [hidden email] wrote:
>
>> stevel      2005/05/13 14:57:23
>>
>>    @@ -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;
>>
>>  
>>
> I do not think that this will happen. The problem was that there was a
> mismatch
> between the script (1.6.3) and the ant jars (1.6.2) which includes
> compatible versions
> of the Main(ant.jar) and Launcher(ant-launcher.jar) classes.
>
> The problem was that some linux distributions are including ant via the
> jpackage project.
> This uses a file - /etc/ant.conf, which describes where ant is located.
> To cooperate with the
> jpackage project, ant's ant script reads this file. The ant.conf file
> overwrites the environment variable
> ANT_HOME.
> ----- snippet from the ant.conf file ----
> if $no_config ; then
>  # Disable RPM layout
>  rpm_mode=false
> else
>  # Use RPM layout
>  rpm_mode=true
>
>  # ANT_HOME for rpm layout
>  ANT_HOME=/usr/share/ant
> fi
> --------------------------------------------
>
> This ANT_HOME is then used in the rest of the 1.6.3 script - causing it
> to use the locator.jar from ant.1.6.2.
>
>
> I think that the jpackage people have updated the script to check if
> ANT_HOME is set already before setting it,
> but this is not in the ant.1.6.2 package release.

I see. I think we ought to leave the logic in -it doesnt cost  much if
not used, but we may want to tune the text a bit. Like you say, it
should be a pretty rare occurence.

Maybe it should point to a Wiki URL or something that discusses this
problem in detail.

>
> The ant script could check if ANT_HOME has been modified by the call to
> ant.conf and warn the user.

ah, now that is paranoia. I like it.

-steve


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]