Maven: JspC should use external JSP files

We use Maven 3, and I come across a project that has JSP files, and also uses "global" JSP files stored in another project. This works well when using maven-war-plugin and webResources. All JSP files fall into the WAR file.

A new idea is to precompile all JSPs. The obvious choice is to use jspc-maven-plugin . However, this does not include external JSPs when compiling local JSP projects.

Here's a snippet from pom.xml:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jspc-maven-plugin</artifactId>
    <executions>
      <execution>
        <id>jspc</id>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1</version>
    <configuration>
      <warName>${pom.groupId}.${pom.artifactId}-0.0.1-SNAPSHOT</warName>
      <webXml>${basedir}/target/jspweb.xml</webXml>
      <webResources>
        <resource>
          <directory>../name.of.external.project/src/global/webapp</directory>
        </resource>
      </webResources>
    </configuration>
  </plugin>

Error

[ERROR] Failed to execute goal org.codehaus.mojo:jspc-maven-plugin:1.4.6:compile (jspc) on project internal.project: JSPC Error: file:C:/workspace/name.of.internal.project/src/main/webapp/WEB-INF/views/show.jsp(2,0) File "/WEB-INF/views/../jspGlobal/jsp-declaration.jspf" not found -> [Help 1]

jspGlobalThe directory will be copied using the line <directory>../name.of.external.project/src/global/webapp</directory>above.

What is missing to enable external JSPs in JspC?


EDIT: prunge's Raghuram JavaDocs. , sources FileSet, . sources , , JSP-source. <plugin>, . :

  <plugin>
    <groupId>org.codehaus.mojo.jspc</groupId>
    <artifactId>jspc-maven-plugin</artifactId>
    <version>2.0-alpha-3</version>
    <executions>
      <execution>
        <id>jspc</id>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <sources>
        <directory>${basedir}/../name.of.external.project/src/global/webapp</directory>
      </sources>
<!-- the later mentioned <sources> gets picked
      <sources>
        <directory>${basedir}/src/main/webapp</directory>
      </sources>
-->
      <!-- 1.6 doesn't work!? Something lower than 1.5 seems to be the default -->
      <source>1.5</source>
      <target>1.5</target>
    </configuration>
    <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>
    <version>2.1</version>
    <configuration>
      <warName>${pom.groupId}.${pom.artifactId}-0.0.1-SNAPSHOT</warName>
      <webXml>${basedir}/target/jspweb.xml</webXml>
      <webResources>
        <resource>
          <directory>../name.of.external.project/src/global/webapp</directory>
        </resource>
      </webResources>
    </configuration>
  </plugin>

JSP . JSP . ?

BTW, <sources> , , .

+5
2

, jspc-maven-plugin, 2.0-alpha-3. , usage .

+1

CompilationMojoSupport, sources FileSet. , . , ${project.basedir}/src/main/webapp WAR.

+1

All Articles