blob: c4da403d1b2386eff240f0848a1c0a982cce61f9 [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 Startsev201ecd92018-09-12 12:47:15 +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 Startsevc1bb4d22018-10-23 18:50:39 +030035 ext.experimentalsEnabled = ["-Xuse-experimental=kotlin.Experimental",
36 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
37 ]
38
39 ext.experimentalsInTestEnabled = ["-Xuse-experimental=kotlin.Experimental",
40 "-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 Startsevc563d232018-05-07 20:29:23 +030060 if (deployNative) {
61 // use patched version which supports Gradle metadata, but is not compatible with Maven publications
62 classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.2-SNAPSHOT'
63 } else {
64 classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
65 }
Leonid Startsevbae49f92018-05-03 19:57:01 +030066
Vsevolod Tolstopyatove593b422018-06-28 11:23:49 +030067 classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
68 classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
69 classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
Leonid Startsev08d3ca02017-07-26 15:16:23 +030070 }
71}
72
Leonid Startsev00dd4f52017-08-23 16:09:21 +030073ext {
74 libraries = [
Leonid Startsev1e737f22017-09-14 13:19:32 +030075 kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$librariesVersion",
76 kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$librariesVersion",
77 kotlin_stdlib_js: "org.jetbrains.kotlin:kotlin-stdlib-js:$librariesVersion",
78 kotlin_test: "org.jetbrains.kotlin:kotlin-test:$librariesVersion",
Leonid Startsev8642a1f2018-04-03 17:38:39 +030079 kotlin_test_junit: "org.jetbrains.kotlin:kotlin-test-junit:$librariesVersion",
Leonid Startsev1e737f22017-09-14 13:19:32 +030080 kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$librariesVersion",
Leonid Startsev7dd8ad72017-11-22 19:24:02 +030081 kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$librariesVersion",
Leonid Startsev1e737f22017-09-14 13:19:32 +030082 kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$librariesVersion",
83 kotlin_reflect: "org.jetbrains.kotlin:kotlin-reflect:$librariesVersion",
Leonid Startsev00dd4f52017-08-23 16:09:21 +030084 ]
85}
86
87allprojects {
88 group 'org.jetbrains.kotlinx'
Leonid Startsev51114eb2018-07-13 16:00:18 +030089 version property('library.version')
Leonid Startsev476b7222018-06-26 17:06:14 +030090
91 if (project.hasProperty("bootstrap")) {
92 version = version + '-SNAPSHOT'
93 }
Leonid Startsev84062e12017-09-25 16:41:38 +030094
95 repositories {
96 jcenter()
97 mavenLocal()
Leonid Startsevaee4fc22018-08-07 14:42:28 +030098 maven { url eapChannel }
99 maven { url serializationRepo }
Leonid Startsev84062e12017-09-25 16:41:38 +0300100 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300101}
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300102
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300103apply plugin: 'kotlin'
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300104
Leonid Startsev1c35d912017-10-04 12:26:43 +0300105subprojects {
Leonid Startsev0a9f0d62018-07-13 12:12:09 +0300106 if (project.name.contains("native")) return
Leonid Startsevbae49f92018-05-03 19:57:01 +0300107
Leonid Startsevd79fb1f2017-09-15 18:02:59 +0300108 apply plugin: 'kotlinx-serialization'
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300109
Leonid Startsevc1bb4d22018-10-23 18:50:39 +0300110 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
111 if (task.name.contains("Test") || task.name.contains("Jmh")) {
112 task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
113 } else {
114 task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
115 }
116 }
117
Leonid Startsev133194c2018-07-13 12:58:36 +0300118 if (project.name.contains("benchmark")) return
119
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300120 apply plugin: 'maven-publish'
Leonid Startseved87fbd2017-08-04 17:33:09 +0300121
Leonid Startsevd79fb1f2017-09-15 18:02:59 +0300122 def varintName = ""
123
124 if (project.name == "jvm") {
125 varintName = "${rootProject.name}"
126 } else {
127 varintName = "${rootProject.name}-${project.name}"
128 }
Leonid Startseva5873932017-08-09 11:36:01 +0300129
Leonid Startsevef125382017-09-22 16:50:39 +0300130 afterEvaluate {
131 task sourceJar(type: Jar, dependsOn: classes) {
132 classifier 'sources'
133 from sourceSets.main.kotlin
Leonid Startsev88185402018-02-01 16:03:25 +0300134 if (project.name == "jvm" || project.name == "js") {
135 duplicatesStrategy = "exclude"
136 def platformSrc = sourceSets.main.kotlin
137 def commonSrc = project(':common').sourceSets.main.kotlin
138 from(platformSrc + commonSrc)
139 }
Leonid Startsevef125382017-09-22 16:50:39 +0300140 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300141 }
Leonid Startseva5873932017-08-09 11:36:01 +0300142
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300143 tasks.withType(Jar) {
144 archivesBaseName = varintName
145 }
Leonid Startseva5873932017-08-09 11:36:01 +0300146
Leonid Startsevfa9e9202018-10-18 17:13:44 +0300147 apply from: "${rootProject.rootDir}/gradle/mavenMetadata.gradle"
148
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300149 publishing {
150 publications {
Leonid Startsev1e737f22017-09-14 13:19:32 +0300151 mavenProject(MavenPublication) {
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300152 from components.java
153 groupId project.group
154 artifactId varintName
155 version project.version
156
157 artifact sourceJar {
158 classifier "sources"
159 }
Leonid Startsevfa9e9202018-10-18 17:13:44 +0300160 pom.withXml {
161 def root = it.asNode()
162 // NOTE: Don't try to move top-level things (especially "description") to the pomConfig block
163 // because they would resolve incorrectly to top-level project properties in Gradle/Groovy
164 root.appendNode('name', varintName)
165 root.appendNode('description', 'Kotlin multiplatform serialization runtime library')
166 root.appendNode('url', 'https://github.com/Kotlin/kotlinx.serialization')
167 root.children().last() + pomConfig
168 }
Leonid Startseva5873932017-08-09 11:36:01 +0300169 }
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300170 }
171 }
Leonid Startsev1e737f22017-09-14 13:19:32 +0300172
Leonid Startsevbae49f92018-05-03 19:57:01 +0300173 apply plugin: 'com.jfrog.bintray'
Leonid Startsevc563d232018-05-07 20:29:23 +0300174
175 apply from: "${rootProject.rootDir}/gradle/bintray.gradle"
Leonid Startsev23dfc082018-10-19 14:34:14 +0300176
177 // Disable metadata for non-native modules
178 afterEvaluate {
179 publishing.publications.each { pub ->
180 pub.gradleModuleMetadataFile = null
181 tasks.matching { it.name == "generateMetadataFileFor${pub.name.capitalize()}Publication" }.all {
182 onlyIf { false }
183 }
184 }
185 }
Leonid Startsevda728dd2018-03-07 12:41:47 +0300186}