Roman Elizarov | 26af919 | 2017-09-21 18:12:04 +0300 | [diff] [blame] | 1 | /* |
Leonid Startsev | 0a9f0d6 | 2018-07-13 12:12:09 +0300 | [diff] [blame] | 2 | * Copyright 2018 JetBrains s.r.o. |
Roman Elizarov | 26af919 | 2017-09-21 18:12:04 +0300 | [diff] [blame] | 3 | * |
| 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 Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 17 | buildscript { |
Leonid Startsev | c563d23 | 2018-05-07 20:29:23 +0300 | [diff] [blame] | 18 | def deployNative = property('native.deploy') == 'true' |
| 19 | |
Leonid Startsev | ca62091 | 2017-11-09 19:55:51 +0300 | [diff] [blame] | 20 | if (project.hasProperty("bootstrap")) { |
Leonid Startsev | 14b57df | 2018-06-13 23:18:22 +0300 | [diff] [blame] | 21 | ext.compilerVersion = property('kotlin.version.snapshot') |
| 22 | ext.librariesVersion = property('kotlin.version.snapshot') |
Leonid Startsev | 476b722 | 2018-06-26 17:06:14 +0300 | [diff] [blame] | 23 | ext.serializationPluginVersion = property('plugin.version.snapshot') |
Leonid Startsev | e4c5404 | 2018-10-31 18:31:32 +0300 | [diff] [blame] | 24 | ext.konanVersion = property('konan.version.snapshot') |
Leonid Startsev | 12a0003 | 2018-11-08 19:05:36 +0300 | [diff] [blame^] | 25 | ext["org.jetbrains.kotlin.native.home"] = System.getenv("KONAN_LOCAL_DIST") |
Leonid Startsev | ca62091 | 2017-11-09 19:55:51 +0300 | [diff] [blame] | 26 | } else { |
Leonid Startsev | 8642a1f | 2018-04-03 17:38:39 +0300 | [diff] [blame] | 27 | ext.compilerVersion = property('kotlin.version') |
| 28 | ext.librariesVersion = property('kotlin.version') |
Leonid Startsev | 14b57df | 2018-06-13 23:18:22 +0300 | [diff] [blame] | 29 | ext.serializationPluginVersion = property('plugin.version') |
Leonid Startsev | e4c5404 | 2018-10-31 18:31:32 +0300 | [diff] [blame] | 30 | ext.konanVersion = property('konan.version') |
Leonid Startsev | ca62091 | 2017-11-09 19:55:51 +0300 | [diff] [blame] | 31 | } |
Leonid Startsev | c1bb4d2 | 2018-10-23 18:50:39 +0300 | [diff] [blame] | 32 | ext.serializationCoordinates = "org.jetbrains.kotlin:kotlin-serialization" |
Leonid Startsev | 201ecd9 | 2018-09-12 12:47:15 +0300 | [diff] [blame] | 33 | ext.eapChannel = 'https://dl.bintray.com/kotlin/kotlin-dev' |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 34 | ext.serializationRepo = 'https://kotlin.bintray.com/kotlinx' |
Leonid Startsev | c1bb4d2 | 2018-10-23 18:50:39 +0300 | [diff] [blame] | 35 | 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 Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 43 | |
| 44 | repositories { |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 45 | jcenter() |
Leonid Startsev | 6fbc215 | 2017-09-21 16:18:32 +0300 | [diff] [blame] | 46 | mavenLocal() |
Vsevolod Tolstopyatov | e593b42 | 2018-06-28 11:23:49 +0300 | [diff] [blame] | 47 | maven { url "https://plugins.gradle.org/m2/" } |
Leonid Startsev | 7dd8ad7 | 2017-11-22 19:24:02 +0300 | [diff] [blame] | 48 | maven { url eapChannel } |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 49 | maven { url serializationRepo } |
Leonid Startsev | bae49f9 | 2018-05-03 19:57:01 +0300 | [diff] [blame] | 50 | maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" } |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | dependencies { |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 54 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$compilerVersion" |
Leonid Startsev | c652f29 | 2018-09-11 17:47:21 +0300 | [diff] [blame] | 55 | classpath "$serializationCoordinates:$serializationPluginVersion" |
Leonid Startsev | 477563f | 2018-10-31 16:19:27 +0300 | [diff] [blame] | 56 | classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$konanVersion" |
Leonid Startsev | bae49f9 | 2018-05-03 19:57:01 +0300 | [diff] [blame] | 57 | |
Leonid Startsev | ed87fbd | 2017-08-04 17:33:09 +0300 | [diff] [blame] | 58 | classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2' |
Leonid Startsev | bae49f9 | 2018-05-03 19:57:01 +0300 | [diff] [blame] | 59 | |
Leonid Startsev | c563d23 | 2018-05-07 20:29:23 +0300 | [diff] [blame] | 60 | 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 Startsev | bae49f9 | 2018-05-03 19:57:01 +0300 | [diff] [blame] | 66 | |
Vsevolod Tolstopyatov | e593b42 | 2018-06-28 11:23:49 +0300 | [diff] [blame] | 67 | 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 Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 70 | } |
| 71 | } |
| 72 | |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 73 | ext { |
| 74 | libraries = [ |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 75 | 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 Startsev | 8642a1f | 2018-04-03 17:38:39 +0300 | [diff] [blame] | 79 | kotlin_test_junit: "org.jetbrains.kotlin:kotlin-test-junit:$librariesVersion", |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 80 | kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$librariesVersion", |
Leonid Startsev | 7dd8ad7 | 2017-11-22 19:24:02 +0300 | [diff] [blame] | 81 | kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$librariesVersion", |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 82 | kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$librariesVersion", |
| 83 | kotlin_reflect: "org.jetbrains.kotlin:kotlin-reflect:$librariesVersion", |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 84 | ] |
| 85 | } |
| 86 | |
| 87 | allprojects { |
| 88 | group 'org.jetbrains.kotlinx' |
Leonid Startsev | 51114eb | 2018-07-13 16:00:18 +0300 | [diff] [blame] | 89 | version property('library.version') |
Leonid Startsev | 476b722 | 2018-06-26 17:06:14 +0300 | [diff] [blame] | 90 | |
| 91 | if (project.hasProperty("bootstrap")) { |
| 92 | version = version + '-SNAPSHOT' |
| 93 | } |
Leonid Startsev | 84062e1 | 2017-09-25 16:41:38 +0300 | [diff] [blame] | 94 | |
| 95 | repositories { |
| 96 | jcenter() |
| 97 | mavenLocal() |
Leonid Startsev | aee4fc2 | 2018-08-07 14:42:28 +0300 | [diff] [blame] | 98 | maven { url eapChannel } |
| 99 | maven { url serializationRepo } |
Leonid Startsev | 84062e1 | 2017-09-25 16:41:38 +0300 | [diff] [blame] | 100 | } |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 101 | } |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 102 | |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 103 | apply plugin: 'kotlin' |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 104 | |
Leonid Startsev | 1c35d91 | 2017-10-04 12:26:43 +0300 | [diff] [blame] | 105 | subprojects { |
Leonid Startsev | 0a9f0d6 | 2018-07-13 12:12:09 +0300 | [diff] [blame] | 106 | if (project.name.contains("native")) return |
Leonid Startsev | bae49f9 | 2018-05-03 19:57:01 +0300 | [diff] [blame] | 107 | |
Leonid Startsev | d79fb1f | 2017-09-15 18:02:59 +0300 | [diff] [blame] | 108 | apply plugin: 'kotlinx-serialization' |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 109 | |
Leonid Startsev | c1bb4d2 | 2018-10-23 18:50:39 +0300 | [diff] [blame] | 110 | 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 Startsev | 133194c | 2018-07-13 12:58:36 +0300 | [diff] [blame] | 118 | if (project.name.contains("benchmark")) return |
| 119 | |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 120 | apply plugin: 'maven-publish' |
Leonid Startsev | ed87fbd | 2017-08-04 17:33:09 +0300 | [diff] [blame] | 121 | |
Leonid Startsev | d79fb1f | 2017-09-15 18:02:59 +0300 | [diff] [blame] | 122 | def varintName = "" |
| 123 | |
| 124 | if (project.name == "jvm") { |
| 125 | varintName = "${rootProject.name}" |
| 126 | } else { |
| 127 | varintName = "${rootProject.name}-${project.name}" |
| 128 | } |
Leonid Startsev | a587393 | 2017-08-09 11:36:01 +0300 | [diff] [blame] | 129 | |
Leonid Startsev | ef12538 | 2017-09-22 16:50:39 +0300 | [diff] [blame] | 130 | afterEvaluate { |
| 131 | task sourceJar(type: Jar, dependsOn: classes) { |
| 132 | classifier 'sources' |
| 133 | from sourceSets.main.kotlin |
Leonid Startsev | 8818540 | 2018-02-01 16:03:25 +0300 | [diff] [blame] | 134 | 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 Startsev | ef12538 | 2017-09-22 16:50:39 +0300 | [diff] [blame] | 140 | } |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 141 | } |
Leonid Startsev | a587393 | 2017-08-09 11:36:01 +0300 | [diff] [blame] | 142 | |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 143 | tasks.withType(Jar) { |
| 144 | archivesBaseName = varintName |
| 145 | } |
Leonid Startsev | a587393 | 2017-08-09 11:36:01 +0300 | [diff] [blame] | 146 | |
Leonid Startsev | fa9e920 | 2018-10-18 17:13:44 +0300 | [diff] [blame] | 147 | apply from: "${rootProject.rootDir}/gradle/mavenMetadata.gradle" |
| 148 | |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 149 | publishing { |
| 150 | publications { |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 151 | mavenProject(MavenPublication) { |
Leonid Startsev | 00dd4f5 | 2017-08-23 16:09:21 +0300 | [diff] [blame] | 152 | from components.java |
| 153 | groupId project.group |
| 154 | artifactId varintName |
| 155 | version project.version |
| 156 | |
| 157 | artifact sourceJar { |
| 158 | classifier "sources" |
| 159 | } |
Leonid Startsev | fa9e920 | 2018-10-18 17:13:44 +0300 | [diff] [blame] | 160 | 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 Startsev | a587393 | 2017-08-09 11:36:01 +0300 | [diff] [blame] | 169 | } |
Leonid Startsev | 08d3ca0 | 2017-07-26 15:16:23 +0300 | [diff] [blame] | 170 | } |
| 171 | } |
Leonid Startsev | 1e737f2 | 2017-09-14 13:19:32 +0300 | [diff] [blame] | 172 | |
Leonid Startsev | bae49f9 | 2018-05-03 19:57:01 +0300 | [diff] [blame] | 173 | apply plugin: 'com.jfrog.bintray' |
Leonid Startsev | c563d23 | 2018-05-07 20:29:23 +0300 | [diff] [blame] | 174 | |
| 175 | apply from: "${rootProject.rootDir}/gradle/bintray.gradle" |
Leonid Startsev | 23dfc08 | 2018-10-19 14:34:14 +0300 | [diff] [blame] | 176 | |
| 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 Startsev | da728dd | 2018-03-07 12:41:47 +0300 | [diff] [blame] | 186 | } |