buildscript {
    ext.kotlin_version = '1.2.51'
    ext.corda_gradle_plugins_version = '3.0.9'


    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
        maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases' }
        maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-dev' }

    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
        classpath "net.corda.plugins:publish-utils:$corda_gradle_plugins_version"
        classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
        classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"

        // for Spec - http://spekframework.org/docs/latest/
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
    }

}

plugins {
    id 'java'
    id "org.jetbrains.kotlin.jvm" version "1.2.51"
    id "application"

}

apply plugin: 'kotlin'
apply plugin: 'org.junit.platform.gradle.plugin'


group 'net.corda.workbench'
version '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    maven { url "https://jitpack.io" }
    maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases' }

}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    compile "io.javalin:javalin:1.6.1"
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.5'
    compile 'khttp:khttp:0.1.0'

    compile ("net.corda:corda-core:3.2-corda") {
        exclude group: 'org.jetbrains.kotlin'
    }

    compile group: 'commons-cli', name: 'commons-cli', version: '1.4'

    // TOOO - removing this has odd conflicts with the embedded org.json in workbench commons
    //        when building the uberjar - not sure why, but remove it and 'java -jar build/libs/corda-local-network.jar
    //        behaves very oddly - probably a transitive dep problem (too many libs
    //        pulling in different versions of org.json
    compile group: 'org.json', name: 'json', version: '20180130'


    compile "com.typesafe:config:1.3.2"

    // shared libraries is local for now
    compile files('../commons/lib/workbench-commons.jar')

    compile group: "org.http4k", name: "http4k-core", version: "3.102.1"
    compile group: "org.http4k", name: "http4k-server-jetty", version: "3.103.2"
    compile group: "org.http4k", name: "http4k-client-apache", version: "3.103.2"
    compile group: "org.http4k", name: "http4k-multipart", version: "3.103.2"

    // need an explicit dependencies for some reason once 'org.http4k' is included
    compile "com.google.guava:guava:19.0"

    // web page template engine
    compile 'com.vladsch.flexmark:flexmark-all:0.34.48'
    compile 'com.github.spullara.mustache.java:compiler:0.9.5'


    testCompile group: 'com.natpryce', name: 'hamkrest', version: '1.4.2.2'
    testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
    testCompile ('org.jetbrains.spek:spek-api:1.1.5') {
        exclude group: 'org.jetbrains.kotlin'
    }
    testRuntime ('org.jetbrains.spek:spek-junit-platform-engine:1.1.5') {
        exclude group: 'org.junit.platform'
        exclude group: 'org.jetbrains.kotlin'
    }

    testCompile 'org.spekframework.spek2:spek-dsl-common:2.0.0-rc.1'

    testCompile group: "org.http4k", name: "http4k-testing-hamkrest", version: "3.102.1"



    testCompile ('org.junit.platform:junit-platform-runner:1.0.0')
    testCompile 'khttp:khttp:0.1.0'

}

test {
    useJUnitPlatform {
        includeEngines 'spek', 'spek2'
    }
}


mainClassName = "net.corda.workbench.cordaNetwork.AppKt"


compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

jar {
    from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
        exclude "META-INF/*.SF"
        exclude "META-INF/*.DSA"
        exclude "META-INF/*.RSA"
    }
    archiveName = "corda-local-network.jar"
    manifest {
        attributes 'Main-Class': "net.corda.workbench.cordaNetwork.AppKt"
    }
}



run {
    if (project.hasProperty("appArgs")) {
        args Eval.me(appArgs)
    }
}
