plugins {
    id 'java' // or 'groovy' Must be explicitly applied
    id 'com.github.johnrengelman.shadow' version '1.2.3'
    id 'application'
}

mainClassName = "com.gcplot.bootstrap.Bootstrap"

jar {
    manifest {
        attributes("Implementation-Title": "GCPlot",
                "Implementation-Version": "$gcplotVersion",
                "Main-Class": "com.gcplot.bootstrap.Bootstrap")
    }
}

shadowJar {
    zip64 = true
    mergeServiceFiles()
}

sourceSets {
    integrationTest {
        java {
            compileClasspath += main.output + test.output
            runtimeClasspath += main.output + test.output
            srcDir file('src/integration-test/java')
        }
        resources.srcDirs(file('src/integration-test/resources'), file('../com.gcplot.gc-model/src/main/resources'))
    }
}

sourceSets.main.resources.srcDir "../com.gcplot.gc-model/src/main/resources";

configurations {
    integrationTestCompile.extendsFrom testCompile
    integrationTestRuntime.extendsFrom testRuntime
}

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

integrationTest {
    minHeapSize = "512m"
    maxParallelForks = 1
    forkEvery = 1

    testLogging {
        showExceptions = true
        showCauses = true
        showStackTraces = true
        events "passed", "skipped", "failed", "standardOut", "standardError"
    }
}

dependencies {
    compile project(":com.gcplot.model")
    compile project(":com.gcplot.api")
    compile project(":com.gcplot.commons")
    compile project(":com.gcplot.services")
    compile project(":com.gcplot.gc-model")
    compile project(":com.gcplot.log-processor")

    compile "com.amazonaws:aws-java-sdk-s3:$awsVersion"
    compile("io.vertx:vertx-web:$vertxVersion") {
        exclude group: 'io.netty'
    }
    compile "io.vertx:vertx-codegen:$vertxVersion"
    compile "org.springframework:spring-context:$springVersion"
    compile "org.springframework:spring-beans:$springVersion"
    compile "io.dropwizard.metrics:metrics-core:$metricsVersion"
    compile "io.dropwizard.metrics:metrics-graphite:$metricsVersion"
    compile "com.beust:jcommander:$jcommanderVersion"
    compile "commons-codec:commons-codec:$apacheCodecVersion"
    compile "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"

    testCompile "org.springframework:spring-test:$springVersion"
    integrationTestCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: "$httpClientVersion"
    integrationTestCompile group: 'org.apache.httpcomponents', name: 'httpmime', version: "$httpClientVersion"
    integrationTestCompile group: 'org.apache.zookeeper', name: 'zookeeper', version: "$zookeeperVersion"
    integrationTestCompile 'com.github.kirviq:dumbster:1.7'
}

check.dependsOn integrationTest
integrationTest.mustRunAfter test

tasks.withType(Test) {
    reports.html.destination = file("${reporting.baseDir}/${name}")
}

