Methods Summary |
---|
public void | addWebApp(org.apache.tools.ant.taskdefs.optional.jsp.JspC$WebAppParameter webappParam)Adds a single webapp.
//demand create vector of filesets
if (webApp == null) {
webApp = webappParam;
} else {
throw new BuildException("Only one webapp can be specified");
}
|
public org.apache.tools.ant.types.Path | createClasspath()Adds a path to the classpath.
if (classpath == null) {
classpath = new Path(getProject());
}
return classpath.createPath();
|
public org.apache.tools.ant.types.Path | createCompilerclasspath()Support nested compiler classpath, used to locate compiler adapter
if (compilerClasspath == null) {
compilerClasspath = new Path(getProject());
}
return compilerClasspath.createPath();
|
public void | deleteEmptyJavaFiles()delete any java output files that are empty
this is to get around a little defect in jasper: when it
fails, it leaves incomplete files around.
if (javaFiles != null) {
Enumeration e = javaFiles.elements();
while (e.hasMoreElements()) {
File file = (File) e.nextElement();
if (file.exists() && file.length() == 0) {
log("deleting empty output file " + file);
file.delete();
}
}
}
|
private void | doCompilation(org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapter compiler)do the compile
// now we need to populate the compiler adapter
compiler.setJspc(this);
// finally, lets execute the compiler!!
if (!compiler.execute()) {
if (failOnError) {
throw new BuildException(FAIL_MSG, getLocation());
} else {
log(FAIL_MSG, Project.MSG_ERR);
}
}
|
public void | execute()execute by building up a list of files that
have changed and hand them off to a jsp compiler
// make sure that we've got a destdir
if (destDir == null) {
throw new BuildException("destdir attribute must be set!",
getLocation());
}
if (!destDir.isDirectory()) {
throw new BuildException("destination directory \"" + destDir
+ "\" does not exist or is not a directory", getLocation());
}
File dest = getActualDestDir();
//bind to a compiler
JspCompilerAdapter compiler =
JspCompilerAdapterFactory.getCompiler(compilerName, this,
getProject().createClassLoader(compilerClasspath));
//if we are a webapp, hand off to the compiler, which had better handle it
if (webApp != null) {
doCompilation(compiler);
return;
}
// make sure that we've got a srcdir
if (src == null) {
throw new BuildException("srcdir attribute must be set!",
getLocation());
}
String [] list = src.list();
if (list.length == 0) {
throw new BuildException("srcdir attribute must be set!",
getLocation());
}
// if the compiler does its own dependency stuff, we just call it right now
if (compiler.implementsOwnDependencyChecking()) {
doCompilation(compiler);
return;
}
//the remainder of this method is only for compilers that need their dependency work done
JspMangler mangler = compiler.createMangler();
// scan source directories and dest directory to build up both copy
// lists and compile lists
resetFileLists();
int filecount = 0;
for (int i = 0; i < list.length; i++) {
File srcDir = getProject().resolveFile(list[i]);
if (!srcDir.exists()) {
throw new BuildException("srcdir \"" + srcDir.getPath()
+ "\" does not exist!", getLocation());
}
DirectoryScanner ds = this.getDirectoryScanner(srcDir);
String[] files = ds.getIncludedFiles();
filecount = files.length;
scanDir(srcDir, dest, mangler, files);
}
// compile the source files
log("compiling " + compileList.size() + " files", Project.MSG_VERBOSE);
if (compileList.size() > 0) {
log("Compiling " + compileList.size() + " source file"
+ (compileList.size() == 1 ? "" : "s")
+ " to "
+ dest);
doCompilation(compiler);
} else {
if (filecount == 0) {
log("there were no files to compile", Project.MSG_INFO);
} else {
log("all files are up to date", Project.MSG_VERBOSE);
}
}
|
private java.io.File | getActualDestDir()calculate where the files will end up:
this is destDir or it id destDir + the package name
File dest = null;
if (packageName == null) {
dest = destDir;
} else {
String path = destDir.getPath() + File.separatorChar
+ packageName.replace('.", File.separatorChar);
dest = new File(path);
}
return dest;
|
public org.apache.tools.ant.types.Path | getClasspath()Get the classpath.
return classpath;
|
public java.util.Vector | getCompileList()get the list of files to compile
return compileList;
|
public org.apache.tools.ant.types.Path | getCompilerclasspath()get the classpath used to find the compiler adapter
return compilerClasspath;
|
public java.io.File | getDestdir()Get the destination directory.
return destDir;
|
public boolean | getFailonerror()Gets the failonerror flag.
return failOnError;
|
public java.lang.String | getIeplugin()Get the IE CLASSID value.
return iepluginid;
|
public java.lang.String | getPackage()Get the name of the package.
return packageName;
|
public org.apache.tools.ant.types.Path | getSrcDir()Get the source dir.
return src;
|
public java.io.File | getUribase()Get the uri base value.
return uriroot;
|
public java.io.File | getUriroot()Get the uri root value.
return uriroot;
|
public int | getVerbose()Get the verbose level.
return verbose;
|
public org.apache.tools.ant.taskdefs.optional.jsp.JspC$WebAppParameter | getWebApp()Get the web app.
return webApp;
|
public java.io.File | getWebinc()Get the webinc attribute.
return this.webinc;
|
public java.io.File | getWebxml()Filename for web.xml.
return this.webxml;
|
private boolean | isCompileNeeded(java.io.File srcFile, java.io.File javaFile)Test whether or not compilation is needed. A return value of
true means yes, false means
our tests do not indicate this, but as the TLDs are
not used for dependency checking this is not guaranteed.
The current tests are
- no dest file
- dest file out of date w.r.t source
- dest file zero bytes long
boolean shouldCompile = false;
if (!javaFile.exists()) {
shouldCompile = true;
log("Compiling " + srcFile.getPath()
+ " because java file " + javaFile.getPath()
+ " does not exist", Project.MSG_VERBOSE);
} else {
if (srcFile.lastModified() > javaFile.lastModified()) {
shouldCompile = true;
log("Compiling " + srcFile.getPath()
+ " because it is out of date with respect to "
+ javaFile.getPath(),
Project.MSG_VERBOSE);
} else {
if (javaFile.length() == 0) {
shouldCompile = true;
log("Compiling " + srcFile.getPath()
+ " because java file " + javaFile.getPath()
+ " is empty", Project.MSG_VERBOSE);
}
}
}
return shouldCompile;
|
public boolean | isMapped()If true, generate separate write() calls for each HTML line
in the JSP.
return mapped;
|
protected java.io.File | mapToJavaFile(JspMangler mangler, java.io.File srcFile, java.io.File srcDir, java.io.File dest)get a filename from our jsp file.
if (!srcFile.getName().endsWith(".jsp")) {
return null;
}
String javaFileName = mangler.mapJspToJavaName(srcFile);
// String srcFileDir=srcFile.getParent();
return new File(dest, javaFileName);
|
protected void | resetFileLists()Clear the list of files to be compiled and copied..
compileList.removeAllElements();
|
protected void | scanDir(java.io.File srcDir, java.io.File dest, JspMangler mangler, java.lang.String[] files)Scans the directory looking for source files to be compiled.
The results are returned in the class variable compileList
long now = (new Date()).getTime();
for (int i = 0; i < files.length; i++) {
String filename = files[i];
File srcFile = new File(srcDir, filename);
File javaFile = mapToJavaFile(mangler, srcFile, srcDir, dest);
if (javaFile == null) {
continue;
}
if (srcFile.lastModified() > now) {
log("Warning: file modified in the future: " + filename,
Project.MSG_WARN);
}
boolean shouldCompile = false;
shouldCompile = isCompileNeeded(srcFile, javaFile);
if (shouldCompile) {
compileList.addElement(srcFile.getAbsolutePath());
javaFiles.addElement(javaFile);
}
}
|
public void | setClasspath(org.apache.tools.ant.types.Path cp)Set the classpath to be used for this compilation.
if (classpath == null) {
classpath = cp;
} else {
classpath.append(cp);
}
|
public void | setClasspathRef(org.apache.tools.ant.types.Reference r)Adds a reference to a classpath defined elsewhere
createClasspath().setRefid(r);
|
public void | setCompiler(java.lang.String compiler)Class name of a JSP compiler adapter.
this.compilerName = compiler;
|
public void | setCompilerclasspath(org.apache.tools.ant.types.Path cp)Set the classpath to be used to find this compiler adapter
if (compilerClasspath == null) {
compilerClasspath = cp;
} else {
compilerClasspath.append(cp);
}
|
public void | setDestdir(java.io.File destDir)Set the destination directory into which the JSP source
files should be compiled.
this.destDir = destDir;
|
public void | setFailonerror(boolean fail)Whether or not the build should halt if compilation fails.
Defaults to true .
failOnError = fail;
|
public void | setIeplugin(java.lang.String iepluginid)Java Plugin CLASSID for Internet Explorer
this.iepluginid = iepluginid;
|
public void | setMapped(boolean mapped)If true, generate separate write() calls for each HTML line
in the JSP.
this.mapped = mapped;
|
public void | setPackage(java.lang.String pkg)Set the name of the package the compiled jsp files should be in.
this.packageName = pkg;
|
public void | setSrcDir(org.apache.tools.ant.types.Path srcDir)Set the path for source JSP files.
// CheckStyle:VisibilityModifier ON
if (src == null) {
src = srcDir;
} else {
src.append(srcDir);
}
|
public void | setUribase(java.io.File uribase)The URI context of relative URI references in the JSP pages.
If it does not exist then it is derived from the location
of the file relative to the declared or derived value of uriroot.
log("Uribase is currently an unused parameter", Project.MSG_WARN);
|
public void | setUriroot(java.io.File uriroot)The root directory that uri files should be resolved
against. (Default is the directory jspc is invoked from)
this.uriroot = uriroot;
|
public void | setVerbose(int i)Set the verbose level of the compiler
verbose = i;
|
public void | setWebinc(java.io.File webinc)output filename for the fraction of web.xml that lists
servlets.
this.webinc = webinc;
|
public void | setWebxml(java.io.File webxml)Filename for web.xml.
this.webxml = webxml;
|