我们正在使用Maven 3,我正面临一个拥有JSP文件的项目,并且还使用存储在不同项目中的"全局"JSP文件.使用时,这很好地工作Maven的战争插件和webResources.所有JSP文件都可以进入WAR文件.
新想法是预编译所有JSP.显而易见的选择是使用jspc-maven-plugin.但是,在编译项目本地JSP时,它不包括外部JSP.
以下是来自以下内容的片段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>
Run Code Online (Sandbox Code Playgroud)
错误是
[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]
Run Code Online (Sandbox Code Playgroud)
该jspGlobal-directory将被复制与<directory>../name.of.external.project/src/global/webapp</directory>上述直插式.
在JspC中包含外部JSP的缺失是什么?
编辑:感谢prunge和Raghuram的输入,我更深入地了解了源代码和JavaDocs.我注意到上面提到的sources需要一个FileSet不允许列表的目录.而且因为sources它也不是一个列表,我认为我不可能指定多个JSP源目录.我甚至试图复制 - <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>
Run Code Online (Sandbox Code Playgroud)
现在,外部JSP被编译到当前项目的目标路径中.现在我需要一种方法来编译当前项目的JSP.我该怎么做呢?
顺便说一句,如果我切换<sources>到当前项目的行,我会得到与前面提到的相同的错误.
| 归档时间: |
|
| 查看次数: |
7269 次 |
| 最近记录: |