首先,您可能需要一些非常基本的 gretty 设置:
buildscript {
repositories {
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:1.4.0'
}
}
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'org.akhikhl.gretty'
gretty {
servletContainer = 'jetty9'
httpEnabled = true
httpPort = 8081
contextPath = '/WebServer'
jvmArgs { '-ea' }
loggingLevel = 'ALL' // options: 'ALL', 'DEBUG', 'ERROR', 'INFO', 'OFF', 'TRACE', 'WARN'
}
一旦你有了它,你就可以在农场中设置一个webapp。在此处指定您的 war 文件的路径(提供的示例是 GWT 插件放置我的位置)。
farm {
webapp 'build/libs/web_server.war'
}
要指定依赖项:
project.afterEvaluate {
tasks.farmRun.dependsOn myCustomWarTask
}
一旦你完成了所有这些,'gradle farmRun' 将在 Gretty 中构建和运行你的 war 文件。