Search code examples
mavenjsptomcat8

How to compile JSPs via Maven, but without failing on errors?


I've just started working on a large project that has many JSPs, many of which were created long ago, and some of which were generated. I would like to use the jetty-jspc-maven-plugin from org.eclipse.jetty to compile our JSPs for use in Tomcat 8.5. Unfortunately, some of the JSPs do not compile cleanly, and when there is a compilation problem, the maven build fails and stops.

The JspcMojo class does most of the work. It has an embedded class, JspcMojo.JettyJspC that extends org.apache.jasper.JspC and has a failOnError property. The documentation for JettyJspC says, "JettyJspC Add some extra setters to standard JspC class to help configure it for running in maven." So, it seems like I ought to be able to set the failOnError property to false and be done. I have tried all of the following, without success. How can I pass the failOnError property from maven to the JSP compiler?

<jspc.failOnError>false</jspc.failOnError>
<org.apache.jasper.compiler.failOnError>false</org.apache.jasper.compiler.failOnError>
<org.apache.jasper.JspC.failOnError>false</org.apache.jasper.JspC.failOnError>
<maven.compiler.failOnError>false</maven.compiler.failOnError>
<JettyJspC.failOnError>false</JettyJspC.failOnError>
<JspcMojo.JettyJspC.failOnError>false</JspcMojo.JettyJspC.failOnError>
<org.eclipse.jetty.jspc.plugin.JspcMojo.JettyJspC.failOnError>false</org.eclipse.jetty.jspc.plugin.JspcMojo.JettyJspC.failOnError>

BTW, compiling JSPs using ant is fairly well documented. I want to do the equivalent using maven.


Solution

  • Under the configuration section, you can use a subelement of the jspc element, like so:

    <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-jspc-maven-plugin</artifactId>
        <version>9.4.7.v20170914</version>
        <executions>
            <execution>
                <id>jspc</id>
                <goals>
                    <goal>jspc</goal>
                </goals>
                <configuration>
                    <webAppSourceDirectory>${basedir}/target/overlaidjsps</webAppSourceDirectory>
                    <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
                    <webXmlFragment>${basedir}/target/webfrag.xml</webXmlFragment>
                    <!-- The comma separated list of patterns for file extensions to be processed. -->
                    <includes>**/*.jsp</includes>
                    <jspc><failOnError>false</failOnError></jspc>
                </configuration>
            </execution>
        </executions>
    </plugin>