我需要从gradle任务启动WireMock服务器。在java中我会做这样的事情:
WireMockServer wireMockServer = new WireMockServer(wireMockConfig().port(8089));
如何使用gradle任务创建此wireMock服务器?
答案 0 :(得分:1)
可以完全相同的方式完成。在这里你有一个工作的例子:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.tomakehurst:wiremock:1.52'
}
}
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig
import com.github.tomakehurst.wiremock.*
apply plugin: 'java'
task someTask {
doLast {
WireMockServer wireMockServer = new WireMockServer(wireMockConfig().port(8089))
println wireMockServer
}
}
如果要在build.gradle
本身使用外部库,则应将其作为依赖项添加到buildscript
块。