ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant Main.java
Date Fri, 08 Jun 2001 10:31:11 GMT
bodewig     01/06/08 03:31:10

  Modified:    docs/manual using.html
               src/main/org/apache/tools/ant Main.java
  Log:
  Add a property that contains the version of Ant.
  
  Revision  Changes    Path
  1.6       +1 -0      jakarta-ant/docs/manual/using.html
  
  Index: using.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/using.html,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- using.html	2001/05/22 14:40:02	1.5
  +++ using.html	2001/06/08 10:31:02	1.6
  @@ -208,6 +208,7 @@
   basedir             the absolute path of the project's basedir (as set
                       with the basedir attribute of <project>).
   ant.file            the absolute path of the buildfile.
  +ant.version         the version of Ant
   ant.project.name    the name of the project that is currently executing;
                       it is set in the name attribute of <project>.
   ant.java.version    the JVM version Ant detected; currently it can hold
  
  
  
  1.36      +27 -21    jakarta-ant/src/main/org/apache/tools/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Main.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- Main.java	2001/05/23 16:44:04	1.35
  +++ Main.java	2001/06/08 10:31:08	1.36
  @@ -385,6 +385,7 @@
   
               project.fireBuildStarted();
               project.init();
  +            project.setUserProperty("ant.version", getAntVersion());
   
               // set user-define properties
               Enumeration e = definedProps.keys();
  @@ -394,7 +395,7 @@
                   project.setUserProperty(arg, value);
               }
   
  -            project.setUserProperty( "ant.file" , buildFile.getAbsolutePath() );
  +            project.setUserProperty("ant.file" , buildFile.getAbsolutePath() );
   
               // first use the ProjectHelper to create the project object
               // from the given build file.
  @@ -513,27 +514,32 @@
           System.out.println(getAntVersion());
       }
   
  -    public static String getAntVersion() throws BuildException {
  -        try {
  -            Properties props = new Properties();
  -            InputStream in =
  -                Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt");
  -            props.load(in);
  -            in.close();
  -
  -            String lSep = System.getProperty("line.separator");
  -            StringBuffer msg = new StringBuffer();
  -            msg.append("Ant version ");
  -            msg.append(props.getProperty("VERSION"));
  -            msg.append(" compiled on ");
  -            msg.append(props.getProperty("DATE"));
  -            return msg.toString();
  -        } catch (IOException ioe) {
  -            throw new BuildException("Could not load the version information:"
  -                                     + ioe.getMessage());
  -        } catch (NullPointerException npe) {
  -            throw new BuildException("Could not load the version information.");
  +    private static String antVersion = null;
  +
  +    public synchronized static String getAntVersion() throws BuildException {
  +        if (antVersion == null) {
  +            try {
  +                Properties props = new Properties();
  +                InputStream in =
  +                    Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt");
  +                props.load(in);
  +                in.close();
  +                
  +                String lSep = System.getProperty("line.separator");
  +                StringBuffer msg = new StringBuffer();
  +                msg.append("Ant version ");
  +                msg.append(props.getProperty("VERSION"));
  +                msg.append(" compiled on ");
  +                msg.append(props.getProperty("DATE"));
  +                antVersion = msg.toString();
  +            } catch (IOException ioe) {
  +                throw new BuildException("Could not load the version information:"
  +                                         + ioe.getMessage());
  +            } catch (NullPointerException npe) {
  +                throw new BuildException("Could not load the version information.");
  +            }
           }
  +        return antVersion;
       }
   
       /**
  
  
  

Mime
View raw message