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/javacc JJTree.java
Date Fri, 25 Jul 2003 09:44:52 GMT
bodewig     2003/07/25 02:44:52

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/javacc
                        JJTree.java
  Log:
  backwards compatibility fix submitted by Jene Jasper
  
  Revision  Changes    Path
  1.23      +19 -10    ant/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java
  
  Index: JJTree.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JJTree.java	23 Jul 2003 14:12:12 -0000	1.22
  +++ JJTree.java	25 Jul 2003 09:44:49 -0000	1.23
  @@ -72,7 +72,7 @@
    * Runs the JJTree compiler compiler.
    *
    * @author thomas.haas@softwired-inc.com
  - * @author Michael Saunders 
  + * @author Michael Saunders
    *         <a href="mailto:michael@amtec.com">michael@amtec.com</a>
    */
   public class JJTree extends Task {
  @@ -232,9 +232,9 @@
           if (target == null || !target.isFile()) {
               throw new BuildException("Invalid target: " + target);
           }
  -        
  +
           if (outputFile != null) {
  -            cmdl.createArgument().setValue("-" + OUTPUT_FILE + ":" 
  +            cmdl.createArgument().setValue("-" + OUTPUT_FILE + ":"
                                              + outputFile.replace('\\', '/'));
           }
   
  @@ -242,21 +242,21 @@
   
           // use the directory containing the target as the output directory
           if (outputDirectory == null) {
  -            javaFile = new File(createOutputFileName(target, outputFile, 
  +            javaFile = new File(createOutputFileName(target, outputFile,
                                                        null));
           } else {
               if (!outputDirectory.isDirectory()) {
                   throw new BuildException("'outputdirectory' " + outputDirectory
                                            + " is not a directory.");
               }
  - 
  +
               // convert backslashes to slashes, otherwise jjtree will
               // put this as comments and this seems to confuse javacc
               cmdl.createArgument().setValue("-OUTPUT_DIRECTORY:"
                                              + outputDirectory.getAbsolutePath()
                                                .replace('\\', '/'));
  - 
  -            javaFile = new File(createOutputFileName(target, outputFile, 
  +
  +            javaFile = new File(createOutputFileName(target, outputFile,
                                                        outputDirectory
                                                        .getPath()));
           }
  @@ -269,7 +269,7 @@
           }
           cmdl.createArgument().setValue(target.getAbsolutePath());
   
  -        cmdl.setClassname(JavaCC.getMainClass(javaccHome, 
  +        cmdl.setClassname(JavaCC.getMainClass(javaccHome,
                                                 JavaCC.TASKDEF_TYPE_JJTREE));
   
           final Path classpath = cmdl.createClasspath(getProject());
  @@ -319,15 +319,24 @@
                   if (currentSuffix.equals(DEFAULT_SUFFIX)) {
                       optionalOutputFile = jjtreeFile + DEFAULT_SUFFIX;
                   } else {
  -                    optionalOutputFile = jjtreeFile.substring(0, suffixPos) 
  +                    optionalOutputFile = jjtreeFile.substring(0, suffixPos)
                           + DEFAULT_SUFFIX;
                   }
               }
           }
   
           if ((outputDirectory == null) || outputDirectory.equals("")) {
  -            outputDirectory = getProject().getBaseDir().getAbsolutePath();
  +            if (isAbsolute(optionalOutputFile)) {
  +                return optionalOutputFile.replace('\\','/');
  +            } else {
  +                outputDirectory = getProject().getBaseDir().getAbsolutePath();
  +            }
           }
  +
           return (outputDirectory + "/" + optionalOutputFile).replace('\\', '/');
  +    }
  +
  +    private boolean isAbsolute(String fileName) {
  +        return (fileName.startsWith("/") || (new File(fileName).isAbsolute()));
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message