How to run jetty 7+ with specified war with groovy/gradle?

后端 未结 4 787
清酒与你
清酒与你 2020-12-17 21:17

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 c

4条回答
  •  感动是毒
    2020-12-17 21:45

    Here's a working version, using the jetty ant tasks. This finally enabled me the proper control with deamon=true.

    configurations { jetty }
    dependencies { jetty 'org.eclipse.jetty:jetty-ant:9.0.4.v20130625' }
    task jetty(dependsOn: build) << {
        ant.taskdef(name: 'jettyRun', classname: 'org.eclipse.jetty.ant.JettyRunTask', classpath: configurations.jetty.asPath, loaderref: "jetty.loader")
        ant.typedef(name: "connector", classname: "org.eclipse.jetty.ant.types.Connector", classpath: configurations.jetty.asPath, loaderref: "jetty.loader")
        ant.jettyRun(daemon:true, stopPort: 8999, stopKey: "STOP") {
            webApp(war: THE_WAR_PRODUCING_TASK.archivePath, contextPath: '/context')
            connectors { connector(port: 9000) }
            systemProperties {
                systemProperty(name: 'environment.type', value: 'development')
            }
        }
    }
    task jettyStop << {
        ant.taskdef(name: 'jettyStop', classname: 'org.eclipse.jetty.ant.JettyStopTask', classpath: configurations.jetty.asPath)
        ant.jettyStop(stopPort: 8999, stopKey: "STOP")
    }
    

提交回复
热议问题