Roman Elizarov | 26af919 | 2017-09-21 18:12:04 +0300 | [diff] [blame] | 1 | /* |
Leonid Startsev | 21dea85 | 2021-05-18 18:36:19 +0300 | [diff] [blame] | 2 | * Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
Roman Elizarov | 26af919 | 2017-09-21 18:12:04 +0300 | [diff] [blame] | 3 | */ |
| 4 | |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 5 | buildscript { |
Leonid Startsev | ca62091 | 2017-11-09 19:55:51 +0300 | [diff] [blame] | 6 | if (project.hasProperty("bootstrap")) { |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 7 | ext.kotlin_version = property('kotlin.version.snapshot') |
Leonid Startsev | cea9b43 | 2019-11-19 14:14:26 +0300 | [diff] [blame] | 8 | ext["kotlin.native.home"] = System.getenv("KONAN_LOCAL_DIST") |
Leonid Startsev | ca62091 | 2017-11-09 19:55:51 +0300 | [diff] [blame] | 9 | } else { |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 10 | ext.kotlin_version = property('kotlin.version') |
Leonid Startsev | ca62091 | 2017-11-09 19:55:51 +0300 | [diff] [blame] | 11 | } |
Leonid Startsev | 78d5d2d | 2019-07-25 13:51:54 +0300 | [diff] [blame] | 12 | if (project.hasProperty("library.version")) { |
| 13 | ext.overriden_version = property('library.version') |
| 14 | } |
Leonid Startsev | 9650a28 | 2022-05-11 14:55:47 +0300 | [diff] [blame^] | 15 | ext.experimentalsEnabled = ["-progressive", "-opt-in=kotlin.Experimental", |
| 16 | "-opt-in=kotlin.ExperimentalMultiplatform", |
| 17 | "-opt-in=kotlinx.serialization.InternalSerializationApi" |
Vsevolod Tolstopyatov | 74b4802 | 2019-04-02 18:56:29 +0300 | [diff] [blame] | 18 | ] |
Leonid Startsev | c1bb4d2 | 2018-10-23 18:50:39 +0300 | [diff] [blame] | 19 | |
Leonid Startsev | 9650a28 | 2022-05-11 14:55:47 +0300 | [diff] [blame^] | 20 | ext.experimentalsInTestEnabled = ["-progressive", "-opt-in=kotlin.Experimental", |
| 21 | "-opt-in=kotlin.ExperimentalMultiplatform", |
| 22 | "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", |
| 23 | "-opt-in=kotlinx.serialization.InternalSerializationApi", |
| 24 | "-opt-in=kotlin.ExperimentalUnsignedTypes" |
Vsevolod Tolstopyatov | 74b4802 | 2019-04-02 18:56:29 +0300 | [diff] [blame] | 25 | ] |
Leonid Startsev | e721ebe | 2021-10-29 14:41:49 +0300 | [diff] [blame] | 26 | ext.koverEnabled = property('kover.enabled') ?: true |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 27 | |
Vsevolod Tolstopyatov | fa2231c | 2019-05-29 17:39:15 +0300 | [diff] [blame] | 28 | /* |
Leonid Startsev | cea9b43 | 2019-11-19 14:14:26 +0300 | [diff] [blame] | 29 | * This property group is used to build kotlinx.serialization against Kotlin compiler snapshot. |
Vsevolod Tolstopyatov | fa2231c | 2019-05-29 17:39:15 +0300 | [diff] [blame] | 30 | * When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version. |
| 31 | * DO NOT change the name of these properties without adapting kotlinx.train build chain. |
| 32 | */ |
| 33 | def prop = rootProject.properties['build_snapshot_train'] |
| 34 | ext.build_snapshot_train = prop != null && prop != "" |
| 35 | if (build_snapshot_train) { |
| 36 | ext.kotlin_version = rootProject.properties['kotlin_snapshot_version'] |
| 37 | if (kotlin_version == null) { |
| 38 | throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler") |
| 39 | } |
| 40 | repositories { |
Vsevolod Tolstopyatov | fa2231c | 2019-05-29 17:39:15 +0300 | [diff] [blame] | 41 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
Vsevolod Tolstopyatov | fa2231c | 2019-05-29 17:39:15 +0300 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 45 | repositories { |
Vsevolod Tolstopyatov | d3d2dca | 2020-10-03 06:18:32 -0700 | [diff] [blame] | 46 | maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' } |
Leonid Startsev | fc9343f | 2021-04-26 15:18:02 +0300 | [diff] [blame] | 47 | // kotlin-dev with space redirector |
| 48 | maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } |
Leonid Startsev | 6a8dc86 | 2021-02-04 17:03:31 +0300 | [diff] [blame] | 49 | mavenCentral() |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 50 | gradlePluginPortal() |
Vsevolod Tolstopyatov | 6d2e5cf | 2021-03-17 15:00:40 +0300 | [diff] [blame] | 51 | // For Dokka that depends on kotlinx-html |
Leonid Startsev | 9f8d050 | 2021-07-08 12:12:06 +0300 | [diff] [blame] | 52 | maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" } |
Leonid Startsev | 0e75d25 | 2021-09-01 15:07:44 +0300 | [diff] [blame] | 53 | mavenLocal() |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 54 | } |
| 55 | |
Leonid Startsev | d656e5a | 2019-06-14 12:06:23 +0300 | [diff] [blame] | 56 | configurations.classpath { |
| 57 | resolutionStrategy.eachDependency { DependencyResolveDetails details -> |
| 58 | if (details.requested.group == 'org.jetbrains.kotlin') { |
| 59 | details.useVersion kotlin_version |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 64 | dependencies { |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 65 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| 66 | classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" |
Leonid Startsev | bc9c8f4 | 2020-04-06 22:30:25 +0300 | [diff] [blame] | 67 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" |
Leonid Startsev | e721ebe | 2021-10-29 14:41:49 +0300 | [diff] [blame] | 68 | classpath "org.jetbrains.kotlinx:kover:$kover_version" |
Vsevolod Tolstopyatov | 6de9648 | 2020-06-17 06:41:00 -0700 | [diff] [blame] | 69 | classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$validator_version" |
Roman Elizarov | 5459c10 | 2020-08-11 12:27:36 +0300 | [diff] [blame] | 70 | classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version" |
Vsevolod Tolstopyatov | ab5c139 | 2021-06-09 15:38:57 +0300 | [diff] [blame] | 71 | classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.3' // Android API check |
Leonid Startsev | bc9c8f4 | 2020-04-06 22:30:25 +0300 | [diff] [blame] | 72 | |
Sebastian Schuberth | ece9fdd | 2022-01-28 16:23:48 +0100 | [diff] [blame] | 73 | classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18' |
Leonid Startsev | bae49f9 | 2018-05-03 19:57:01 +0300 | [diff] [blame] | 74 | |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 75 | // Various benchmarking stuff |
| 76 | classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2" |
Mark Kosichkin | c5672e9 | 2021-05-24 21:38:20 +0300 | [diff] [blame] | 77 | classpath "me.champeau.gradle:jmh-gradle-plugin:0.5.3" |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 78 | classpath "net.ltgt.gradle:gradle-apt-plugin:0.21" |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 79 | } |
| 80 | } |
| 81 | |
Vsevolod Tolstopyatov | 608cbad | 2020-09-14 15:38:02 +0300 | [diff] [blame] | 82 | // To make it visible for compiler-version.gradle |
Vsevolod Tolstopyatov | fa2231c | 2019-05-29 17:39:15 +0300 | [diff] [blame] | 83 | ext.compilerVersion = org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION |
Vsevolod Tolstopyatov | 07f730a | 2021-01-22 03:32:08 -0800 | [diff] [blame] | 84 | ext.nativeDebugBuild = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG |
Vsevolod Tolstopyatov | ab5c139 | 2021-06-09 15:38:57 +0300 | [diff] [blame] | 85 | |
Vsevolod Tolstopyatov | 6de9648 | 2020-06-17 06:41:00 -0700 | [diff] [blame] | 86 | apply plugin: 'binary-compatibility-validator' |
Vsevolod Tolstopyatov | ab5c139 | 2021-06-09 15:38:57 +0300 | [diff] [blame] | 87 | apply plugin: 'base' |
| 88 | apply plugin: 'kotlinx-knit' |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 89 | |
Vsevolod Tolstopyatov | 6de9648 | 2020-06-17 06:41:00 -0700 | [diff] [blame] | 90 | apiValidation { |
Roman Elizarov | 5459c10 | 2020-08-11 12:27:36 +0300 | [diff] [blame] | 91 | ignoredProjects += ["benchmark", "guide", "kotlinx-serialization"] |
Vsevolod Tolstopyatov | 6de9648 | 2020-06-17 06:41:00 -0700 | [diff] [blame] | 92 | } |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 93 | |
Roman Elizarov | 5459c10 | 2020-08-11 12:27:36 +0300 | [diff] [blame] | 94 | knit { |
| 95 | siteRoot = "https://kotlin.github.io/kotlinx.serialization" |
Vsevolod Tolstopyatov | d3d2dca | 2020-10-03 06:18:32 -0700 | [diff] [blame] | 96 | moduleDocs = "build/dokka/htmlMultiModule" |
Roman Elizarov | 5459c10 | 2020-08-11 12:27:36 +0300 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | // Build API docs for all modules with dokka before running Knit |
| 100 | knitPrepare.dependsOn "dokka" |
| 101 | |
Ignat Beresnev | 8be6845 | 2021-12-27 18:40:50 +0300 | [diff] [blame] | 102 | apply plugin: 'org.jetbrains.dokka' |
| 103 | dependencies { |
| 104 | dokkaPlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version") |
| 105 | } |
| 106 | |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 107 | allprojects { |
| 108 | group 'org.jetbrains.kotlinx' |
Leonid Startsev | 476b722 | 2018-06-26 17:06:14 +0300 | [diff] [blame] | 109 | |
Leonid Startsev | f5accd1 | 2020-02-25 20:42:46 +0300 | [diff] [blame] | 110 | def deployVersion = properties['DeployVersion'] |
| 111 | if (deployVersion != null) version = deployVersion |
Leonid Startsev | 78d5d2d | 2019-07-25 13:51:54 +0300 | [diff] [blame] | 112 | |
Leonid Startsev | 476b722 | 2018-06-26 17:06:14 +0300 | [diff] [blame] | 113 | if (project.hasProperty("bootstrap")) { |
| 114 | version = version + '-SNAPSHOT' |
| 115 | } |
Leonid Startsev | 84062e1 | 2017-09-25 16:41:38 +0300 | [diff] [blame] | 116 | |
Leonid Startsev | 9f6d3b4 | 2019-10-09 18:07:41 +0300 | [diff] [blame] | 117 | // the only place where HostManager could be instantiated |
| 118 | project.ext.hostManager = new org.jetbrains.kotlin.konan.target.HostManager() |
| 119 | |
Vsevolod Tolstopyatov | fa2231c | 2019-05-29 17:39:15 +0300 | [diff] [blame] | 120 | if (build_snapshot_train) { |
| 121 | // Snapshot-specific |
Vsevolod Tolstopyatov | fa2231c | 2019-05-29 17:39:15 +0300 | [diff] [blame] | 122 | repositories { |
| 123 | mavenLocal() |
| 124 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| 125 | } |
| 126 | } |
Leonid Startsev | cf1db5c | 2019-09-17 19:33:44 +0300 | [diff] [blame] | 127 | |
| 128 | configurations.all { |
| 129 | resolutionStrategy.eachDependency { DependencyResolveDetails details -> |
| 130 | if (details.requested.group == 'org.jetbrains.kotlin') { |
| 131 | details.useVersion kotlin_version |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
Leonid Startsev | 84062e1 | 2017-09-25 16:41:38 +0300 | [diff] [blame] | 136 | repositories { |
Leonid Startsev | 6a8dc86 | 2021-02-04 17:03:31 +0300 | [diff] [blame] | 137 | mavenCentral() |
Vsevolod Tolstopyatov | d3d2dca | 2020-10-03 06:18:32 -0700 | [diff] [blame] | 138 | maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev' } |
Vsevolod Tolstopyatov | 6d2e5cf | 2021-03-17 15:00:40 +0300 | [diff] [blame] | 139 | // kotlin-dev with space redirector |
| 140 | maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } |
| 141 | // For Dokka that depends on kotlinx-html |
Leonid Startsev | 9f8d050 | 2021-07-08 12:12:06 +0300 | [diff] [blame] | 142 | maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" } |
Vsevolod Tolstopyatov | 6d2e5cf | 2021-03-17 15:00:40 +0300 | [diff] [blame] | 143 | // For local development |
| 144 | mavenLocal() |
Leonid Startsev | 9f8d050 | 2021-07-08 12:12:06 +0300 | [diff] [blame] | 145 | |
Leonid Startsev | 84062e1 | 2017-09-25 16:41:38 +0300 | [diff] [blame] | 146 | } |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 147 | } |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 148 | |
Leonid Startsev | 1c35d91 | 2017-10-04 12:26:43 +0300 | [diff] [blame] | 149 | subprojects { |
Leonid Startsev | c1bb4d2 | 2018-10-23 18:50:39 +0300 | [diff] [blame] | 150 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task -> |
| 151 | if (task.name.contains("Test") || task.name.contains("Jmh")) { |
| 152 | task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled |
| 153 | } else { |
| 154 | task.kotlinOptions.freeCompilerArgs += experimentalsEnabled |
| 155 | } |
| 156 | } |
| 157 | |
Leonid Startsev | 9f6d3b4 | 2019-10-09 18:07:41 +0300 | [diff] [blame] | 158 | apply from: rootProject.file('gradle/teamcity.gradle') |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 159 | // Configure publishing for some artifacts |
Roman Elizarov | 5459c10 | 2020-08-11 12:27:36 +0300 | [diff] [blame] | 160 | if (project.name != "benchmark" && project.name != "guide") { |
| 161 | apply from: rootProject.file('gradle/publishing.gradle') |
| 162 | } |
| 163 | |
Leonid Startsev | 45aa7c7 | 2019-04-23 21:29:03 +0300 | [diff] [blame] | 164 | } |
Leonid Startsev | ed87fbd | 2017-08-04 17:33:09 +0300 | [diff] [blame] | 165 | |
Vsevolod Tolstopyatov | ab5c139 | 2021-06-09 15:38:57 +0300 | [diff] [blame] | 166 | subprojects { |
| 167 | // Can't be applied to BOM |
Leonid Startsev | e721ebe | 2021-10-29 14:41:49 +0300 | [diff] [blame] | 168 | if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark" || project.name == "guide") return |
| 169 | |
| 170 | // Animalsniffer setup |
Vsevolod Tolstopyatov | ab5c139 | 2021-06-09 15:38:57 +0300 | [diff] [blame] | 171 | apply plugin: 'ru.vyarus.animalsniffer' |
| 172 | |
| 173 | afterEvaluate { // Can be applied only when the project is evaluated |
| 174 | animalsniffer { |
| 175 | sourceSets = [sourceSets.main] |
| 176 | } |
| 177 | dependencies { |
| 178 | signature 'net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature' |
| 179 | signature 'org.codehaus.mojo.signature:java18:1.0@signature' |
| 180 | } |
| 181 | } |
Leonid Startsev | e721ebe | 2021-10-29 14:41:49 +0300 | [diff] [blame] | 182 | |
| 183 | // Kover setup |
| 184 | apply from: rootProject.file("gradle/kover.gradle") |
Vsevolod Tolstopyatov | ab5c139 | 2021-06-09 15:38:57 +0300 | [diff] [blame] | 185 | } |
| 186 | |
Vsevolod Tolstopyatov | 608cbad | 2020-09-14 15:38:02 +0300 | [diff] [blame] | 187 | apply from: rootProject.file('gradle/compiler-version.gradle') |
Leonid Startsev | bc9c8f4 | 2020-04-06 22:30:25 +0300 | [diff] [blame] | 188 | apply from: rootProject.file("gradle/dokka.gradle") |
Leonid Startsev | 98ead98 | 2021-06-28 13:02:07 +0300 | [diff] [blame] | 189 | apply from: rootProject.file("gradle/benchmark-parsing.gradle") |