今日のひとこと Challange IT For Future

JSPのプリコンパイルのMavenプラグイン

Java 読了 3分

この記事は最終更新から 17 年以上たっています。内容が現在の状況と異なる可能性があります。現在の情報は最新の記事、Fess の記事をご覧ください。

jspc-maven-plugin を使うと、pom.xml に追記するだけで、JSPをプリコンパイルしてくれて、war に含まれるようになる。これは便利だ。ただし、2.0-alpha-3 だと、web.xml をシステムエンコーディングで扱うので、web.xml に日本語があると、うまくいかない場合があると思う(Windowsとかだと)。それは対応しようかな。

<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<!-- Use the Tomcat 6 JSP compiler -->
<dependencies>
<dependency>
<groupId>org.codehaus.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat6</artifactId>
<version>2.0-alpha-3</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${pom.basedir}/target/jspweb.xml</webXml>
</configuration>
</plugin>

追記: http://jira.codehaus.org/browse/MJSPC-44 にバグとパッチを上げておいた。groovy で記述された Mojo は意外だった。