• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5import org.jetbrains.kotlin.konan.target.HostManager
6
7buildscript {
8    /*
9     * These property group is used to build kotlinx.atomicfu against Kotlin compiler snapshot.
10     * How does it work:
11     * When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version,
12     * Additionally, mavenLocal and Sonatype snapshots are added to repository list (the former is required for AFU and public
13     * the latter is required for compiler snapshots).
14     * DO NOT change the name of these properties without adapting kotlinx.train build chain.
15     */
16    def prop = rootProject.properties['build_snapshot_train']
17    ext.build_snapshot_train = prop != null && prop != ""
18    if (build_snapshot_train) {
19        ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
20        if (kotlin_version == null) {
21            throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
22        }
23        repositories {
24            mavenLocal()
25            maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
26        }
27    }
28    // These two flags are enabled in train builds for JVM IR compiler testing
29    ext.jvm_ir_enabled = rootProject.properties['enable_jvm_ir'] != null
30    ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null
31
32    repositories {
33        jcenter()
34        maven { url "https://plugins.gradle.org/m2/" }
35        // Future replacement for kotlin-dev, with cache redirector
36        maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
37        maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
38    }
39
40    dependencies {
41        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
42        classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
43    }
44}
45
46allprojects {
47    // the only place where HostManager could be instantiated
48    project.ext.hostManager = new HostManager()
49    if (build_snapshot_train) {
50        kotlin_version = rootProject.properties['kotlin_snapshot_version']
51        repositories {
52            mavenLocal()
53            maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
54        }
55    }
56
57    println "Using Kotlin $kotlin_version for project $it"
58    repositories {
59        jcenter()
60        // Future replacement for kotlin-dev, with cache redirector
61        maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
62        maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
63    }
64
65    def deployVersion = properties['DeployVersion']
66    if (deployVersion != null) version = deployVersion
67
68    // 'atomicfu-native' check is a kludge so that existing YouTrack config works, todo: remove
69    if (project != rootProject && project.name != 'atomicfu-native') {
70        apply from: rootProject.file("gradle/publishing.gradle")
71    }
72
73    // This fixes "org.gradle.jvm.version" in Gradle metadata
74    plugins.withType(JavaPlugin) {
75        java {
76            sourceCompatibility = JavaVersion.VERSION_1_8
77            targetCompatibility = JavaVersion.VERSION_1_8
78        }
79    }
80}
81
82println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
83if (build_snapshot_train) {
84    afterEvaluate {
85        println "Manifest of kotlin-compiler-embeddable.jar for atomicfu"
86        configure(subprojects.findAll { it.name == "atomicfu" }) {
87            configurations.matching { it.name == "kotlinCompilerClasspath" }.all {
88                resolvedConfiguration.getFiles().findAll { it.name.contains("kotlin-compiler-embeddable") }.each {
89                    def manifest = zipTree(it).matching {
90                        include 'META-INF/MANIFEST.MF'
91                    }.getFiles().first()
92
93                    manifest.readLines().each {
94                        println it
95                    }
96                }
97            }
98        }
99    }
100}
101
102// main deployment task
103task deploy(dependsOn: getTasksByName("publish", true) + getTasksByName("publishNpm", true))
104