即时尝试将我们的构建过程从Maven更改为Gradle(V 2.9)。在Maven中,我使用了如下的JSP预编译:使用Gradle预编译JSP
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
<version>9.2.7.v20150116</version>
<executions>
<execution>
<phase>package</phase>
<id>jspc</id>
<goals>
<goal>jspc</goal>
</goals>
<configuration>
<excludes>**\/*inc_page_bottom.jsp,**\/*inc_page_top.jsp</excludes>
<includes>**\/*.jsp</includes>
</configuration>
</execution>
</executions>
</plugin>
它工作正常。 现在我试图找到一种方法来做到与gradle相同。 我找到了一些信息/ build.gradle的例子,但没有任何工作真的。我目前正在使用Tomcat 7作为servlet容器,并计划在几周内切换到8.当然,将它们编译为目标servlet容器是完美的,但首先我会很乐意预编译它们,就像我在做这件事一样与码头的/与码头。
我目前的build.gradle的一部分,给了我一个错误:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.4'
}
}
apply plugin: 'com.bmuschko.tomcat'
tomcat {
jasper {
validateXml = true
errorOnUseBeanInvalidClassAttribute = false
compilerSourceVM = "1.8"
compilerTargetVM = "1.8"
}
}
task compileJsps(type: JavaCompile, dependsOn: 'clean') {
dependsOn tomcatJasper
group = 'build'
description = 'Translates and compiles JSPs'
classpath = configurations.tomcat + sourceSets.main.output + sourceSets.main.runtimeClasspath
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
destinationDir = file("$buildDir/jasper-classes")
sourceSets {
main {
java {
srcDir "$buildDir/jasper"
}
}
}
}
dependencies {
def tomcatVersion = '7.0.59'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"
}
即时得到以下错误:
:tomcatJasper FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':tomcatJasper'.
> org.apache.jasper.JasperException: file:/xxx/xxx/xxx/xxx/src/main/webapp/index.jsp (line: 6, column: 0) The value for the useBean class attribute xxx.xxx.xxx.XxxXxx is invalid.
运行该JSP的Tomcat中7工作正常... 有人有最新的howto或暗示吗?
有没有得到一个答案呢?我在maven中发现了一个<%@ include file =“directives.jsp”%>在服务器上工作但在预编译上下文中不起作用的问题 –
不幸的是,没有(并且没有找到任何解决方案......) – StephanM
我们放弃了对jetty的jdt-core的提升,以获得与jre 18u112兼容的jasper编译器 –