65 lines
1.8 KiB
Groovy
65 lines
1.8 KiB
Groovy
buildscript {
|
|
repositories {
|
|
maven { url "https://repo.spring.io/plugins-release" }
|
|
}
|
|
dependencies {
|
|
classpath("com.bmuschko:gradle-tomcat-plugin:2.2.4")
|
|
}
|
|
}
|
|
|
|
apply plugin: 'com.bmuschko.tomcat'
|
|
|
|
dependencies {
|
|
def tomcatVersion = '7.0.54'
|
|
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
|
|
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
|
|
"org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}",
|
|
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"
|
|
}
|
|
|
|
task integrationTomcatRun(type: com.bmuschko.gradle.tomcat.tasks.TomcatRun) {
|
|
onlyIf { !sourceSets.integrationTest.allSource.empty }
|
|
daemon = true
|
|
tomcatClasspath = tomcatRun.tomcatClasspath
|
|
webAppClasspath = tomcatRun.webAppClasspath
|
|
webAppSourceDirectory = tomcatRun.webAppSourceDirectory
|
|
doFirst {
|
|
def mainOutputDir = project.sourceSets.main.output.classesDir
|
|
if(mainOutputDir) {
|
|
classesDirectory = mainOutputDir
|
|
}
|
|
contextPath = tomcatRun.contextPath
|
|
// delay reserving ports to ensure they are still available
|
|
def ports = reservePorts(3)
|
|
httpPort = ports[0]
|
|
ajpPort = ports[1]
|
|
stopPort = ports[2]
|
|
}
|
|
}
|
|
|
|
task integrationTomcatStop(type: com.bmuschko.gradle.tomcat.tasks.TomcatStop) {
|
|
onlyIf { !sourceSets.integrationTest.allSource.empty }
|
|
doFirst {
|
|
stopPort = integrationTomcatRun.stopPort
|
|
}
|
|
}
|
|
|
|
integrationTest {
|
|
dependsOn integrationTomcatRun
|
|
doFirst {
|
|
def host = 'localhost:' + integrationTomcatRun.httpPort
|
|
systemProperties['geb.build.baseUrl'] = 'http://'+host+'/' + integrationTomcatRun.contextPath + '/'
|
|
systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
|
|
}
|
|
finalizedBy integrationTomcatStop
|
|
}
|
|
|
|
def reservePorts(int count) {
|
|
def sockets = []
|
|
for(int i in 1..count) {
|
|
sockets << new ServerSocket(0)
|
|
}
|
|
def result = sockets*.localPort
|
|
sockets*.close()
|
|
result
|
|
} |