Maven JspC Plugin
The Maven JspC Plugin provides a single goal jspc which is by default executed in the compile phase of the Maven build process. This goal takes all JSP source files from a configured location (src/main/scripts by default) and compiles them into classes in a configurable location (target/jspc-plugin-generated by default). In addition, for each compiled JSP a Declarative Services descriptor is generated and written to a descriptor file (OSGI-INF/jspServiceComponents.xml in the output location). This descriptor will then be read by the Service Component Runtime of the deployment OSGi framework to register all contained JSP as javax.servlet.Servlet services.
Use
To use the Maven JspC Plugin define the following elements in the <plugins> section of the POM:
<?xml version="1.0" encoding="ISO-8859-1"?> <project> .... <build> .... <plugins> .... <plugin> <groupId>org.apache.sling</groupId> <artifactId>maven-jspc-plugin</artifactId> <executions> <execution> <id>compile-jsp</id> <goals> <goal>jspc</goal> </goals> </execution> </executions> </plugin> .... <plugins> .... <build> .... <project>
Configuration
The Maven JspC Plugin may be configured in the <configuration> element using the following properties:
Parameter | Default Value | Description |
---|---|---|
sourceDirectory | ${project.build.scriptSourceDirectory} | Location of the JSP source file; may be overwritten using the jspc.sourceDirectory system property. |
outputDirectory | ${project.build.directory}/jspc-plugin-generated | Target directory for the compiled JSP classes; may be overwritten using the jspc.outputDirectory system propertiy. |
compilerTargetVM | 1.5 | The Target Virtual Machine Version to generate class files for; may be overwritten using the jspc.compilerTargetVM system property. |
compilerSourceVM | 1.5 | The Compiler Source Version of the Java source generated from the JSP files before compiling into classes; may be overwritten using the jspc.compilerSourceVM system property. |
servletPackage | org.apache.jsp | The root package name for the generated class files; may be overwritten using the jspc.servletPackage system property. |
Notes
The generated JSP classes as well as the Declarative Services descriptor are automatically copied to the generated bundle jar file if the Maven Bundle Plugin (from the Apache Felix) project is used to build the project package.