[英]Is there any easy way to run jetty 8 from gradle (like with jettyRun)?
Unlucky I need jetty 8 to work properly with spray/akka (it's scala project). 不幸的是,我需要码头8才能与spray / akka一起正常工作(这是scala项目)。
With older version used by jettyRun I'm getting error like: 使用jettyRun使用的旧版本时,出现如下错误:
java.lang.NoClassDefFoundError: org/eclipse/jetty/continuation/ContinuationListener java.lang.NoClassDefFoundError:org / eclipse / jetty / continuation / ContinuationListener
Is it possible to create some simple task to do the job which jettyRun is doing but with jetty 8? 是否可以创建一些简单的任务来完成jettyRun所做的工作,但要使用jetty 8?
In worst case I can use embedded version of jetty with war which I'm building, but I would be happy to see some simpler solution if there is any... 在最坏的情况下,我可以在正在建造的战争中使用嵌入式版本的码头,但如果有的话,我很高兴看到一些更简单的解决方案...
Pitor, why didn't you end up adding your excellent answer from here ? 先生,您为什么不从这里开始添加出色的答案呢?
I've adapted it below, to use Jetty version 9
, to depend on the war
task, and to use the same task name as the jetty plugin (ie jettyRun
). 我在下面对其进行了修改,以使用Jetty版本9
来依赖war
任务,并使用与jetty插件相同的任务名称(即jettyRun
)。
configurations {
jetty
}
dependencies {
jetty "org.eclipse.jetty:jetty-runner:9.2.11.v20150529"
}
task jettyRun(type: JavaExec, dependsOn: war) {
main = "org.eclipse.jetty.runner.Runner"
args = [war.archivePath]
classpath configurations.jetty
}
gradle jettyRun
I think it's a little late for an answer :) But I'll post it for others who would google around for the same thing. 我认为答案来晚了:)但是,我会将其发布给其他会搜索同一内容的人。
I stumbled upon the same issue while trying to run a scalatra app with gradle. 在尝试使用gradle运行scalatra应用程序时,我偶然发现了同一问题。 I found this plugin and it just works - https://github.com/martins1930/jettyMulti 我找到了这个插件,它可以正常工作-https://github.com/martins1930/jettyMulti
Since I wasn't able to find good solution at the gradle build level I decided to use embedded jetty. 由于无法在gradle构建级别上找到好的解决方案,因此决定使用嵌入式码头。 Here is scala class: 这是scala类:
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
import org.eclipse.jetty.server.bio.SocketConnector
object JettyServer {
def main(args: Array[String]) {
val server = new Server
val context = new WebAppContext
val connector = new SocketConnector
connector.setMaxIdleTime(1000 * 60 * 60)
connector.setPort(8080)
context.setServer(server)
context.setWar(args(0))
server.setConnectors(Array(connector))
server.setHandler(context)
try {
server.start();
server.join();
} catch {
case e: Exception => e.printStackTrace();
}
}
}
And then in build.gradle: 然后在build.gradle中:
apply plugin: "application"
mainClassName = "com.mycompany.myproject"
run.args = [war.archivePath]
task jettyRun(dependsOn: run)
And everything works :) 一切正常:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.