| Method from org.apache.tools.ant.taskdefs.optional.jsp.JspC Detail: |
public void addWebApp(JspC.WebAppParameter webappParam) throws BuildException {
//demand create vector of filesets
if (webApp == null) {
webApp = webappParam;
} else {
throw new BuildException("Only one webapp can be specified");
}
}
|
public Path createClasspath() {
if (classpath == null) {
classpath = new Path(getProject());
}
return classpath.createPath();
}
Adds a path to the classpath. |
public Path createCompilerclasspath() {
if (compilerClasspath == null) {
compilerClasspath = new Path(getProject());
}
return compilerClasspath.createPath();
}
Support nested compiler classpath, used to locate compiler adapter |
public void deleteEmptyJavaFiles() {
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();
}
}
}
}
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. |
public void execute() throws BuildException {
// 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);
}
}
}
execute by building up a list of files that
have changed and hand them off to a jsp compiler |
public Path getClasspath() {
return classpath;
}
|
public Vector getCompileList() {
return compileList;
}
get the list of files to compile |
public Path getCompilerclasspath() {
return compilerClasspath;
}
get the classpath used to find the compiler adapter |
public File getDestdir() {
return destDir;
}
Get the destination directory. |
public boolean getFailonerror() {
return failOnError;
}
Gets the failonerror flag. |
public String getIeplugin() {
return iepluginid;
}
Get the IE CLASSID value. |
public String getPackage() {
return packageName;
}
Get the name of the package. |
public Path getSrcDir() {
return src;
}
|
public File getUribase() {
return uriroot;
}
|
public File getUriroot() {
return uriroot;
}
|
public int getVerbose() {
return verbose;
}
|
public JspC.WebAppParameter getWebApp() {
return webApp;
}
|
public File getWebinc() {
return this.webinc;
}
Get the webinc attribute. |
public File getWebxml() {
return this.webxml;
}
|
public boolean isMapped() {
return mapped;
}
If true, generate separate write() calls for each HTML line
in the JSP. |
protected File mapToJavaFile(JspMangler mangler,
File srcFile,
File srcDir,
File dest) {
if (!srcFile.getName().endsWith(".jsp")) {
return null;
}
String javaFileName = mangler.mapJspToJavaName(srcFile);
// String srcFileDir=srcFile.getParent();
return new File(dest, javaFileName);
}
get a filename from our jsp file. |
protected void resetFileLists() {
compileList.removeAllElements();
}
Clear the list of files to be compiled and copied.. |
protected void scanDir(File srcDir,
File dest,
JspMangler mangler,
String[] files) {
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);
}
}
}
Scans the directory looking for source files to be compiled.
The results are returned in the class variable compileList |
public void setClasspath(Path cp) {
if (classpath == null) {
classpath = cp;
} else {
classpath.append(cp);
}
}
Set the classpath to be used for this compilation. |
public void setClasspathRef(Reference r) {
createClasspath().setRefid(r);
}
Adds a reference to a classpath defined elsewhere |
public void setCompiler(String compiler) {
this.compilerName = compiler;
}
Class name of a JSP compiler adapter. |
public void setCompilerclasspath(Path cp) {
if (compilerClasspath == null) {
compilerClasspath = cp;
} else {
compilerClasspath.append(cp);
}
}
Set the classpath to be used to find this compiler adapter |
public void setDestdir(File destDir) {
this.destDir = destDir;
}
Set the destination directory into which the JSP source
files should be compiled. |
public void setFailonerror(boolean fail) {
failOnError = fail;
}
Whether or not the build should halt if compilation fails.
Defaults to true. |
public void setIeplugin(String iepluginid) {
this.iepluginid = iepluginid;
}
Java Plugin CLASSID for Internet Explorer |
public void setMapped(boolean mapped) {
this.mapped = mapped;
}
If true, generate separate write() calls for each HTML line
in the JSP. |
public void setPackage(String pkg) {
this.packageName = pkg;
}
Set the name of the package the compiled jsp files should be in. |
public void setSrcDir(Path srcDir) {
// CheckStyle:VisibilityModifier ON
if (src == null) {
src = srcDir;
} else {
src.append(srcDir);
}
}
Set the path for source JSP files. |
public void setUribase(File uribase) {
log("Uribase is currently an unused parameter", Project.MSG_WARN);
}
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. |
public void setUriroot(File uriroot) {
this.uriroot = uriroot;
}
The root directory that uri files should be resolved
against. (Default is the directory jspc is invoked from) |
public void setVerbose(int i) {
verbose = i;
}
Set the verbose level of the compiler |
public void setWebinc(File webinc) {
this.webinc = webinc;
}
output filename for the fraction of web.xml that lists
servlets. |
public void setWebxml(File webxml) {
this.webxml = webxml;
}
|