blob: 69aa68dd173ea42a6ae2599be22832481061b274 [file] [log] [blame]
/*
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
buildscript {
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.Experimental",
"-opt-in=kotlin.ExperimentalMultiplatform",
"-opt-in=kotlinx.serialization.InternalSerializationApi"
]
ext.experimentalsInTestEnabled = ["-progressive", "-opt-in=kotlin.Experimental",
"-opt-in=kotlin.ExperimentalMultiplatform",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlinx.serialization.InternalSerializationApi",
"-opt-in=kotlin.ExperimentalUnsignedTypes"
]
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.gradle:jmh-gradle-plugin:0.5.3"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.21"
}
}
// 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://kotlin.github.io/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" }
}
}
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()
}
}
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 (project.name != "benchmark" && project.name != "guide") {
apply from: rootProject.file('gradle/publishing.gradle')
}
}
subprojects {
// Can't be applied to BOM
if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark" || project.name == "guide") return
// Animalsniffer setup
apply plugin: 'ru.vyarus.animalsniffer'
afterEvaluate { // Can be applied only when the project is evaluated
animalsniffer {
sourceSets = [sourceSets.main]
}
dependencies {
signature 'net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature'
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
}
}
// Kover setup
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")