blob: 12f531d6e54f92d2f8cb318175f32f9df10c8b0d [file] [log] [blame]
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
import org.jetbrains.kotlin.konan.target.HostManager
buildscript {
/*
* These property group is used to build kotlinx.atomicfu against Kotlin compiler snapshot.
* How does it work:
* When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version,
* Additionally, mavenLocal and Sonatype snapshots are added to repository list (the former is required for AFU and public
* the latter is required for compiler snapshots).
* DO NOT change the name of these properties without adapting kotlinx.train build chain.
*/
def prop = rootProject.properties['build_snapshot_train']
ext.build_snapshot_train = prop != null && prop != ""
if (build_snapshot_train) {
ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
if (kotlin_version == null) {
throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
}
repositories {
mavenLocal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
// These two flags are enabled in train builds for JVM IR compiler testing
ext.jvm_ir_enabled = rootProject.properties['enable_jvm_ir'] != null
ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null
repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
// Future replacement for kotlin-dev, with cache redirector
maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
maven {
url "https://kotlin.bintray.com/kotlin-dev"
credentials {
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') ?: ""
password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') ?: ""
}
}
maven { url "https://kotlin.bintray.com/kotlin-eap" }
maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" }
maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
}
}
allprojects {
// the only place where HostManager could be instantiated
project.ext.hostManager = new HostManager()
if (build_snapshot_train) {
kotlin_version = rootProject.properties['kotlin_snapshot_version']
repositories {
mavenLocal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
println "Using Kotlin $kotlin_version for project $it"
repositories {
jcenter()
maven { url "https://kotlin.bintray.com/kotlin-eap" }
// Future replacement for kotlin-dev, with cache redirector
maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
maven {
url "https://kotlin.bintray.com/kotlin-dev"
credentials {
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') ?: ""
password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') ?: ""
}
}
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
}
def deployVersion = properties['DeployVersion']
if (deployVersion != null) version = deployVersion
// 'atomicfu-native' check is a kludge so that existing YouTrack config works, todo: remove
if (project != rootProject && project.name != 'atomicfu-native') {
apply from: rootProject.file("gradle/publishing.gradle")
}
// This fixes "org.gradle.jvm.version" in Gradle metadata
plugins.withType(JavaPlugin) {
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
}
println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
if (build_snapshot_train) {
afterEvaluate {
println "Manifest of kotlin-compiler-embeddable.jar for atomicfu"
configure(subprojects.findAll { it.name == "atomicfu" }) {
configurations.matching { it.name == "kotlinCompilerClasspath" }.all {
resolvedConfiguration.getFiles().findAll { it.name.contains("kotlin-compiler-embeddable") }.each {
def manifest = zipTree(it).matching {
include 'META-INF/MANIFEST.MF'
}.getFiles().first()
manifest.readLines().each {
println it
}
}
}
}
}
}
// main deployment task
task deploy(dependsOn: getTasksByName("publish", true) + getTasksByName("publishNpm", true))