/*
 * R3 Proprietary and Confidential
 *
 * Copyright (c) 2018 R3 Limited.  All rights reserved.
 *
 * The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
 *
 * Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
 */

buildscript {
    Properties constants = new Properties()
    file("../constants.properties").withInputStream { constants.load(it) }

    ext {
        guava_version = constants.getProperty("guavaVersion")
        kotlin_version = constants.getProperty("kotlinVersion")
        proguard_version = constants.getProperty("proguardVersion")
        assertj_version = '3.9.1'
        junit_version = '4.12'
        asm_version = '6.2'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "net.sf.proguard:proguard-gradle:$proguard_version"
    }
}

apply plugin: 'maven'
apply plugin: 'java'

repositories {
    mavenLocal()
    mavenCentral()
}

allprojects {
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            languageVersion = "1.2"
            apiVersion = "1.2"
            jvmTarget = "1.8"
            javaParameters = true   // Useful for reflection.
        }
    }

    tasks.withType(Test) {
        // Prevent the project from creating temporary files outside of the build directory.
        systemProperty 'java.io.tmpdir', buildDir.absolutePath

        // Tell the tests where Gradle's current module cache is.
        // We need the tests to share this module cache to prevent the
        // Gradle Test-Kit from downloading its own copy of Kotlin etc.
        systemProperty 'test.gradle.user.home', project.gradle.gradleUserHomeDir
    }
}

dependencies {
    // Add the top-level projects ONLY to the host project.
    runtime project.childProjects.values().collect {
        project(it.path)
    }
}

// Don't create an empty jar. The plugins are now in child projects.
jar.enabled = false