如何使用 groovy/gradle 运行带有指定战争的 jetty 7+? [英] How to run jetty 7+ with specified war with groovy/gradle?
问题描述
我想使用 gradle build 运行 Jetty 7+,但不幸的是,jettyRun 似乎无法做到这一点.因此,实现我想要的最简单的想法可能是使用自定义目标:
I want to run Jetty 7+ with gradle build, but unlucky looks like there is no way to do this with jettyRun. So probably simplest idea to achieve what I want would be to use custom target:
task runJetty << {
def server = new Server()
// more code here
server.start()
server.join()
}
不幸的是我刚开始使用 gradle,我也不知道 groovy,所以我很难创建合适的目标.我正在浏览互联网,但找不到任何解决方案.任何人都可以用一些可以使用 jetty 运行现有 jar 的示例 groovy 代码来打我吗?
Unlucky I just started with gradle and I don't know groovy either, so it's hard for me to create proper target. I was looking over the internet but I wasn't able to find any solution. Can anyone hit me with some sample groovy code which can run existing jar with jetty?
推荐答案
好的,我找到了如何直接从存储库使用 jetty 运行它:
Ok, I found out how to run it using jetty directly from repository:
jettyVersion = "8.1.0.RC0"
configurations {
jetty8
}
dependencies {
jetty8 "org.mortbay.jetty:jetty-runner:$jettyVersion"
}
task runJetty8(type: JavaExec) {
main = "org.mortbay.jetty.runner.Runner"
args = [war.archivePath]
classpath configurations.jetty8
}
这篇关于如何使用 groovy/gradle 运行带有指定战争的 jetty 7+?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!