Class JspC
- java.lang.Object
- 
- org.apache.tools.ant.ProjectComponent
- 
- org.apache.tools.ant.Task
- 
- org.apache.tools.ant.taskdefs.MatchingTask
- 
- org.apache.tools.ant.taskdefs.optional.jsp.JspC
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable,- SelectorContainer
 
 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>Large amount of cutting and pasting from the Javac task... - Since:
- 1.5
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classJspC.WebAppParameterstatic inner class used as a parameter element
 - 
Field SummaryFields Modifier and Type Field Description protected java.util.Vector<java.lang.String>compileListprotected booleanfailOnErrorflag to control action on execution troubleprotected JspC.WebAppParameterwebAppweb apps- 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTaskfileset
 - 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description JspC()
 - 
Method SummaryModifier and Type Method Description voidaddWebApp(JspC.WebAppParameter webappParam)Adds a single webapp.PathcreateClasspath()Adds a path to the classpath.PathcreateCompilerclasspath()Support nested compiler classpath, used to locate compiler adaptervoiddeleteEmptyJavaFiles()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 compilerPathgetClasspath()Get the classpath.java.util.Vector<java.lang.String>getCompileList()get the list of files to compilePathgetCompilerclasspath()get the classpath used to find the compiler adapterjava.io.FilegetDestdir()Get the destination directory.booleangetFailonerror()Gets the failonerror flag.java.lang.StringgetIeplugin()Get the IE CLASSID value.java.lang.StringgetPackage()Get the name of the package.PathgetSrcDir()Get the source dir.java.io.FilegetUribase()Get the uri base value.java.io.FilegetUriroot()Get the uri root value.intgetVerbose()Get the verbose level.JspC.WebAppParametergetWebApp()Get the web app.java.io.FilegetWebinc()Get the webinc attribute.java.io.FilegetWebxml()Filename for web.xml.booleanisMapped()If true, generate separate write() calls for each HTML line in the JSP.protected java.io.FilemapToJavaFile(JspMangler mangler, java.io.File srcFile, java.io.File srcDir, java.io.File dest)get a filename from our jsp file.protected voidresetFileLists()Clear the list of files to be compiled and copied..protected voidscanDir(java.io.File srcDir, java.io.File dest, JspMangler mangler, java.lang.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 elsewherevoidsetCompiler(java.lang.String compiler)Class name of a JSP compiler adapter.voidsetCompilerclasspath(Path cp)Set the classpath to be used to find this compiler adaptervoidsetDestdir(java.io.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(java.lang.String iepluginid)Java Plugin CLASSID for Internet ExplorervoidsetMapped(boolean mapped)If true, generate separate write() calls for each HTML line in the JSP.voidsetPackage(java.lang.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(java.io.File uribase)The URI context of relative URI references in the JSP pages.voidsetUriroot(java.io.File uriroot)The root directory that uri files should be resolved against.voidsetVerbose(int i)Set the verbose level of the compilervoidsetWebinc(java.io.File webinc)output filename for the fraction of web.xml that lists servlets.voidsetWebxml(java.io.File webxml)Filename for web.xml.- 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTaskadd, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 - 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation
 
- 
 
- 
- 
- 
Field Detail- 
compileListprotected java.util.Vector<java.lang.String> compileList 
 - 
failOnErrorprotected boolean failOnError flag to control action on execution trouble
 - 
webAppprotected JspC.WebAppParameter webApp web apps
 
- 
 - 
Method Detail- 
setSrcDirpublic void setSrcDir(Path srcDir) Set the path for source JSP files.- Parameters:
- srcDir- the source path.
 
 - 
getSrcDirpublic Path getSrcDir() Get the source dir.- Returns:
- the source path.
 
 - 
setDestdirpublic void setDestdir(java.io.File destDir) Set the destination directory into which the JSP source files should be compiled.- Parameters:
- destDir- the destination directory.
 
 - 
getDestdirpublic java.io.File getDestdir() Get the destination directory.- Returns:
- the directory.
 
 - 
setPackagepublic void setPackage(java.lang.String pkg) Set the name of the package the compiled jsp files should be in.- Parameters:
- pkg- the name of the package.
 
 - 
getPackagepublic java.lang.String getPackage() Get the name of the package.- Returns:
- the package.
 
 - 
setVerbosepublic void setVerbose(int i) Set the verbose level of the compiler- Parameters:
- i- the verbose level to use.
 
 - 
getVerbosepublic int getVerbose() Get the verbose level.- Returns:
- the level.
 
 - 
setFailonerrorpublic void setFailonerror(boolean fail) Whether or not the build should halt if compilation fails. Defaults totrue.- Parameters:
- fail- a- booleanvalue.
 
 - 
getFailonerrorpublic boolean getFailonerror() Gets the failonerror flag.- Returns:
- the flag.
 
 - 
getIepluginpublic java.lang.String getIeplugin() Get the IE CLASSID value.- Returns:
- the value.
 
 - 
setIepluginpublic void setIeplugin(java.lang.String iepluginid) Java Plugin CLASSID for Internet Explorer- Parameters:
- iepluginid- the id to use.
 
 - 
isMappedpublic boolean isMapped() If true, generate separate write() calls for each HTML line in the JSP.- Returns:
- mapping status
 
 - 
setMappedpublic void setMapped(boolean mapped) If true, generate separate write() calls for each HTML line in the JSP.- Parameters:
- mapped- a- booleanvalue.
 
 - 
setUribasepublic 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.- Parameters:
- uribase- The new Uribase value
 
 - 
getUribasepublic java.io.File getUribase() Get the uri base value.- Returns:
- the value.
 
 - 
setUrirootpublic void setUriroot(java.io.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
 
 - 
getUrirootpublic java.io.File getUriroot() Get the uri root value.- Returns:
- the value.
 
 - 
setClasspathpublic void setClasspath(Path cp) Set the classpath to be used for this compilation.- Parameters:
- cp- the path to be used.
 
 - 
createClasspathpublic Path createClasspath() Adds a path to the classpath.- Returns:
- a path to be configured.
 
 - 
setClasspathRefpublic void setClasspathRef(Reference r) Adds a reference to a classpath defined elsewhere- Parameters:
- r- a reference to a classpath.
 
 - 
getClasspathpublic Path getClasspath() Get the classpath.- Returns:
- the classpath.
 
 - 
setCompilerclasspathpublic void setCompilerclasspath(Path cp) Set the classpath to be used to find this compiler adapter- Parameters:
- cp- the compiler classpath.
 
 - 
getCompilerclasspathpublic Path getCompilerclasspath() get the classpath used to find the compiler adapter- Returns:
- the compiler classpath.
 
 - 
createCompilerclasspathpublic Path createCompilerclasspath() Support nested compiler classpath, used to locate compiler adapter- Returns:
- a path to be configured.
 
 - 
setWebxmlpublic void setWebxml(java.io.File webxml) Filename for web.xml.- Parameters:
- webxml- The new Webxml value
 
 - 
getWebxmlpublic java.io.File getWebxml() Filename for web.xml.- Returns:
- The filename for web.xml.
 
 - 
setWebincpublic void setWebinc(java.io.File webinc) output filename for the fraction of web.xml that lists servlets.- Parameters:
- webinc- The new Webinc value
 
 - 
getWebincpublic java.io.File getWebinc() Get the webinc attribute.- Returns:
- the webinc attribute.
 
 - 
addWebApppublic void addWebApp(JspC.WebAppParameter webappParam) throws BuildException Adds a single webapp.- Parameters:
- webappParam- add a web app parameter
- Throws:
- BuildException- if more than one webapp is specified.
 
 - 
getWebApppublic JspC.WebAppParameter getWebApp() Get the web app.- Returns:
- the web app attribute.
 
 - 
setCompilerpublic void setCompiler(java.lang.String compiler) Class name of a JSP compiler adapter.- Parameters:
- compiler- the compiler class name.
 
 - 
getCompileListpublic java.util.Vector<java.lang.String> getCompileList() get the list of files to compile- Returns:
- the list of files.
 
 - 
executepublic void execute() throws BuildExceptionexecute by building up a list of files that have changed and hand them off to a jsp compiler- Overrides:
- executein class- Task
- Throws:
- BuildException- on error.
 
 - 
resetFileListsprotected void resetFileLists() Clear the list of files to be compiled and copied..
 - 
scanDirprotected 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- Parameters:
- srcDir- the source directory.
- dest- the destination directory.
- mangler- the jsp filename mangler.
- files- the file names to mangle.
 
 - 
mapToJavaFileprotected 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.- Parameters:
- mangler- the jsp filename manager.
- srcFile- the source file.
- srcDir- the source directory.
- dest- the destination directory.
- Returns:
- the filename.
- To do:
- support packages and subdirs
 
 - 
deleteEmptyJavaFilespublic 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.
 
- 
 
-