/*
 * 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

    def noTeamcityInteractionFlag = rootProject.hasProperty("no_teamcity_interaction")
    def buildSnapshotUPFlag = rootProject.hasProperty("build_snapshot_up")
    ext.teamcityInteractionDisabled = noTeamcityInteractionFlag || buildSnapshotUPFlag

    /*
    * 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()

    }

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile).configureEach {
        compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") }
    }
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile).configureEach {
        compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") }
    }
}

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" }"""])
}

tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask).configureEach {
    args.add("--ignore-engines")
}