Class JspC
- All Implemented Interfaces:
Cloneable, SelectorContainer
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 Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic inner class used as a parameter element -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanflag to control action on execution troubleprotected JspC.WebAppParameterweb appsFields inherited from class MatchingTask
filesetFields inherited from class ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWebApp(JspC.WebAppParameter webappParam) Adds a single webapp.Adds a path to the classpath.Support nested compiler classpath, used to locate compiler adaptervoiddelete 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 compilerGet the classpath.get the list of files to compileget the classpath used to find the compiler adapterGet the destination directory.booleanGets the failonerror flag.Get the IE CLASSID value.Get the name of the package.Get the source dir.Get the uri base value.Get the uri root value.intGet the verbose level.Get the web app.Get the webinc attribute.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 voidClear 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.voidAdds a reference to a classpath defined elsewherevoidsetCompiler(String compiler) Class name of a JSP compiler adapter.voidSet the classpath to be used to find this compiler adaptervoidsetDestdir(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 ExplorervoidsetMapped(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.voidSet 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 compilervoidoutput filename for the fraction of web.xml that lists servlets.voidFilename for web.xml.Methods inherited from class MatchingTask
add, 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, XsetItemsModifier and TypeMethodDescriptionvoidadd(FileSelector selector) add an arbitrary selectorvoidaddAnd(AndSelector selector) add an "And" selector entry on the selector listvoidaddContains(ContainsSelector selector) add a contains selector entry on the selector listvoidaddContainsRegexp(ContainsRegexpSelector selector) add a regular expression selector entry on the selector listvoidaddCustom(ExtendSelector selector) add an extended selector entry on the selector listvoidaddDate(DateSelector selector) add a selector date entry on the selector listvoidaddDepend(DependSelector selector) add a depends selector entry on the selector listvoidaddDepth(DepthSelector selector) add a depth selector entry on the selector listvoidaddDifferent(DifferentSelector selector) add a type selector entry on the type listvoidaddFilename(FilenameSelector selector) add a selector filename entry on the selector listvoidaddMajority(MajoritySelector selector) add a majority selector entry on the selector listvoidaddModified(ModifiedSelector selector) add the modified selectorvoidaddNone(NoneSelector selector) add a "None" selector entry on the selector listvoidaddNot(NotSelector selector) add a "Not" selector entry on the selector listvoidaddOr(OrSelector selector) add an "Or" selector entry on the selector listvoidaddPresent(PresentSelector selector) add a present selector entry on the selector listvoidaddSelector(SelectSelector selector) add a "Select" selector entry on the selector listvoidaddSize(SizeSelector selector) add a selector size entry on the selector listvoidaddType(TypeSelector selector) add a type selector entry on the type listvoidappendSelector(FileSelector selector) Add a new selector into this container.add a name entry on the exclude listadd a name entry on the include files listadd a name entry on the include listadd a name entry on the include files listadd a set of patternsprotected DirectoryScannergetDirectoryScanner(File baseDir) Returns the directory scanner needed to access the files to process.protected final FileSetAccessor for the implicit fileset.Returns the set of selectors as an array.booleanIndicates whether there are any selectors here.intGives the count of the number of selectors in this containerReturns an enumerator for accessing the set of selectors.voidsetCaseSensitive(boolean isCaseSensitive) Sets case sensitivity of the file systemvoidsetDefaultexcludes(boolean useDefaultExcludes) Sets whether default exclusions should be used or not.voidsetExcludes(String excludes) Sets the set of exclude patterns.voidsetExcludesfile(File excludesfile) Sets the name of the file containing the includes patterns.voidsetFollowSymlinks(boolean followSymlinks) Sets whether or not symbolic links or Windows junctions should be followed.voidsetIncludes(String includes) Sets the set of include patterns.voidsetIncludesfile(File includesfile) Sets the name of the file containing the includes patterns.voidsetProject(Project project) Sets the project object of this component.voidXsetIgnore(String ignoreString) List of filenames and directory names to not include.voidSet this to be the items in the base directory that you want to be included.Methods inherited from class Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeModifier and TypeMethodDescriptionfinal voidbindToOwner(Task owner) Bind a task to another; use this when configuring a newly created task to do work on behalf of another.Returns the container target of this task.Returns the wrapper used for runtime configuration.Returns the name to use in logging messages.Return the type of task.protected RuntimeConfigurableReturn the runtime configurable structure for this task.protected voidhandleErrorFlush(String output) Handles an error line by logging it with the WARN priority.protected voidhandleErrorOutput(String output) Handles an error output by logging it with the WARN priority.protected voidhandleFlush(String output) Handles output by logging it with the INFO priority.protected inthandleInput(byte[] buffer, int offset, int length) Handle an input request by this task.protected voidhandleOutput(String output) Handles output by logging it with the INFO priority.voidinit()Called by the project to let the task initialize properly.protected final booleanHas this task been marked invalid?voidLogs a message with the default (INFO) priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidConfigures this task - if it hasn't been done already.final voidperform()Performs this task if it's still valid, or gets a replacement version and performs that otherwise.voidForce the task to be reconfigured from its RuntimeConfigurable.voidsetOwningTarget(Target target) Sets the target container of this task.voidSets the wrapper to be used for runtime configuration.voidsetTaskName(String name) Sets the name to use in logging messages.voidsetTaskType(String type) Sets the name with which the task has been invoked.Methods inherited from class ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocationModifier and TypeMethodDescriptionclone()Returns the description of the current action.Returns the file/location where this task was defined.Returns the project to which this component belongs.voidsetDescription(String desc) Sets a description of the current action.voidsetLocation(Location location) Sets the file/location where this task was defined.
-
Field Details
-
compileList
-
failOnError
protected boolean failOnErrorflag to control action on execution trouble -
webApp
web apps
-
-
Constructor Details
-
JspC
public JspC()
-
-
Method Details
-
setSrcDir
Set the path for source JSP files.- Parameters:
srcDir- the source path.
-
getSrcDir
-
setDestdir
Set the destination directory into which the JSP source files should be compiled.- Parameters:
destDir- the destination directory.
-
getDestdir
-
setPackage
Set the name of the package the compiled jsp files should be in.- Parameters:
pkg- the name of the package.
-
getPackage
-
setVerbose
public void setVerbose(int i) Set the verbose level of the compiler- Parameters:
i- the verbose level to use.
-
getVerbose
public int getVerbose()Get the verbose level.- Returns:
- the level.
-
setFailonerror
public void setFailonerror(boolean fail) Whether or not the build should halt if compilation fails. Defaults totrue.- Parameters:
fail- abooleanvalue.
-
getFailonerror
public boolean getFailonerror()Gets the failonerror flag.- Returns:
- the flag.
-
getIeplugin
-
setIeplugin
Java Plugin CLASSID for Internet Explorer- Parameters:
iepluginid- the id to use.
-
isMapped
public boolean isMapped()If true, generate separate write() calls for each HTML line in the JSP.- Returns:
- mapping status
-
setMapped
public void setMapped(boolean mapped) If true, generate separate write() calls for each HTML line in the JSP.- Parameters:
mapped- abooleanvalue.
-
setUribase
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
-
getUribase
-
setUriroot
The root directory that uri files should be resolved against. (Default is the directory jspc is invoked from)- Parameters:
uriroot- The new Uribase value
-
getUriroot
-
setClasspath
Set the classpath to be used for this compilation.- Parameters:
cp- the path to be used.
-
createClasspath
-
setClasspathRef
Adds a reference to a classpath defined elsewhere- Parameters:
r- a reference to a classpath.
-
getClasspath
-
setCompilerclasspath
Set the classpath to be used to find this compiler adapter- Parameters:
cp- the compiler classpath.
-
getCompilerclasspath
get the classpath used to find the compiler adapter- Returns:
- the compiler classpath.
-
createCompilerclasspath
Support nested compiler classpath, used to locate compiler adapter- Returns:
- a path to be configured.
-
setWebxml
-
getWebxml
-
setWebinc
output filename for the fraction of web.xml that lists servlets.- Parameters:
webinc- The new Webinc value
-
getWebinc
-
addWebApp
Adds a single webapp.- Parameters:
webappParam- add a web app parameter- Throws:
BuildException- if more than one webapp is specified.
-
getWebApp
-
setCompiler
Class name of a JSP compiler adapter.- Parameters:
compiler- the compiler class name.
-
getCompileList
-
execute
execute by building up a list of files that have changed and hand them off to a jsp compiler- Overrides:
executein classTask- Throws:
BuildException- on error.
-
resetFileLists
protected void resetFileLists()Clear the list of files to be compiled and copied.. -
scanDir
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.
-
mapToJavaFile
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
-
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.
-