Maven:JspC应该使用外部JSP文件
我们使用的是Maven 3,我面对的是一个包含JSP文件的项目,它还使用存储在不同项目中的“全局”JSP文件。这在使用和Maven:JspC应该使用外部JSP文件,maven,pom.xml,Maven,Pom.xml,我们使用的是Maven 3,我面对的是一个包含JSP文件的项目,它还使用存储在不同项目中的“全局”JSP文件。这在使用和webResources时非常有效。所有JSP文件都会进入WAR文件 新的想法是预编译所有JSP。显而易见的选择是使用。但是,在编译项目本地JSP时,它不包括外部JSP 下面是来自pom.xml的片段: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId
webResources
时非常有效。所有JSP文件都会进入WAR文件
新的想法是预编译所有JSP。显而易见的选择是使用。但是,在编译项目本地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>
将使用上面的./name.of.external.project/src/global/webapp
-行复制jspGlobal
-目录
在JspC中包含外部JSP缺少什么
编辑:多亏了,我更深入地研究了源代码和Javadoc。我注意到前面提到的
源代码
需要一个文件集
,它不允许目录列表。由于sources
也不是一个列表,我看不出有可能指定多个JSP源目录。我甚至试着复制
-元素,但是没有用。我目前的情况是:
<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>
org.codehaus.mojo.jspc
JSPCMaven插件
2.0-α-3
jspc
编译
${basedir}/./name.of.external.project/src/global/webapp
1.5
1.5
org.codehaus.mojo.jspc
jspc-compiler-tomcat6
2.0-α-3
org.apache.maven.plugins
maven战争插件
2.1
${pom.groupId}.${pom.artifactId}-0.0.1-SNAPSHOT
${basedir}/target/jspweb.xml
../name.of.external.project/src/global/webapp
现在,外部JSP被编译到当前项目的目标路径中。现在我需要一种方法来编译当前项目的JSP。我该怎么做
顺便说一句,如果我将
切换到当前项目的行,我会得到与前面提到的相同的错误。也许您可以尝试使用的最新版本,即2.0-alpha-3。请注意,与早期版本略有不同 查看的,我看到类型为FileSet
的sources
属性。您可以在插件的配置中对此进行配置,以添加其他源目录。默认情况下,无论WAR插件的配置如何,它都会使用${project.basedir}/src/main/webapp
。好的,我试过了。如果您的意思是只需在jspc-compiler-tomcat6
上添加依赖项,它就会产生相同的输出。@sjngm为什么要添加依赖项?你试着把它添加为插件吗?@达摩普特兰对不起,我说不出来。这是很久以前的事了。
<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>