org.apache.tools.ant.taskdefs.optional.jsp

Class JspC

public class JspC extends MatchingTask

Runs a JSP compiler.

This task takes the given jsp files and compiles them into java files. It is then up to the user to compile the java files into classes.

The task requires the srcdir and destdir attributes to be set. This Task is a MatchingTask, so the files to be compiled can be specified using includes/excludes attributes or nested include/exclude elements. Optional attributes are verbose (set the verbosity level passed to jasper), package (name of the destination package for generated java classes and classpath (the classpath to use when running the jsp compiler).

This task supports the nested elements classpath (A Path) and classpathref (A Reference) which can be used in preference to the attribute classpath, if the jsp compiler is not already in the ant classpath.

Usage

 <jspc srcdir="${basedir}/src/war"
       destdir="${basedir}/gensrc"
       package="com.i3sp.jsp"
       verbose="9">
   <include name="**\/*.jsp" />
 </jspc>
 

Since: 1.5

Nested Class Summary
static classJspC.WebAppParameter
static inner class used as a parameter element
Field Summary
protected VectorcompileList
protected booleanfailOnError
flag to control action on execution trouble
protected JspC.WebAppParameterwebApp
web apps
Method Summary
voidaddWebApp(JspC.WebAppParameter webappParam)
Adds a single webapp.
PathcreateClasspath()
Adds a path to the classpath.
PathcreateCompilerclasspath()
Support nested compiler classpath, used to locate compiler adapter
voiddeleteEmptyJavaFiles()
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.
voidexecute()
execute by building up a list of files that have changed and hand them off to a jsp compiler
PathgetClasspath()
VectorgetCompileList()
get the list of files to compile
PathgetCompilerclasspath()
get the classpath used to find the compiler adapter
FilegetDestdir()
booleangetFailonerror()
Gets the failonerror flag.
StringgetIeplugin()
StringgetPackage()
PathgetSrcDir()
FilegetUribase()
FilegetUriroot()
intgetVerbose()
JspC.WebAppParametergetWebApp()
FilegetWebinc()
FilegetWebxml()
Filename for web.xml.
booleanisMapped()
If true, generate separate write() calls for each HTML line in the JSP.
protected FilemapToJavaFile(JspMangler mangler, File srcFile, File srcDir, File dest)
get a filename from our jsp file
protected voidresetFileLists()
Clear the list of files to be compiled and copied..
protected voidscanDir(File srcDir, File dest, JspMangler mangler, String[] files)
Scans the directory looking for source files to be compiled.
voidsetClasspath(Path cp)
Set the classpath to be used for this compilation.
voidsetClasspathRef(Reference r)
Adds a reference to a classpath defined elsewhere
voidsetCompiler(String compiler)
Class name of a JSP compiler adapter.
voidsetCompilerclasspath(Path cp)
Set the classpath to be used to find this compiler adapter
voidsetDestdir(File destDir)
Set the destination directory into which the JSP source files should be compiled.
voidsetFailonerror(boolean fail)
Whether or not the build should halt if compilation fails.
voidsetIeplugin(String iepluginid)
Java Plugin CLASSID for Internet Explorer
voidsetMapped(boolean mapped)
If true, generate separate write() calls for each HTML line in the JSP.
voidsetPackage(String pkg)
Set the name of the package the compiled jsp files should be in.
voidsetSrcDir(Path srcDir)
Set the path for source JSP files.
voidsetUribase(File uribase)
The URI context of relative URI references in the JSP pages.
voidsetUriroot(File uriroot)
The root directory that uri files should be resolved against.
voidsetVerbose(int i)
Set the verbose level of the compiler
voidsetWebinc(File webinc)
output filename for the fraction of web.xml that lists servlets.
voidsetWebxml(File webxml)
Filename for web.xml.

Field Detail

compileList

protected Vector compileList

failOnError

protected boolean failOnError
flag to control action on execution trouble

webApp

protected JspC.WebAppParameter webApp
web apps

Method Detail

addWebApp

public void addWebApp(JspC.WebAppParameter webappParam)
Adds a single webapp.

Parameters: webappParam add a web app parameter

createClasspath

public Path createClasspath()
Adds a path to the classpath.

createCompilerclasspath

public Path createCompilerclasspath()
Support nested compiler classpath, used to locate compiler adapter

deleteEmptyJavaFiles

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.

execute

public void execute()
execute by building up a list of files that have changed and hand them off to a jsp compiler

getClasspath

public Path getClasspath()

getCompileList

public Vector getCompileList()
get the list of files to compile

getCompilerclasspath

public Path getCompilerclasspath()
get the classpath used to find the compiler adapter

getDestdir

public File getDestdir()

getFailonerror

public boolean getFailonerror()
Gets the failonerror flag.

getIeplugin

public String getIeplugin()

getPackage

public String getPackage()

getSrcDir

public Path getSrcDir()

getUribase

public File getUribase()

getUriroot

public File getUriroot()

getVerbose

public int getVerbose()

getWebApp

public JspC.WebAppParameter getWebApp()

getWebinc

public File getWebinc()

getWebxml

public File getWebxml()
Filename for web.xml.

Returns: The filename for web.xml.

isMapped

public boolean isMapped()
If true, generate separate write() calls for each HTML line in the JSP.

Returns: mapping status

mapToJavaFile

protected File mapToJavaFile(JspMangler mangler, File srcFile, File srcDir, File dest)
get a filename from our jsp file

UNKNOWN: support packages and subdirs

resetFileLists

protected void resetFileLists()
Clear the list of files to be compiled and copied..

scanDir

protected void scanDir(File srcDir, File dest, JspMangler mangler, String[] files)
Scans the directory looking for source files to be compiled. The results are returned in the class variable compileList

setClasspath

public void setClasspath(Path cp)
Set the classpath to be used for this compilation.

setClasspathRef

public void setClasspathRef(Reference r)
Adds a reference to a classpath defined elsewhere

setCompiler

public void setCompiler(String compiler)
Class name of a JSP compiler adapter.

setCompilerclasspath

public void setCompilerclasspath(Path cp)
Set the classpath to be used to find this compiler adapter

setDestdir

public void setDestdir(File destDir)
Set the destination directory into which the JSP source files should be compiled.

setFailonerror

public void setFailonerror(boolean fail)
Whether or not the build should halt if compilation fails. Defaults to true.

setIeplugin

public void setIeplugin(String iepluginid)
Java Plugin CLASSID for Internet Explorer

setMapped

public void setMapped(boolean mapped)
If true, generate separate write() calls for each HTML line in the JSP.

setPackage

public void setPackage(String pkg)
Set the name of the package the compiled jsp files should be in.

setSrcDir

public void setSrcDir(Path srcDir)
Set the path for source JSP files.

setUribase

public void setUribase(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.

Parameters: uribase The new Uribase value

setUriroot

public void setUriroot(File uriroot)
The root directory that uri files should be resolved against. (Default is the directory jspc is invoked from)

Parameters: uriroot The new Uribase value

setVerbose

public void setVerbose(int i)
Set the verbose level of the compiler

setWebinc

public void setWebinc(File webinc)
output filename for the fraction of web.xml that lists servlets.

Parameters: webinc The new Webinc value

setWebxml

public void setWebxml(File webxml)
Filename for web.xml.

Parameters: webxml The new Webxml value

Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.