Browse Source

backwards compatibility fix submitted by Jene Jasper

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274948 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
fa49c59243
1 changed files with 19 additions and 10 deletions
  1. +19
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java

+ 19
- 10
src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java View File

@@ -72,7 +72,7 @@ import org.apache.tools.ant.util.JavaEnvUtils;
* Runs the JJTree compiler compiler. * Runs the JJTree compiler compiler.
* *
* @author thomas.haas@softwired-inc.com * @author thomas.haas@softwired-inc.com
* @author Michael Saunders
* @author Michael Saunders
* <a href="mailto:michael@amtec.com">michael@amtec.com</a> * <a href="mailto:michael@amtec.com">michael@amtec.com</a>
*/ */
public class JJTree extends Task { public class JJTree extends Task {
@@ -232,9 +232,9 @@ public class JJTree extends Task {
if (target == null || !target.isFile()) { if (target == null || !target.isFile()) {
throw new BuildException("Invalid target: " + target); throw new BuildException("Invalid target: " + target);
} }
if (outputFile != null) { if (outputFile != null) {
cmdl.createArgument().setValue("-" + OUTPUT_FILE + ":"
cmdl.createArgument().setValue("-" + OUTPUT_FILE + ":"
+ outputFile.replace('\\', '/')); + outputFile.replace('\\', '/'));
} }


@@ -242,21 +242,21 @@ public class JJTree extends Task {


// use the directory containing the target as the output directory // use the directory containing the target as the output directory
if (outputDirectory == null) { if (outputDirectory == null) {
javaFile = new File(createOutputFileName(target, outputFile,
javaFile = new File(createOutputFileName(target, outputFile,
null)); null));
} else { } else {
if (!outputDirectory.isDirectory()) { if (!outputDirectory.isDirectory()) {
throw new BuildException("'outputdirectory' " + outputDirectory throw new BuildException("'outputdirectory' " + outputDirectory
+ " is not a directory."); + " is not a directory.");
} }
// convert backslashes to slashes, otherwise jjtree will // convert backslashes to slashes, otherwise jjtree will
// put this as comments and this seems to confuse javacc // put this as comments and this seems to confuse javacc
cmdl.createArgument().setValue("-OUTPUT_DIRECTORY:" cmdl.createArgument().setValue("-OUTPUT_DIRECTORY:"
+ outputDirectory.getAbsolutePath() + outputDirectory.getAbsolutePath()
.replace('\\', '/')); .replace('\\', '/'));
javaFile = new File(createOutputFileName(target, outputFile,
javaFile = new File(createOutputFileName(target, outputFile,
outputDirectory outputDirectory
.getPath())); .getPath()));
} }
@@ -269,7 +269,7 @@ public class JJTree extends Task {
} }
cmdl.createArgument().setValue(target.getAbsolutePath()); cmdl.createArgument().setValue(target.getAbsolutePath());


cmdl.setClassname(JavaCC.getMainClass(javaccHome,
cmdl.setClassname(JavaCC.getMainClass(javaccHome,
JavaCC.TASKDEF_TYPE_JJTREE)); JavaCC.TASKDEF_TYPE_JJTREE));


final Path classpath = cmdl.createClasspath(getProject()); final Path classpath = cmdl.createClasspath(getProject());
@@ -319,15 +319,24 @@ public class JJTree extends Task {
if (currentSuffix.equals(DEFAULT_SUFFIX)) { if (currentSuffix.equals(DEFAULT_SUFFIX)) {
optionalOutputFile = jjtreeFile + DEFAULT_SUFFIX; optionalOutputFile = jjtreeFile + DEFAULT_SUFFIX;
} else { } else {
optionalOutputFile = jjtreeFile.substring(0, suffixPos)
optionalOutputFile = jjtreeFile.substring(0, suffixPos)
+ DEFAULT_SUFFIX; + DEFAULT_SUFFIX;
} }
} }
} }


if ((outputDirectory == null) || outputDirectory.equals("")) { if ((outputDirectory == null) || outputDirectory.equals("")) {
outputDirectory = getProject().getBaseDir().getAbsolutePath();
if (isAbsolute(optionalOutputFile)) {
return optionalOutputFile.replace('\\','/');
} else {
outputDirectory = getProject().getBaseDir().getAbsolutePath();
}
} }

return (outputDirectory + "/" + optionalOutputFile).replace('\\', '/'); return (outputDirectory + "/" + optionalOutputFile).replace('\\', '/');
} }

private boolean isAbsolute(String fileName) {
return (fileName.startsWith("/") || (new File(fileName).isAbsolute()));
}
} }

Loading…
Cancel
Save