ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional ANTLR.java
Date Wed, 21 May 2003 13:29:55 GMT
bodewig     2003/05/21 06:29:55

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional ANTLR.java
  Log:
  What has been -traceTreeWalker in ANTLR 2.7.0 has become
  -traceTreeParser in 2.7.2
  
  PR: 20020
  
  Revision  Changes    Path
  1.27      +25 -4     ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  
  Index: ANTLR.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ANTLR.java	18 Apr 2003 23:40:24 -0000	1.26
  +++ ANTLR.java	21 May 2003 13:29:55 -0000	1.27
  @@ -59,6 +59,7 @@
   import java.io.File;
   import java.io.FileReader;
   import java.io.IOException;
  +import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  @@ -337,7 +338,11 @@
               commandline.createArgument().setValue("-traceLexer");
           }
           if (traceTreeWalker) {
  -            commandline.createArgument().setValue("-traceTreeWalker");
  +            if (is272()) {
  +                commandline.createArgument().setValue("-traceTreeParser");
  +            } else {
  +                commandline.createArgument().setValue("-traceTreeWalker");
  +            }
           }
           if (debug) {
               commandline.createArgument().setValue("-debug");
  @@ -385,9 +390,9 @@
           PumpStreamHandler psh = 
               new PumpStreamHandler(new LogOutputStream(this, Project.MSG_INFO),
                                     new TeeOutputStream(
  -                                      new LogOutputStream(this, 
  -                                                          Project.MSG_WARN),
  -                                      bos)
  +                                                      new LogOutputStream(this, 
  +                                                                          Project.MSG_WARN),
  +                                                      bos)
                                     );
           Execute exe = new Execute(psh, null);
           exe.setAntRun(getProject());
  @@ -405,5 +410,21 @@
               } catch (IOException e) {
               }
           }
  +    }
  +
  +    /**
  +     * Whether the antlr version is 2.7.2 (or higher).
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected boolean is272() {
  +        try {
  +            AntClassLoader l = new AntClassLoader(getProject(),
  +                                                  commandline.getClasspath());
  +            l.loadClass("antlr.Version");
  +            return true;
  +        } catch (ClassNotFoundException e) {
  +            return false;
  +        } // end of try-catch
       }
   }
  
  
  

Mime
View raw message