即時嘗試將我們的構建過程從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編譯器 –