2014-06-12 13:01:16 -04:00
|
|
|
buildscript {
|
2015-03-23 12:14:26 -04:00
|
|
|
repositories {
|
|
|
|
maven { url "https://repo.spring.io/plugins-release" }
|
|
|
|
}
|
|
|
|
dependencies {
|
2016-03-14 21:20:25 -04:00
|
|
|
classpath("com.bmuschko:gradle-tomcat-plugin:2.2.4")
|
2015-03-23 12:14:26 -04:00
|
|
|
}
|
2014-06-12 13:01:16 -04:00
|
|
|
}
|
|
|
|
|
2016-03-14 21:20:25 -04:00
|
|
|
apply plugin: 'com.bmuschko.tomcat'
|
2013-08-05 17:22:33 -04:00
|
|
|
|
|
|
|
dependencies {
|
2015-03-23 12:14:26 -04:00
|
|
|
def tomcatVersion = '7.0.54'
|
|
|
|
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
|
2016-03-14 21:20:25 -04:00
|
|
|
"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}"
|
2014-06-12 13:01:16 -04:00
|
|
|
}
|
|
|
|
|
2016-03-14 21:20:25 -04:00
|
|
|
task integrationTomcatRun(type: com.bmuschko.gradle.tomcat.tasks.TomcatRun) {
|
2015-03-23 12:14:26 -04:00
|
|
|
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
|
|
|
|
}
|
2016-03-14 21:20:25 -04:00
|
|
|
contextPath = tomcatRun.contextPath
|
2015-03-23 12:14:26 -04:00
|
|
|
// delay reserving ports to ensure they are still available
|
|
|
|
def ports = reservePorts(3)
|
|
|
|
httpPort = ports[0]
|
|
|
|
ajpPort = ports[1]
|
|
|
|
stopPort = ports[2]
|
|
|
|
}
|
2014-06-12 13:01:16 -04:00
|
|
|
}
|
|
|
|
|
2016-03-14 21:20:25 -04:00
|
|
|
task integrationTomcatStop(type: com.bmuschko.gradle.tomcat.tasks.TomcatStop) {
|
2015-03-23 12:14:26 -04:00
|
|
|
onlyIf { !sourceSets.integrationTest.allSource.empty }
|
|
|
|
doFirst {
|
|
|
|
stopPort = integrationTomcatRun.stopPort
|
|
|
|
}
|
2014-06-12 13:01:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
integrationTest {
|
2015-03-23 12:14:26 -04:00
|
|
|
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
|
2014-06-12 13:01:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
def reservePorts(int count) {
|
2015-03-23 12:14:26 -04:00
|
|
|
def sockets = []
|
|
|
|
for(int i in 1..count) {
|
|
|
|
sockets << new ServerSocket(0)
|
|
|
|
}
|
|
|
|
def result = sockets*.localPort
|
|
|
|
sockets*.close()
|
|
|
|
result
|
2013-08-05 17:22:33 -04:00
|
|
|
}
|