buildscript {
    ext {
        springBootVersion = '1.5.2.RELEASE'
    }
    repositories {
        maven {
           url "https://plugins.gradle.org/m2/"
        }
        mavenCentral()
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
        classpath 'com.fkorotkov:gradle-libraries-plugin:0.1'
        classpath "gradle.plugin.se.patrikerdes:gradle-use-latest-versions-plugin:0.2.3"
        classpath 'org.apache.openjpa:openjpa:3.1.1'
        classpath 'com.gradle.publish:plugin-publish-plugin:0.13.0'
    }
}

configurations {
    integration
    integrationCompile.extendsFrom testCompile
    integrationRuntime.extendsFrom testRuntime
}

apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: "com.github.ben-manes.versions"
apply plugin: 'com.fkorotkov.libraries'
apply plugin: 'se.patrikerdes.use-latest-versions'

jar {
    baseName = 'base'
    version = '0.0.1-SNAPSHOT'
}

sourceCompatibility = 1.8

sourceSets {
    integration {
        compileClasspath += main.output + test.output
        runtimeClasspath += main.output + test.output

        groovy.srcDir file('src/test/integration/groovy')
    }
}

idea {
    module {
        scopes.TEST.plus = [configurations.integration]
    }
}
repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-jersey') {
        exclude module: "spring-boot-starter-tomcat"
    }

    compile("org.springframework.boot:spring-boot-starter-jetty")

    //compile('org.codehaus.groovy:groovy:2.4.9')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    compile("org.grails:gorm-hibernate5-spring-boot:6.0.9.RELEASE")
    runtime('mysql:mysql-connector-java:6.0.5')

    testCompile 'org.spockframework:spock-spring:1.0-groovy-2.4'
    // optional dependencies for using Spock
    testCompile "org.hamcrest:hamcrest-core:1.3" // only necessary if Hamcrest matchers are used
    testRuntime "cglib:cglib-nodep:3.1" // allows mocking of classes (in addition to interfaces)

    dependency 'org.apache.openjpa:openjpa:3.1.1'
}

task integration(type: Test) {
    testClassesDir = sourceSets.integration.output.classesDir
    classpath = sourceSets.integration.runtimeClasspath

    // This is not needed, but I like to see which tests have run
    testLogging {
        events "passed", "skipped", "failed"
    }
}
