blob: 01858c333b72c61a1a20b5e2521abeccc48d4141 [file] [log] [blame]
Roman Elizarov26af9192017-09-21 18:12:04 +03001/*
Leonid Startsev0a9f0d62018-07-13 12:12:09 +03002 * Copyright 2018 JetBrains s.r.o.
Roman Elizarov26af9192017-09-21 18:12:04 +03003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Leonid Startsev08d3ca02017-07-26 15:16:23 +030017buildscript {
Leonid Startsevc563d232018-05-07 20:29:23 +030018 def deployNative = property('native.deploy') == 'true'
19
Leonid Startsevca620912017-11-09 19:55:51 +030020 if (project.hasProperty("bootstrap")) {
Leonid Startsev14b57df2018-06-13 23:18:22 +030021 ext.compilerVersion = property('kotlin.version.snapshot')
22 ext.librariesVersion = property('kotlin.version.snapshot')
Leonid Startsev476b7222018-06-26 17:06:14 +030023 ext.serializationPluginVersion = property('plugin.version.snapshot')
Leonid Startseve4c54042018-10-31 18:31:32 +030024 ext.konanVersion = property('konan.version.snapshot')
Leonid Startsev12a00032018-11-08 19:05:36 +030025 ext["org.jetbrains.kotlin.native.home"] = System.getenv("KONAN_LOCAL_DIST")
Leonid Startsevca620912017-11-09 19:55:51 +030026 } else {
Leonid Startsev8642a1f2018-04-03 17:38:39 +030027 ext.compilerVersion = property('kotlin.version')
28 ext.librariesVersion = property('kotlin.version')
Leonid Startsev14b57df2018-06-13 23:18:22 +030029 ext.serializationPluginVersion = property('plugin.version')
Leonid Startseve4c54042018-10-31 18:31:32 +030030 ext.konanVersion = property('konan.version')
Leonid Startsevca620912017-11-09 19:55:51 +030031 }
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030032 ext.serializationCoordinates = "org.jetbrains.kotlin:kotlin-serialization"
Leonid Startsev69ac2ae2018-12-19 18:48:46 +030033 ext.eapChannel = 'https://dl.bintray.com/kotlin/kotlin-dev'
Leonid Startsev1e737f22017-09-14 13:19:32 +030034 ext.serializationRepo = 'https://kotlin.bintray.com/kotlinx'
Leonid Startsevb0fd1202018-12-12 19:42:48 +030035 ext.experimentalsEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030036 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
37 ]
38
Leonid Startsevb0fd1202018-12-12 19:42:48 +030039 ext.experimentalsInTestEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030040 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
41 "-Xuse-experimental=kotlinx.serialization.ImplicitReflectionSerializer",
42 ]
Leonid Startsev08d3ca02017-07-26 15:16:23 +030043
44 repositories {
Leonid Startsev1e737f22017-09-14 13:19:32 +030045 jcenter()
Leonid Startsev6fbc2152017-09-21 16:18:32 +030046 mavenLocal()
Vsevolod Tolstopyatove593b422018-06-28 11:23:49 +030047 maven { url "https://plugins.gradle.org/m2/" }
Leonid Startsev7dd8ad72017-11-22 19:24:02 +030048 maven { url eapChannel }
Leonid Startsev1e737f22017-09-14 13:19:32 +030049 maven { url serializationRepo }
Leonid Startsevbae49f92018-05-03 19:57:01 +030050 maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
Leonid Startsev08d3ca02017-07-26 15:16:23 +030051 }
52
53 dependencies {
Leonid Startsev1e737f22017-09-14 13:19:32 +030054 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$compilerVersion"
Leonid Startsevc652f292018-09-11 17:47:21 +030055 classpath "$serializationCoordinates:$serializationPluginVersion"
Leonid Startsev477563f2018-10-31 16:19:27 +030056 classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$konanVersion"
Leonid Startsevbae49f92018-05-03 19:57:01 +030057
Leonid Startseved87fbd2017-08-04 17:33:09 +030058 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2'
Leonid Startsevbae49f92018-05-03 19:57:01 +030059
Leonid Startsevb4656a02019-01-17 16:19:12 +030060 // Custom bintray plugin to publish with Gradle Metadata
61 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4-jetbrains-3"
Leonid Startsevbae49f92018-05-03 19:57:01 +030062
Vsevolod Tolstopyatove593b422018-06-28 11:23:49 +030063 classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
64 classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
65 classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
Leonid Startsev08d3ca02017-07-26 15:16:23 +030066 }
67}
68
Leonid Startsev00dd4f52017-08-23 16:09:21 +030069ext {
70 libraries = [
Leonid Startsev1e737f22017-09-14 13:19:32 +030071 kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$librariesVersion",
72 kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$librariesVersion",
73 kotlin_stdlib_js: "org.jetbrains.kotlin:kotlin-stdlib-js:$librariesVersion",
74 kotlin_test: "org.jetbrains.kotlin:kotlin-test:$librariesVersion",
Leonid Startsev8642a1f2018-04-03 17:38:39 +030075 kotlin_test_junit: "org.jetbrains.kotlin:kotlin-test-junit:$librariesVersion",
Leonid Startsev1e737f22017-09-14 13:19:32 +030076 kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$librariesVersion",
Leonid Startsev7dd8ad72017-11-22 19:24:02 +030077 kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$librariesVersion",
Leonid Startsev1e737f22017-09-14 13:19:32 +030078 kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$librariesVersion",
79 kotlin_reflect: "org.jetbrains.kotlin:kotlin-reflect:$librariesVersion",
Leonid Startsev00dd4f52017-08-23 16:09:21 +030080 ]
81}
82
83allprojects {
84 group 'org.jetbrains.kotlinx'
Leonid Startsev51114eb2018-07-13 16:00:18 +030085 version property('library.version')
Leonid Startsev476b7222018-06-26 17:06:14 +030086
87 if (project.hasProperty("bootstrap")) {
88 version = version + '-SNAPSHOT'
89 }
Leonid Startsev84062e12017-09-25 16:41:38 +030090
91 repositories {
92 jcenter()
93 mavenLocal()
Leonid Startsevaee4fc22018-08-07 14:42:28 +030094 maven { url eapChannel }
95 maven { url serializationRepo }
Leonid Startsev84062e12017-09-25 16:41:38 +030096 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +030097}
Leonid Startsev08d3ca02017-07-26 15:16:23 +030098
Leonid Startsev08d3ca02017-07-26 15:16:23 +030099apply plugin: 'kotlin'
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300100
Leonid Startsev1c35d912017-10-04 12:26:43 +0300101subprojects {
Leonid Startsev0a9f0d62018-07-13 12:12:09 +0300102 if (project.name.contains("native")) return
Leonid Startsevbae49f92018-05-03 19:57:01 +0300103
Leonid Startsevd79fb1f2017-09-15 18:02:59 +0300104 apply plugin: 'kotlinx-serialization'
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300105
Leonid Startsevc1bb4d22018-10-23 18:50:39 +0300106 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
107 if (task.name.contains("Test") || task.name.contains("Jmh")) {
108 task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
109 } else {
110 task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
111 }
112 }
113
Leonid Startsev133194c2018-07-13 12:58:36 +0300114 if (project.name.contains("benchmark")) return
115
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300116 apply plugin: 'maven-publish'
Leonid Startseved87fbd2017-08-04 17:33:09 +0300117
Leonid Startsevd79fb1f2017-09-15 18:02:59 +0300118 def varintName = ""
119
120 if (project.name == "jvm") {
121 varintName = "${rootProject.name}"
122 } else {
123 varintName = "${rootProject.name}-${project.name}"
124 }
Leonid Startseva5873932017-08-09 11:36:01 +0300125
Leonid Startsevef125382017-09-22 16:50:39 +0300126 afterEvaluate {
127 task sourceJar(type: Jar, dependsOn: classes) {
128 classifier 'sources'
129 from sourceSets.main.kotlin
Leonid Startsev88185402018-02-01 16:03:25 +0300130 if (project.name == "jvm" || project.name == "js") {
131 duplicatesStrategy = "exclude"
132 def platformSrc = sourceSets.main.kotlin
133 def commonSrc = project(':common').sourceSets.main.kotlin
134 from(platformSrc + commonSrc)
135 }
Leonid Startsevef125382017-09-22 16:50:39 +0300136 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300137 }
Leonid Startseva5873932017-08-09 11:36:01 +0300138
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300139 tasks.withType(Jar) {
140 archivesBaseName = varintName
141 }
Leonid Startseva5873932017-08-09 11:36:01 +0300142
Leonid Startsevfa9e9202018-10-18 17:13:44 +0300143 apply from: "${rootProject.rootDir}/gradle/mavenMetadata.gradle"
144
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300145 publishing {
146 publications {
Leonid Startsev1e737f22017-09-14 13:19:32 +0300147 mavenProject(MavenPublication) {
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300148 from components.java
149 groupId project.group
150 artifactId varintName
151 version project.version
152
153 artifact sourceJar {
154 classifier "sources"
155 }
Leonid Startsevfa9e9202018-10-18 17:13:44 +0300156 pom.withXml {
157 def root = it.asNode()
158 // NOTE: Don't try to move top-level things (especially "description") to the pomConfig block
159 // because they would resolve incorrectly to top-level project properties in Gradle/Groovy
160 root.appendNode('name', varintName)
161 root.appendNode('description', 'Kotlin multiplatform serialization runtime library')
162 root.appendNode('url', 'https://github.com/Kotlin/kotlinx.serialization')
163 root.children().last() + pomConfig
164 }
Leonid Startseva5873932017-08-09 11:36:01 +0300165 }
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300166 }
167 }
Leonid Startsev1e737f22017-09-14 13:19:32 +0300168
Leonid Startsevbae49f92018-05-03 19:57:01 +0300169 apply plugin: 'com.jfrog.bintray'
Leonid Startsevc563d232018-05-07 20:29:23 +0300170
171 apply from: "${rootProject.rootDir}/gradle/bintray.gradle"
Leonid Startsev23dfc082018-10-19 14:34:14 +0300172
173 // Disable metadata for non-native modules
174 afterEvaluate {
175 publishing.publications.each { pub ->
Leonid Startsevb4656a02019-01-17 16:19:12 +0300176 pub.moduleDescriptorGenerator = null
Leonid Startsev23dfc082018-10-19 14:34:14 +0300177 }
178 }
Leonid Startsevda728dd2018-03-07 12:41:47 +0300179}