|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectTask
simple.page.ant.CompileTask
public class CompileTask
The CompileTask
represents an Ant task definition that
can be used within an Ant build file to compile JSP templates. This
offers the ability to use pre-compiled JSP templates with the
template engine. Compiling the templates before starting the server
ensures that an initial delay on requesting a page is not incurred.
To add this task to your Ant build the following can be used.
<taskdef name="jspc" classname="simple.page.ant.CompileTask"/>This declares a task named "jspc" which can be used within the Ant build.xml file to compile JSP sources. Typically you will have to add a classpath to the taskdef declaration so that it knows where to load the
CompileTask
byte code.
Once the task definition has been declared you will need to create a task execution configuration block. The following is an example of how to write a JSP compilation task. In the configuration below the "build" parameter is where sources and classes will be compiled to. The "project" parameter specifies the root package name used.
<jspc build="${home}/WEB-INF" project="test"> <source dir="${home}"> <include name="**/*.jsp"/> </source> <classpath> <fileset dir="${lib}"> <include name="**/*.jar"/> </fileset> </classpath> </jspc>To ensure that your JSP sources compile, you will need to add a classpath to the compiler. The classpath used has the same format of a typical Ant classpath element. Finally, the source element is used to specify the directory the source files are read from as well as the source files to include, this is an Ant "fileset".
Constructor Summary | |
---|---|
CompileTask()
|
Method Summary | |
---|---|
void |
addSource(FileSet source)
This is used to set the configuration for the source files to build. |
Path |
createClasspath()
This is used to create a classpath element from the Ant task. |
void |
execute()
This is used to execute the compile step. |
void |
execute(java.io.File path,
java.lang.String[] list)
This is used to execute the compile step. |
void |
setBuild(java.io.File build)
This is used to collect the build directory, which is where the JSP source files are translated and compiled to. |
void |
setClasspath(Path path)
This is used to set the classpath from an attribute. |
void |
setProject(java.lang.String project)
This is used to specify the name of the JSP workspace. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CompileTask()
Method Detail |
---|
public void setClasspath(Path path)
path
- this is the classpath specified in the Ant taskpublic void addSource(FileSet source) throws BuildException
source
- this is the file set for matching JSP sources
BuildException
public Path createClasspath()
public void setBuild(java.io.File build)
build
- this is the directory to compile JSP sources topublic void setProject(java.lang.String project)
project
- this is the root package for the sourcespublic void execute() throws BuildException
BuildException
- if there is a problem compilingpublic void execute(java.io.File path, java.lang.String[] list) throws java.lang.Exception
path
- this is the path to locate the JSP sources fromlist
- this is a list of URI paths for the JSP targets
java.lang.Exception
- if there is a problem compiling sources
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |