I'm trying to use the war overlay feature of maven-war-plugin to include some
common JSPs (e.g. common header and footer files) in multiple projects, but
I also want to use jspc-maven-plugin to precompile the project JSPs.

The issue I'm facing is that jspc-maven-plugin needs to run after the war
overlay is done, so that the common JSPs are available during the
precompile, but before the packaging is done, so the generated classes and
web.xml get included in the final war.

Without using war overlays, the build section of my project pom looks like
this in order to do the precompile:

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jspc-maven-plugin</artifactId>
        <version>1.4.6</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <webXml>${basedir}/target/jspweb.xml</webXml>
        </configuration>
      </plugin>
    </plugins>
  </build>

The <webXml> configuration for maven-war-plugin causes the war plugin to use
the web.xml file generated by the jspc plugin -- jspc rewrites the web.xml
to add servlet mappings for the precompiled JSP classes.

This works well when all the JSPs are present in the project -- the
generated war contains the precompiled JSP classes plus the rewritten
web.xml.

In order to get the precompile to work with JSPs from an overlaid war, I
tried declaring an execution of the war plugin's "exploded" goal during the
process-resources phase so that it builds a directory tree containing the
overlays for the war:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>exploded</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

I added some configuration to the jspc plugin to get it to compile the JSPs
from the exploded tree instead of from src/main/webapps:

        <configuration>
          <warSourceDirectory>
            ${basedir}/target/${artifactId}-${version}
          </warSourceDirectory>
        </configuration>

Here's the complete build section of my project pom after adding those
changes:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>exploded</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jspc-maven-plugin</artifactId>
        <version>1.4.6</version>

        <configuration>
          <warSourceDirectory>
            ${basedir}/target/${artifactId}-${version}
          </warSourceDirectory>
        </configuration>

        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <webXml>${basedir}/target/jspweb.xml</webXml>
        </configuration>
      </plugin>
    </plugins>
  </build>


This works great, almost: the overlaid war directory gets created, jspc
precompiles its JSPs, and the war plugin creates the final war containing
all the precompiled JSP classes in its WEB-INF/classes directory.

The only problem is that the war contains the original web.xml from
src/main/webapps/WEB-INF instead of the rewritten version created by jspc,
even though the configuration to use the rewritten one still exists in the
second maven-war-plugin declaration.

Any ideas why this is happening or how to get around it?

George

-- 
View this message in context: 
http://www.nabble.com/jsp-precompile-with-war-overlay-tf3187860s177.html#a8848176
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to