Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Jetty Jspc Maven Plugin Usage Guide

To use the jetty jspc plugin, you need to put a <plugin> element in your pom.xml for it, and also to configure the war plugin so that it uses the web.xml file produced by the jspc plugin.

Your pom.xml will look like this:

Code Block
xml
xml
<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-jspc-plugin</artifactId>
  <version>6.1-SNAPSHOT</version>
  <executions>
    <execution>
      <id>jspc</id>
      <goals>
        <goal>jspc</goal>
      </goals>
      <configuration>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webXml>${basedir}/target/web.xml</webXml>
  </configuration>
</plugin>

Note: change the <version> tag value to match your prefered jetty jspc plugin release.

Info
titleNew configuration parameters

New configuration parameters will be available from jetty-6.1.10 onwards, to allow you to control the file extensions of the jsps which are compiled. Here's an example:

Code Block
      
<configuration>
    <includes>**/*.foo, **/*.bah</includes>
    <excludes>**/*.roo, **/*.bar</excludes>
</configuration>

The above would compile all jsp files in the webapp with extensions of .foo and .bah, but ignore those with .roo and .bar extensions. This can be useful if you have chosen something other than the usual .jsp and .jspx file extensions.

For a full listing of the <configuration> items supported by this plugin, see jspc parameter reference.

Invoking the plugin will now be done by simply building your webapp to at least the package phase:

Code Block
  mvn package

However, as compiling jsps is usually done during preparation for a production release and not usually done during development, it is more convenient to put the plugin setup inside a <profile> which which can be deliberately invoked during prep for production .

For example, the following profile will only be invoked if the flag -Dprod is present on the run line:

Code Block
xml
xml
  <profiles>
    <profile>
      <id>prod</id>
      <activation>
        <property><name>prod</name></property>
      </activation>
      <build>
      <plugins>
        <plugin>
          <groupId>org.mortbay.jetty</groupId>
          <artifactId>maven-jetty-jspc-plugin</artifactId>
          <version>6.1-SNAPSHOT</version>
          . . .
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          . . .
        </plugin>
      </plugins>
      </build>
    </profile>
  </profiles>

So, the following invocation would cause your code to be compiled, the jsps to be compiled, the <servlet> and <servlet-mapping>s inserted in the web.xml and your webapp assembled into a war:

Code Block
 mvn -Dprod package
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery