buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
    }
}

apply plugin: 'org.springframework.boot'

apply from: JAVA_GRADLE

//tasks.findByPath("artifactoryPublish")?.enabled = false

group = 'samples'
ext {
    jsonassertVersion="1.3.0"
    assertjVersion = "2.4.0"
}

ext['spring-security.version'] = springSecurityVersion

dependencies {
    compile project(':spring-session'),
            "org.springframework.boot:spring-boot-starter-redis",
            "org.springframework.boot:spring-boot-starter-web",
            "org.springframework.boot:spring-boot-starter-thymeleaf",
            "org.springframework.boot:spring-boot-starter-security",
            "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect",
            "biz.paluch.redis:lettuce:$lettuceVersion",
            "org.apache.httpcomponents:httpclient"

    testCompile "org.springframework.boot:spring-boot-starter-test",
            "org.assertj:assertj-core:$assertjVersion"
    testCompile "org.skyscreamer:jsonassert:$jsonassertVersion"
    testCompile "org.assertj:assertj-core:$assertjVersion"
    integrationTestCompile gebDependencies,
            "org.spockframework:spock-spring:$spockVersion"

}
//
integrationTest {
    doFirst {
        def port = reservePort()

        def host = 'localhost:' + port
        systemProperties['geb.build.baseUrl'] = 'http://'+host+'/'
        systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
        systemProperties['server.port'] = port
        systemProperties['management.port'] = 0

        systemProperties['spring.session.redis.namespace'] = project.name
    }
    jvmArgs "-XX:-UseSplitVerifier"
}

integrationTest {
    testLogging {
        events "passed", "skipped", "failed"
    }
}

def reservePort() {
    def socket = new ServerSocket(0)
    def result = socket.localPort
    socket.close()
    result
}