rootProject.name = 'atrium'

buildscript {
    gradle.ext.tutteli_plugins_version = '0.32.2'
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath "ch.tutteli:tutteli-gradle-settings:$gradle.ext.tutteli_plugins_version"
    }
}

apply plugin: 'ch.tutteli.settings'

def kotlinJvm = { self, String suffix ->
    self.folder(suffix, "$suffix-") {
        prefixed('common', 'jvm')
    }
}

def bundleWithExtensionsAndSmokeTest = { self, String apiName ->
    self.kotlinJvmJs(apiName)

    if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
        self.folder(apiName) {
            _ "$apiName-smoke-test"
            folder("extensions") {
                _ "$apiName-smoke-test-kotlin_1_3"
            }
        }
    }
}

def apiWithExtensions = { self, String apiName ->
    self.kotlinJvmJs(apiName)
    self.folder(apiName, "$apiName-") {
        extensions {
            kotlinJvmJs('kotlin_1_3')
        }
    }
}

//noinspection GroovyAssignabilityCheck
include {

    bundles {
        bundleWithExtensionsAndSmokeTest(delegate, 'fluent-en_GB')
        bundleWithExtensionsAndSmokeTest(delegate, 'infix-en_GB')
    }

    apis('api-') {
        apiWithExtensions(delegate, 'fluent-en_GB')
        apiWithExtensions(delegate, 'infix-en_GB')
    }

    core('core-') {
        kotlinJvmJs('api')
        kotlinJvmJs('robstoll')
        kotlinJvmJs('robstoll-lib')
    }

    kotlinJvmJs('logic')
    logic('logic-') {
        extensions {
            kotlinJvmJs('kotlin_1_3')
        }
    }

    translations('translations-') {
        kotlinJvmJs('de_CH')
        kotlinJvmJs('en_GB')
    }

    misc {
        kotlinJvmJs('specs')
        kotlinJvmJs('verbs')
        kotlinJvmJs('verbs-internal')

        tools {
            _ 'bc-test'
            project('readme-examples')
        }
    }

    //TODO remove all below with 1.0.0
    misc {
        folder("deprecated") {
            bundles {
                _ 'cc-en_UK-robstoll'
                _ 'cc-infix-en_UK-robstoll'
                kotlinJvmJs('cc-de_CH-robstoll')
                kotlinJvmJs('cc-en_GB-robstoll')
                kotlinJvmJs('cc-infix-en_GB-robstoll')

                if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
                    folder('cc-en_GB-robstoll') {
                        _ 'cc-en_GB-robstoll-smoke-test'
                    }
                    folder('cc-infix-en_GB-robstoll') {
                        _ 'cc-infix-en_GB-robstoll-smoke-test'
                    }
                }
            }

            folder('apis', 'api-') {
                _ 'cc-en_UK'
                _ 'cc-infix-en_UK'
                kotlinJvmJs('cc-de_CH')
                kotlinJvmJs('cc-en_GB')
                kotlinJvmJs('cc-infix-en_GB')
                kotlinJvm(delegate, 'fluent-en_GB-jdk8')
            }

            core('core-') {
                _ 'api-deprecated'
                _ 'robstoll-deprecated'
            }

            _ 'assertions'
            domain('domain-') {
                _ 'api-deprecated'

                kotlinJvmJs('api')
                kotlinJvmJs('builders')
                kotlinJvmJs('robstoll')
                kotlinJvmJs('robstoll-lib')

                api('api-') {
                    extensions {
                        kotlinJvmJs('kotlin_1_3')
                    }
                }

                builders('builders-') {
                    extensions {
                        kotlinJvmJs('kotlin_1_3')
                    }
                }

                robstoll('robstoll-') {
                    extensions {
                        kotlinJvmJs('kotlin_1_3')
                    }
                }

                folder('robstoll-lib', 'robstoll-lib-') {
                    extensions {
                        kotlinJvmJs('kotlin_1_3')
                    }
                }
            }
            _ 'spec'

            translations('translations-') {
                _ 'de_CH-deprecated'
                _ 'en_UK-deprecated'
            }
        }


    }
}
