Methods Summary |
---|
private java.lang.String | createOutputFileName(java.io.File destFile, java.lang.String optionalOutputFile, boolean plain)
String suffix = DEFAULT_SUFFIX_HTML;
String javaccFile = destFile.getAbsolutePath().replace('\\", '/");
if (plain) {
suffix = DEFAULT_SUFFIX_TEXT;
}
if ((optionalOutputFile == null) || optionalOutputFile.equals("")) {
int filePos = javaccFile.lastIndexOf("/");
if (filePos >= 0) {
javaccFile = javaccFile.substring(filePos + 1);
}
int suffixPos = javaccFile.lastIndexOf('.");
if (suffixPos == -1) {
optionalOutputFile = javaccFile + suffix;
} else {
String currentSuffix = javaccFile.substring(suffixPos);
if (currentSuffix.equals(suffix)) {
optionalOutputFile = javaccFile + suffix;
} else {
optionalOutputFile = javaccFile.substring(0, suffixPos)
+ suffix;
}
}
} else {
optionalOutputFile = optionalOutputFile.replace('\\", '/");
}
return (getProject().getBaseDir() + "/" + optionalOutputFile)
.replace('\\", '/");
|
public void | execute()Do the task.
// load command line with optional attributes
Enumeration iter = optionalAttrs.keys();
while (iter.hasMoreElements()) {
String name = (String) iter.nextElement();
Object value = optionalAttrs.get(name);
cmdl.createArgument()
.setValue("-" + name + ":" + value.toString());
}
if (targetFile == null || !targetFile.isFile()) {
throw new BuildException("Invalid target: " + targetFile);
}
if (outputFile != null) {
cmdl.createArgument() .setValue("-" + OUTPUT_FILE + ":"
+ outputFile.replace('\\", '/"));
}
// use the directory containing the target as the output directory
File javaFile = new File(createOutputFileName(targetFile, outputFile,
plainText));
if (javaFile.exists()
&& targetFile.lastModified() < javaFile.lastModified()) {
log("Target is already built - skipping (" + targetFile + ")",
Project.MSG_VERBOSE);
return;
}
cmdl.createArgument().setValue(targetFile.getAbsolutePath());
final Path classpath = cmdl.createClasspath(getProject());
final File javaccJar = JavaCC.getArchiveFile(javaccHome);
classpath.createPathElement().setPath(javaccJar.getAbsolutePath());
classpath.addJavaRuntime();
cmdl.setClassname(JavaCC.getMainClass(classpath,
JavaCC.TASKDEF_TYPE_JJDOC));
final Commandline.Argument arg = cmdl.createVmArgument();
arg.setValue("-mx140M");
arg.setValue("-Dinstall.root=" + javaccHome.getAbsolutePath());
final Execute process =
new Execute(new LogStreamHandler(this,
Project.MSG_INFO,
Project.MSG_INFO),
null);
log(cmdl.describeCommand(), Project.MSG_VERBOSE);
process.setCommandline(cmdl.getCommandline());
try {
if (process.execute() != 0) {
throw new BuildException("JJDoc failed.");
}
} catch (IOException e) {
throw new BuildException("Failed to launch JJDoc", e);
}
|
public void | setJavacchome(java.io.File javaccHome)The directory containing the JavaCC distribution.
this.javaccHome = javaccHome;
|
public void | setOnetable(boolean oneTable)Sets the ONE_TABLE documentation option.
optionalAttrs.put(ONE_TABLE, oneTable ? Boolean.TRUE : Boolean.FALSE);
|
public void | setOutputfile(java.lang.String outputFile)The outputfile to write the generated BNF documentation file to.
If not set, the file is written with the same name as
the JavaCC grammar file with a suffix .html or .txt.
this.outputFile = outputFile;
|
public void | setTarget(java.io.File target)The javacc grammar file to process.
this.targetFile = target;
|
public void | setText(boolean plainText)Sets the TEXT BNF documentation option.
optionalAttrs.put(TEXT, plainText ? Boolean.TRUE : Boolean.FALSE);
this.plainText = plainText;
|