The Jasper JSPC Gradle plugin lets you run the Liferay Jasper JSPC tool to compile the JavaServer Pages (JSP) files in your project. This can be useful to
- check for errors in the JSP files.
- pre-compile the JSP files for better performance.
The plugin has been successfully tested with Gradle 4.10.2.
Usage
To use the plugin, include it in your build script:
buildscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.jasper.jspc", version: "2.0.5"
}
repositories {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
}
apply plugin: "com.liferay.jasper.jspc"
The Jasper JSPC plugin automatically applies the java
plugin.
Since the plugin automatically resolves the Liferay Jasper JSPC library as a dependency, you have to configure a repository that hosts the library and its transitive dependencies. The Liferay CDN repository hosts them all:
repositories {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
Tasks
The plugin adds two tasks to your project:
Name | Depends On | Type | Description |
---|---|---|---|
compileJSP | generateJSPJava | JavaCompile | Compiles JSP files to check for errors. |
generateJSPJava | jar | CompileJSPTask | Compiles JSP files to Java source files to check for errors. |
The generateJSPJava
task is automatically configured with sensible defaults,
depending on whether the war
plugin is applied:
Property Name | Default Value |
---|---|
classpath | project.configurations.jspCTool |
destinationDir | "${project.buildDir}/jspc" |
jspCClasspath | project.configurations.jspC |
webAppDir | If the Otherwise: The first |
The compileJSP
task is also configured with the following defaults:
Property Name | Default Value |
---|---|
classpath | project.configurations.jspCTool + project.configurations.jspC |
destinationDir | compileJSP.temporaryDir |
source | generateJSPJava.outputs |
CompileJSPTask
Tasks of type CompileJSPTask
extend JavaExec
,
so all its properties and methods, such as args
and maxHeapSize
,
are available. They also have the following properties set by default:
Property Name | Default Value |
---|---|
main | "com.liferay.jasper.jspc.JspC" |
Task Properties
The properties of type File
support any type that can be resolved by
project.file
.
Additional Configuration
There are additional configurations that can help you use Jasper JSPC.
JSP Compilation Classpath
The plugin creates a configuration called jspC
and adds several dependencies
at the end of the configuration phase of the project:
- the JAR file of the project generated by the
jar
task. - the output files of the
main
source set. - the
compileClasspath
file collection of themain
source set.
If necessary, it is possible to add more dependencies to the jspC
configuration.
Liferay Jasper JSPC Dependency
By default, the plugin creates a configuration called jspCTool
and adds a
dependency to the latest released version of the Liferay Jasper JSPC. It is
possible to override this setting and use a specific version of the tool by
manually adding a dependency to the jspCTool
configuration:
dependencies {
jspCTool group: "com.liferay", name: "com.liferay.jasper.jspc", version: "1.0.11"
jspCTool group: "org.apache.ant", name: "ant", version: "1.9.4"
}