Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] How to compile JSPs via Maven, but without failing on errors?

Lets see ...

First lets ask the plugin what it can do ...

$ mvn <pluginGroupId>:<pluginArtifactId>:<pluginVersion>:help

Results in ...

$ mvn org.eclipse.jetty:jetty-jspc-maven-plugin:9.4.7.v20170914:help
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jetty-jspc-maven-plugin:9.4.7.v20170914:help (default-cli) @ standalone-pom ---
[INFO] Jetty :: Jetty JSPC Maven Plugin 9.4.7.v20170914
  The Eclipse Jetty Project

This plugin has 2 goals:

jetty-jspc:help
  Display help information on jetty-jspc-maven-plugin.
  Call mvn jetty-jspc:help -Ddetail=true -Dgoal=<goal-name> to display parameter
  details.

jetty-jspc:jspc
  This goal will compile jsps for a webapp so that they can be included in a
  war.
  At runtime, the plugin will use the jspc compiler to precompile jsps and tags.

  Note that the same java compiler will be used as for on-the-fly compiled jsps,
  which will be the Eclipse java compiler.

  See Usage Guide for instructions on using this plugin.


Cool, lets see what the parameters are for the jspc goal ...


$ mvn org.eclipse.jetty:jetty-jspc-maven-plugin:9.4.7.v20170914:help -Ddetail=true -Dgoal=jspc
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jetty-jspc-maven-plugin:9.4.7.v20170914:help (default-cli) @ standalone-pom ---
[INFO] Jetty :: Jetty JSPC Maven Plugin 9.4.7.v20170914
  The Eclipse Jetty Project

jetty-jspc:jspc
  This goal will compile jsps for a webapp so that they can be included in a
  war.
  At runtime, the plugin will use the jspc compiler to precompile jsps and tags.

  Note that the same java compiler will be used as for on-the-fly compiled jsps,
  which will be the Eclipse java compiler.

  See Usage Guide for instructions on using this plugin.

  Available parameters:

    classesDirectory (Default: ${project.build.outputDirectory})
      The location of the compiled classes for the webapp

    excludes
      The comma separated list of file name patters to exclude from compilation.

    generatedClasses (Default: ${project.build.outputDirectory})
      The destination directory into which to put the compiled jsps.

    includes (Default: **/*.jsp, **/*.jspx)
      The comma separated list of patterns for file extensions to be processed.
      By default will include all .jsp and .jspx files.

    insertionMarker
      Optional. A marker string in the src web.xml file which indicates where to
      merge in the generated web.xml fragment. Note that the marker string will
      NOT be preserved during the insertion. Can be left blank, in which case
      the generated fragment is inserted just before the </web-app> line

    jspc
      The JspC instance being used to compile the jsps.

    keepSources (Default: false)
      Controls whether or not .java files generated during compilation will be
      preserved.

    mergeFragment (Default: true)
      Merge the generated fragment file with the web.xml from
      webAppSourceDirectory. The merged file will go into the same directory as
      the webXmlFragment.

    scanAllDirectories (Default: true)
      Whether dirs on the classpath should be scanned as well as jars. True by
      default. This allows for scanning for tlds of dependent projects that are
      in the reactor as unassembled jars.

    sourceVersion
      Source version - if not set defaults to jsp default (currently 1.7)

    targetVersion
      Target version - if not set defaults to jsp default (currently 1.7)

    tldJarNamePatterns (Default: .*taglibs[^/]*.jar|.*jstl[^/]*.jar$)
      Patterns of jars on the system path that contain tlds. Use | to separate
      each pattern.

    useProvidedScope (Default: false)
      Whether or not to include dependencies on the plugin's classpath with
      <scope>provided</scope> Use WITH CAUTION as you may wind up with duplicate
      jars/classes.

    webAppSourceDirectory (Default: ${basedir}/src/main/webapp)
      Root directory for all html/jsp etc files

    webXml (Default: ${basedir}/src/main/webapp/WEB-INF/web.xml)
      Location of web.xml. Defaults to src/main/webapp/web.xml.

    webXmlFragment (Default: ${basedir}/target/webfrag.xml)
      File into which to generate the <servlet> and <servlet-mapping> tags for
      the compiled jsps


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.998 s
[INFO] Finished at: 2017-10-20T19:38:57Z
[INFO] Final Memory: 7M/26M
[INFO] ------------------------------------------------------------------------


That "jspc" parameter looks interesting.
Says it's the JspC object instance too.

The JspC object has a .setFailOnError(boolean) method that sounds about what you are looking for.

So that means the maven plugin style configuration should be ...

<configuration>
  <jspc>
    <failOnError>true</failOnError>
  </jspc>
</configuration>

Can you give that a go?
If that doesn't work, please file an issue at https://github.com/eclipse/jetty.project/issues/new


Joakim Erdfelt / joakim@xxxxxxxxxxx

On Fri, Oct 20, 2017 at 12:15 PM, Keith Cassell <kcassell@xxxxxxxxxxxxxxxxxxxxx> wrote:

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>

 


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top