summaryrefslogtreecommitdiff
path: root/build.gradle.old
blob: 94ec4a9e19fee8142ba370923ebe8771fddb17a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
 * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

buildscript {
    def deployNative = property('native.deploy') == 'true'

    if (project.hasProperty("bootstrap")) {
        ext.compilerVersion = property('kotlin.version.snapshot')
        ext.librariesVersion = property('kotlin.version.snapshot')
        ext.serializationPluginVersion = property('plugin.version.snapshot')
        ext.konanVersion = property('konan.version.snapshot')
        ext["org.jetbrains.kotlin.native.home"] = System.getenv("KONAN_LOCAL_DIST")
    } else {
        ext.compilerVersion = property('kotlin.version')
        ext.librariesVersion = property('kotlin.version')
        ext.serializationPluginVersion = property('plugin.version')
        ext.konanVersion = property('konan.version')
    }
    ext.serializationVersion = property('library.version')
    ext.serializationCoordinates = "org.jetbrains.kotlin:kotlin-serialization"
    ext.tcChannel = 'https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:2082584/artifacts/content/maven'
    ext.devChannel = 'https://kotlin.bintray.com/kotlin-dev'
    ext.serializationRepo = 'https://kotlin.bintray.com/kotlinx'
    ext.experimentalsEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
                                "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
    ]

    ext.experimentalsInTestEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
                                      "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
                                      "-Xuse-experimental=kotlinx.serialization.ImplicitReflectionSerializer",
                                      "-Xuse-experimental=kotlinx.serialization.UnstableDefault"
    ]

    repositories {
        mavenLocal()
        maven { url tcChannel }
        maven { url devChannel }
        maven { url serializationRepo }
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
        jcenter()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$compilerVersion"
        classpath "$serializationCoordinates:$serializationPluginVersion"
        classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$konanVersion"

        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2'

        // Custom bintray plugin to publish with Gradle Metadata
        classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4-jetbrains-3"

        classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
        classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
        classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
    }
}

ext {
    libraries = [
            kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$librariesVersion",
            kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$librariesVersion",
            kotlin_stdlib_js: "org.jetbrains.kotlin:kotlin-stdlib-js:$librariesVersion",
            kotlin_test: "org.jetbrains.kotlin:kotlin-test:$librariesVersion",
            kotlin_test_junit: "org.jetbrains.kotlin:kotlin-test-junit:$librariesVersion",
            kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$librariesVersion",
            kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$librariesVersion",
            kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$librariesVersion",
            kotlin_reflect: "org.jetbrains.kotlin:kotlin-reflect:$librariesVersion",
    ]
}

allprojects {
    group 'org.jetbrains.kotlinx'
    version serializationVersion

    if (project.hasProperty("bootstrap")) {
        version = version + '-SNAPSHOT'
    }

    repositories {
        mavenLocal()
        maven { url tcChannel }
        maven { url devChannel }
        maven { url serializationRepo }
        jcenter()
    }
}

apply plugin: 'kotlin'

subprojects {
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name == 'kotlinx-serialization-unshaded') {
                details.useVersion serializationPluginVersion
                details.because 'use not bundled one'
            }
        }
    }

    if (project.name.contains("native")) return

    apply plugin: 'kotlinx-serialization'

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
        if (task.name.contains("Test") || task.name.contains("Jmh")) {
            task.kotlinOptions.freeCompilerArgs += experimentalsInTestEnabled
        } else {
            task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
        }
    }

    if (project.name.contains("benchmark")) return

    apply plugin: 'maven-publish'

    def varintName = ""

    if (project.name == "jvm") {
        varintName = "${rootProject.name}"
    } else {
        varintName = "${rootProject.name}-${project.name}"
    }

    afterEvaluate {
        task sourceJar(type: Jar, dependsOn: classes) {
            classifier 'sources'
            from sourceSets.main.kotlin
            if (project.name == "jvm" || project.name == "js") {
                duplicatesStrategy = "exclude"
                def platformSrc = sourceSets.main.kotlin
                def commonSrc = project(':common').sourceSets.main.kotlin
                from(platformSrc + commonSrc)
            }
        }
    }

    tasks.withType(Jar) {
        archivesBaseName = varintName
    }

    apply from: "${rootProject.rootDir}/gradle/mavenMetadata.gradle"

    publishing {
        publications {
            mavenProject(MavenPublication) {
                from components.java
                groupId project.group
                artifactId varintName
                version project.version

                artifact sourceJar {
                    classifier "sources"
                }
                pom.withXml {
                    def root = it.asNode()
                    // NOTE: Don't try to move top-level things (especially "description") to the pomConfig block
                    //       because they would resolve incorrectly to top-level project properties in Gradle/Groovy
                    root.appendNode('name', varintName)
                    root.appendNode('description', 'Kotlin multiplatform serialization runtime library')
                    root.appendNode('url', 'https://github.com/Kotlin/kotlinx.serialization')
                    root.children().last() + pomConfig
                }
            }
        }
    }

    apply plugin: 'com.jfrog.bintray'

    apply from: "${rootProject.rootDir}/gradle/bintray.gradle"

    // Disable metadata for non-native modules
    afterEvaluate {
        publishing.publications.each { pub ->
            pub.moduleDescriptorGenerator = null
        }
    }
}