Jasper JSPC Gradle Plugin

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:

NameDepends OnTypeDescription
compileJSPgenerateJSPJavaJavaCompileCompiles JSP files to check for errors.
generateJSPJavajarCompileJSPTaskCompiles 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 NameDefault Value
classpathproject.configurations.jspCTool
destinationDir"${project.buildDir}/jspc"
jspCClasspathproject.configurations.jspC
webAppDir

If the war plugin is applied: project.webAppDir.

Otherwise: The first resources directory of the main source set (by default, src/main/resources).

The compileJSP task is also configured with the following defaults:

Property NameDefault Value
classpathproject.configurations.jspCTool + project.configurations.jspC
destinationDircompileJSP.temporaryDir
sourcegenerateJSPJava.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 NameDefault Value
main"com.liferay.jasper.jspc.JspC"

Task Properties

Property NameTypeDefault ValueDescription
destinationDirFilenullThe directory where the the JSP files are compiled to. Package directories are automatically generated based on the directories containing the uncompiled JSP files. It sets the -d argument.
jspCClasspathFileCollectionnullThe classpath to use for the JSP files compilation.
webAppDirFilenullThe directory containing the web application. All JSP files in the directory and its subdirectories are compiled. It sets the -webapp argument.

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 the main 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"
}
« Gulp Gradle PluginJavadoc Formatter Gradle Plugin »
Was this article helpful?
0 out of 0 found this helpful