/*
 * Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

buildscript {
    /**
     * Overrides for Teamcity 'K2 User Projects' + 'Aggregate build / Kotlinx libraries compilation' configuration:
     * kotlin_repo_url - local repository with snapshot Kotlin compiler
     * kotlin_version - kotlin version to use
     * kotlin_language_version - LV to use
     */
    ext.snapshotRepoUrl = rootProject.properties["kotlin_repo_url"]
    ext.kotlin_lv_override = rootProject.properties["kotlin_language_version"]
    if (snapshotRepoUrl != null && snapshotRepoUrl != "") {
        ext.kotlin_version = rootProject.properties["kotlin_version"]
        repositories {
            maven { url snapshotRepoUrl }
        }
    } else if (project.hasProperty("bootstrap")) {
        ext.kotlin_version = property('kotlin.version.snapshot')
        ext["kotlin.native.home"] = System.getenv("KONAN_LOCAL_DIST")
    } else {
        ext.kotlin_version = property('kotlin.version')
    }
    if (project.hasProperty("library.version")) {
        ext.overriden_version = property('library.version')
    }
    ext.experimentalsEnabled = ["-progressive",
                                "-opt-in=kotlin.ExperimentalMultiplatform",
                                "-opt-in=kotlinx.serialization.InternalSerializationApi",
                                "-P", "plugin:org.jetbrains.kotlinx.serialization:disableIntrinsic=false"
    ]

    ext.experimentalsInTestEnabled = ["-progressive",
                                      "-opt-in=kotlin.ExperimentalMultiplatform",
                                      "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
                                      "-opt-in=kotlinx.serialization.InternalSerializationApi",
                                      "-P", "plugin:org.jetbrains.kotlinx.serialization:disableIntrinsic=false"
    ]
    ext.koverEnabled = property('kover.enabled') ?: true

    /*
    * This property group is used to build kotlinx.serialization against Kotlin compiler snapshot.
    * When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version.
    * DO NOT change the name of these properties without adapting kotlinx.train build chain.
    */
    def prop = rootProject.properties['build_snapshot_train']
    ext.build_snapshot_train = prop != null && prop != ""
    if (build_snapshot_train) {
        ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
        if (kotlin_version == null) {
            throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
        }
        repositories {
            maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        }
    }

    repositories {
        maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' }
        // kotlin-dev with space redirector
        maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
        mavenCentral()
        gradlePluginPortal()
        // For Dokka that depends on kotlinx-html
        maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" }
        mavenLocal()
    }

    configurations.classpath {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == 'org.jetbrains.kotlin') {
                details.useVersion kotlin_version
            }
        }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
        classpath "org.jetbrains.kotlinx:kover:$kover_version"
        classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$validator_version"
        classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
        classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.3' // Android API check

        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'

        // Various benchmarking stuff
        classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2"
        classpath "me.champeau.jmh:jmh-gradle-plugin:0.6.6"
    }
}

// To make it visible for compiler-version.gradle
ext.compilerVersion = org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION
ext.nativeDebugBuild = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG

apply plugin: 'binary-compatibility-validator'
apply plugin: 'base'
apply plugin: 'kotlinx-knit'

apiValidation {
    ignoredProjects += ["benchmark", "guide", "kotlinx-serialization"]
}

knit {
    siteRoot = "https://kotlinlang.org/api/kotlinx.serialization"
    moduleDocs = "build/dokka/htmlMultiModule"
}

// Build API docs for all modules with dokka before running Knit
knitPrepare.dependsOn "dokka"

apply plugin: 'org.jetbrains.dokka'
dependencies {
    dokkaPlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
}

allprojects {
    group 'org.jetbrains.kotlinx'

    def deployVersion = properties['DeployVersion']
    if (deployVersion != null) version = deployVersion

    if (project.hasProperty("bootstrap")) {
        version = version + '-SNAPSHOT'
    }

    // the only place where HostManager could be instantiated
    project.ext.hostManager = new org.jetbrains.kotlin.konan.target.HostManager()

    if (build_snapshot_train) {
        // Snapshot-specific
        repositories {
            mavenLocal()
            maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        }
    }

    if (snapshotRepoUrl != null && snapshotRepoUrl != "") {
        // Snapshot-specific for K2 CI configurations
        repositories {
            maven { url snapshotRepoUrl }
        }
    }

    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == 'org.jetbrains.kotlin') {
                details.useVersion kotlin_version
            }
        }
    }

    repositories {
        mavenCentral()
        maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' }
        // kotlin-dev with space redirector
        maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
        // For Dokka that depends on kotlinx-html
        maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" }
        // For local development
        mavenLocal()

    }
}

def unpublishedProjects = ["benchmark", "guide", "kotlinx-serialization-json-tests"] as Set
def excludedFromBomProjects = unpublishedProjects + "kotlinx-serialization-bom" as Set
def uncoveredProjects = ["kotlinx-serialization-bom", "benchmark", "guide"] as Set

subprojects {
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
        if (task.name.contains("Test") || task.name.contains("Jmh")) {
            task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
        } else {
            task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
        }
    }

    apply from: rootProject.file('gradle/teamcity.gradle')
    // Configure publishing for some artifacts
    if (!unpublishedProjects.contains(project.name)) {
        apply from: rootProject.file('gradle/publishing.gradle')
    }
}

subprojects {
    // Can't be applied to BOM
    if (excludedFromBomProjects.contains(project.name)) return

    // Animalsniffer setup
    // Animalsniffer requires java plugin to be applied, but Kotlin 1.9.20
    // relies on `java-base` for Kotlin Multiplatforms `withJava` implementation
    // https://github.com/xvik/gradle-animalsniffer-plugin/issues/84
    // https://youtrack.jetbrains.com/issue/KT-59595
    JavaPluginUtil.applyJavaPlugin(project)
    apply plugin: 'ru.vyarus.animalsniffer'

    afterEvaluate { // Can be applied only when the project is evaluated
        animalsniffer {
            sourceSets = [sourceSets.main]
            def annotationValue = "kotlinx.serialization.json.internal.SuppressAnimalSniffer"
            switch (name) {
                case "kotlinx-serialization-core":
                    annotationValue = "kotlinx.serialization.internal.SuppressAnimalSniffer"
                    break
                case "kotlinx-serialization-hocon":
                    annotationValue = "kotlinx.serialization.hocon.internal.SuppressAnimalSniffer"
                    break
                case "kotlinx-serialization-protobuf":
                    annotationValue = "kotlinx.serialization.protobuf.internal.SuppressAnimalSniffer"
            }
            annotation = annotationValue
        }
        dependencies {
            signature 'net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature'
            signature 'org.codehaus.mojo.signature:java18:1.0@signature'
        }

        // Add dependency on kotlinx-serialization-bom inside other kotlinx-serialization modules themselves, so they have same versions
        BomKt.addBomApiDependency(project, ":kotlinx-serialization-bom")
    }
}

// Kover setup
subprojects {
    if (uncoveredProjects.contains(project.name)) return

    apply from: rootProject.file("gradle/kover.gradle")
}

apply from: rootProject.file('gradle/compiler-version.gradle')
apply from: rootProject.file("gradle/dokka.gradle")
apply from: rootProject.file("gradle/benchmark-parsing.gradle")

tasks.named("dokkaHtmlMultiModule") {
    pluginsMapConfiguration.set(["org.jetbrains.dokka.base.DokkaBase": """{ "templatesDir": "${projectDir.toString().replace('\\', '/')}/dokka-templates" }"""])
}
