allprojects {
    repositories {
        mavenCentral()                     // main maven repo
        jcenter()                          // some other stuff
        maven { url 'https://dl.bintray.com/palantir/releases' }
        mavenLocal()                       // useful for developing
        maven { url "https://jitpack.io" } // build projects directly from github
        maven { url "https://dl.bintray.com/sedmelluq/com.sedmelluq" } // Lavaplayer rotator extension
    }

    apply plugin: 'idea'
    group = 'com.fredboat'
}
subprojects {
    buildscript {
        ext {
            //@formatter:off

            //plugin versions
            gradleGitVersion        = '2.1.0'
            shadowVersion           = '2.0.3'
            springBootVersion       = '2.0.1.RELEASE'
            propDepsVersion         = '0.0.9.RELEASE'
            kotlinVersion           = '1.3.71'

            //@formatter:on
        }
        repositories {
            maven { url "https://plugins.gradle.org/m2/" }
            maven { url "https://repo.spring.io/plugins-release" }
            mavenCentral()
        }
        dependencies {
            classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:${gradleGitVersion}"
            classpath "com.github.jengelman.gradle.plugins:shadow:${shadowVersion}"
            classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
            classpath "io.spring.gradle:propdeps-plugin:${propDepsVersion}"
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
            classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
        }
    }
    apply plugin: 'java'

    sourceCompatibility = 11
    targetCompatibility = 11

    compileJava.options.encoding = 'UTF-8'
    compileJava.options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"

    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
    }

    test {
        useJUnitPlatform()
    }

    ext {
        //@formatter:off

        sentinelVersion             = 'd8680e86'
        springBootVersion           = "${springBootVersion}"
        kotlinVersion               = "${kotlinVersion}"

        //audio deps
        lavaplayerVersion           = '1.3.50'
        lavaplayerIpRotatorVersion  = '0.1.7'
        lavalinkVersion             = '2a2ca203'

        //utility deps
        jsonOrgVersion              = '20180130'
        commonsTextVersion          = '1.3'
        commonsIOVersion            = '2.6'
        commonsCodecVersion         = '1.11'
        commonsCollectionsVersion   = '4.1'
        snakeYamlVersion            = '1.19' //do not upgrade to 1.20, app wont start up
        fastUtilVersion             = '8.1.1'
        togglzVersion               = '2.6.0.Final'
        guavaVersion                = '24.1-jre'
        bucket4jVersion             = '3.1.1'
        gsonVersion                 = '2.8.2'
        amqpVersion                 = "2.0.4.RELEASE"
        jacksonKotlinVersion        = "2.9.+"

        //logging / monitoring deps
        logbackVersion              = '1.2.3'
        sentryVersion               = '1.7.2'
        prometheusClientVersion     = '0.3.0'

        //http / web deps
        okhttpVersion               = '3.10.0'

        //QA deps
        spotbugsVersion             = '3.1.2'
        napsterAnnotations          = '0.0.1'

        //testing deps
        junitVersion                = '5.1.0'
        apiGuardianVersion          = '1.0.0'
        dockerComposeRuleVersion    = '0.33.0'
        postgresJdbcVersion         = '42.2.2'
        rerunnerVersion             = '1.1.0'


        //@formatter:on
    }
}

version = '4.0'
ext {
    moduleName = 'FredBoat-Root'
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.10.2'
    //noinspection UnnecessaryQualifiedReference
    distributionType = Wrapper.DistributionType.ALL
}

//create a simple version file that we will be reading to create appropriate docker tags
void versionTxt() {
    new File("$projectDir/VERSION.txt").text = "$rootProject.version\n"
}

versionTxt()
