blob: 94ec4a9e19fee8142ba370923ebe8771fddb17a7 [file] [log] [blame]
Roman Elizarov26af9192017-09-21 18:12:04 +03001/*
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +03002 * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Roman Elizarov26af9192017-09-21 18:12:04 +03003 */
4
Leonid Startsev08d3ca02017-07-26 15:16:23 +03005buildscript {
Leonid Startsevc563d232018-05-07 20:29:23 +03006 def deployNative = property('native.deploy') == 'true'
7
Leonid Startsevca620912017-11-09 19:55:51 +03008 if (project.hasProperty("bootstrap")) {
Leonid Startsev14b57df2018-06-13 23:18:22 +03009 ext.compilerVersion = property('kotlin.version.snapshot')
10 ext.librariesVersion = property('kotlin.version.snapshot')
Leonid Startsev476b7222018-06-26 17:06:14 +030011 ext.serializationPluginVersion = property('plugin.version.snapshot')
Leonid Startseve4c54042018-10-31 18:31:32 +030012 ext.konanVersion = property('konan.version.snapshot')
Leonid Startsev12a00032018-11-08 19:05:36 +030013 ext["org.jetbrains.kotlin.native.home"] = System.getenv("KONAN_LOCAL_DIST")
Leonid Startsevca620912017-11-09 19:55:51 +030014 } else {
Leonid Startsev8642a1f2018-04-03 17:38:39 +030015 ext.compilerVersion = property('kotlin.version')
16 ext.librariesVersion = property('kotlin.version')
Leonid Startsev14b57df2018-06-13 23:18:22 +030017 ext.serializationPluginVersion = property('plugin.version')
Leonid Startseve4c54042018-10-31 18:31:32 +030018 ext.konanVersion = property('konan.version')
Leonid Startsevca620912017-11-09 19:55:51 +030019 }
Leonid Startsevdafca6a2019-03-11 17:33:27 +030020 ext.serializationVersion = property('library.version')
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030021 ext.serializationCoordinates = "org.jetbrains.kotlin:kotlin-serialization"
Leonid Startsev1d3e1502019-03-22 18:32:14 +030022 ext.tcChannel = 'https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:2082584/artifacts/content/maven'
Leonid Startsev97b71872019-02-05 13:04:43 +030023 ext.devChannel = 'https://kotlin.bintray.com/kotlin-dev'
Leonid Startsev1e737f22017-09-14 13:19:32 +030024 ext.serializationRepo = 'https://kotlin.bintray.com/kotlinx'
Leonid Startsevb0fd1202018-12-12 19:42:48 +030025 ext.experimentalsEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030026 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030027 ]
Leonid Startsevc1bb4d22018-10-23 18:50:39 +030028
Leonid Startsevb0fd1202018-12-12 19:42:48 +030029 ext.experimentalsInTestEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
Vsevolod Tolstopyatov74b48022019-04-02 18:56:29 +030030 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
31 "-Xuse-experimental=kotlinx.serialization.ImplicitReflectionSerializer",
32 "-Xuse-experimental=kotlinx.serialization.UnstableDefault"
33 ]
Leonid Startsev08d3ca02017-07-26 15:16:23 +030034
35 repositories {
Leonid Startsev6fbc2152017-09-21 16:18:32 +030036 mavenLocal()
Leonid Startsev97b71872019-02-05 13:04:43 +030037 maven { url tcChannel }
38 maven { url devChannel }
Leonid Startsev1e737f22017-09-14 13:19:32 +030039 maven { url serializationRepo }
Leonid Startsev97b71872019-02-05 13:04:43 +030040 maven { url "https://plugins.gradle.org/m2/" }
Leonid Startsevbae49f92018-05-03 19:57:01 +030041 maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
Leonid Startsev97b71872019-02-05 13:04:43 +030042 jcenter()
Leonid Startsev08d3ca02017-07-26 15:16:23 +030043 }
44
45 dependencies {
Leonid Startsev1e737f22017-09-14 13:19:32 +030046 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$compilerVersion"
Leonid Startsevc652f292018-09-11 17:47:21 +030047 classpath "$serializationCoordinates:$serializationPluginVersion"
Leonid Startsev477563f2018-10-31 16:19:27 +030048 classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$konanVersion"
Leonid Startsevbae49f92018-05-03 19:57:01 +030049
Leonid Startseved87fbd2017-08-04 17:33:09 +030050 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2'
Leonid Startsevbae49f92018-05-03 19:57:01 +030051
Leonid Startsevb4656a02019-01-17 16:19:12 +030052 // Custom bintray plugin to publish with Gradle Metadata
53 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4-jetbrains-3"
Leonid Startsevbae49f92018-05-03 19:57:01 +030054
Vsevolod Tolstopyatove593b422018-06-28 11:23:49 +030055 classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
56 classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
57 classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
Leonid Startsev08d3ca02017-07-26 15:16:23 +030058 }
59}
60
Leonid Startsev00dd4f52017-08-23 16:09:21 +030061ext {
62 libraries = [
Leonid Startsev1e737f22017-09-14 13:19:32 +030063 kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$librariesVersion",
64 kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$librariesVersion",
65 kotlin_stdlib_js: "org.jetbrains.kotlin:kotlin-stdlib-js:$librariesVersion",
66 kotlin_test: "org.jetbrains.kotlin:kotlin-test:$librariesVersion",
Leonid Startsev8642a1f2018-04-03 17:38:39 +030067 kotlin_test_junit: "org.jetbrains.kotlin:kotlin-test-junit:$librariesVersion",
Leonid Startsev1e737f22017-09-14 13:19:32 +030068 kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$librariesVersion",
Leonid Startsev7dd8ad72017-11-22 19:24:02 +030069 kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$librariesVersion",
Leonid Startsev1e737f22017-09-14 13:19:32 +030070 kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$librariesVersion",
71 kotlin_reflect: "org.jetbrains.kotlin:kotlin-reflect:$librariesVersion",
Leonid Startsev00dd4f52017-08-23 16:09:21 +030072 ]
73}
74
75allprojects {
76 group 'org.jetbrains.kotlinx'
Leonid Startsevdafca6a2019-03-11 17:33:27 +030077 version serializationVersion
Leonid Startsev476b7222018-06-26 17:06:14 +030078
79 if (project.hasProperty("bootstrap")) {
80 version = version + '-SNAPSHOT'
81 }
Leonid Startsev84062e12017-09-25 16:41:38 +030082
83 repositories {
Leonid Startsev84062e12017-09-25 16:41:38 +030084 mavenLocal()
Leonid Startsev97b71872019-02-05 13:04:43 +030085 maven { url tcChannel }
86 maven { url devChannel }
Leonid Startsevaee4fc22018-08-07 14:42:28 +030087 maven { url serializationRepo }
Leonid Startsev97b71872019-02-05 13:04:43 +030088 jcenter()
Leonid Startsev84062e12017-09-25 16:41:38 +030089 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +030090}
Leonid Startsev08d3ca02017-07-26 15:16:23 +030091
Leonid Startsev08d3ca02017-07-26 15:16:23 +030092apply plugin: 'kotlin'
Leonid Startsev08d3ca02017-07-26 15:16:23 +030093
Leonid Startsev1c35d912017-10-04 12:26:43 +030094subprojects {
Leonid Startsev1d3e1502019-03-22 18:32:14 +030095 configurations.all {
96 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
97 if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name == 'kotlinx-serialization-unshaded') {
98 details.useVersion serializationPluginVersion
99 details.because 'use not bundled one'
100 }
101 }
102 }
103
Leonid Startsev0a9f0d62018-07-13 12:12:09 +0300104 if (project.name.contains("native")) return
Leonid Startsevbae49f92018-05-03 19:57:01 +0300105
Leonid Startsevd79fb1f2017-09-15 18:02:59 +0300106 apply plugin: 'kotlinx-serialization'
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300107
Leonid Startsevc1bb4d22018-10-23 18:50:39 +0300108 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
109 if (task.name.contains("Test") || task.name.contains("Jmh")) {
110 task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
111 } else {
112 task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
113 }
114 }
115
Leonid Startsev133194c2018-07-13 12:58:36 +0300116 if (project.name.contains("benchmark")) return
117
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300118 apply plugin: 'maven-publish'
Leonid Startseved87fbd2017-08-04 17:33:09 +0300119
Leonid Startsevd79fb1f2017-09-15 18:02:59 +0300120 def varintName = ""
121
122 if (project.name == "jvm") {
123 varintName = "${rootProject.name}"
124 } else {
125 varintName = "${rootProject.name}-${project.name}"
126 }
Leonid Startseva5873932017-08-09 11:36:01 +0300127
Leonid Startsevef125382017-09-22 16:50:39 +0300128 afterEvaluate {
129 task sourceJar(type: Jar, dependsOn: classes) {
130 classifier 'sources'
131 from sourceSets.main.kotlin
Leonid Startsev88185402018-02-01 16:03:25 +0300132 if (project.name == "jvm" || project.name == "js") {
133 duplicatesStrategy = "exclude"
134 def platformSrc = sourceSets.main.kotlin
135 def commonSrc = project(':common').sourceSets.main.kotlin
136 from(platformSrc + commonSrc)
137 }
Leonid Startsevef125382017-09-22 16:50:39 +0300138 }
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300139 }
Leonid Startseva5873932017-08-09 11:36:01 +0300140
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300141 tasks.withType(Jar) {
142 archivesBaseName = varintName
143 }
Leonid Startseva5873932017-08-09 11:36:01 +0300144
Leonid Startsevfa9e9202018-10-18 17:13:44 +0300145 apply from: "${rootProject.rootDir}/gradle/mavenMetadata.gradle"
146
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300147 publishing {
148 publications {
Leonid Startsev1e737f22017-09-14 13:19:32 +0300149 mavenProject(MavenPublication) {
Leonid Startsev00dd4f52017-08-23 16:09:21 +0300150 from components.java
151 groupId project.group
152 artifactId varintName
153 version project.version
154
155 artifact sourceJar {
156 classifier "sources"
157 }
Leonid Startsevfa9e9202018-10-18 17:13:44 +0300158 pom.withXml {
159 def root = it.asNode()
160 // NOTE: Don't try to move top-level things (especially "description") to the pomConfig block
161 // because they would resolve incorrectly to top-level project properties in Gradle/Groovy
162 root.appendNode('name', varintName)
163 root.appendNode('description', 'Kotlin multiplatform serialization runtime library')
164 root.appendNode('url', 'https://github.com/Kotlin/kotlinx.serialization')
165 root.children().last() + pomConfig
166 }
Leonid Startseva5873932017-08-09 11:36:01 +0300167 }
Leonid Startsev08d3ca02017-07-26 15:16:23 +0300168 }
169 }
Leonid Startsev1e737f22017-09-14 13:19:32 +0300170
Leonid Startsevbae49f92018-05-03 19:57:01 +0300171 apply plugin: 'com.jfrog.bintray'
Leonid Startsevc563d232018-05-07 20:29:23 +0300172
173 apply from: "${rootProject.rootDir}/gradle/bintray.gradle"
Leonid Startsev23dfc082018-10-19 14:34:14 +0300174
175 // Disable metadata for non-native modules
176 afterEvaluate {
177 publishing.publications.each { pub ->
Leonid Startsevb4656a02019-01-17 16:19:12 +0300178 pub.moduleDescriptorGenerator = null
Leonid Startsev23dfc082018-10-19 14:34:14 +0300179 }
180 }
Leonid Startsevda728dd2018-03-07 12:41:47 +0300181}