Build: Replace buildSrc with a separate included build (#3104)

Gradle doesn't allow us to substitute dependencies of buildSrc
with artifacts provided by a composite build. But our buildSrc
depends on kotlin-native-utils provided by the Big Kotlin repo.
Thus we cannot make changes in kotlin-native-utils and use them
in buildSrc during a development process.

This patch fixes the issue by transforming buildSrc into a separate
included build.
This commit is contained in:
Ilya Matveev
2019-06-27 17:20:53 +07:00
committed by GitHub
parent e9685e8d17
commit 127ba155c7
44 changed files with 151 additions and 247 deletions
+82
View File
@@ -0,0 +1,82 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.Properties
plugins {
// We explicitly configure versions of plugins in settings.gradle.kts.
// due to https://github.com/gradle/gradle/issues/1697.
id("kotlin")
id("kotlinx-serialization")
groovy
`java-gradle-plugin`
}
val rootProperties = Properties().apply {
rootDir.resolve("../gradle.properties").reader().use(::load)
}
val kotlinVersion: String by rootProperties
val kotlinCompilerRepo: String by rootProperties
val buildKotlinVersion: String by rootProperties
val buildKotlinCompilerRepo: String by rootProperties
val konanVersion: String by rootProperties
group = "org.jetbrains.kotlin"
version = konanVersion
repositories {
maven(kotlinCompilerRepo)
maven(buildKotlinCompilerRepo)
maven("https://cache-redirector.jetbrains.com/maven-central")
maven("https://kotlin.bintray.com/kotlinx")
}
dependencies {
compileOnly(gradleApi())
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("com.ullink.slack:simpleslackapi:1.2.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0")
implementation("io.ktor:ktor-client-auth:1.2.1")
implementation("io.ktor:ktor-client-core:1.2.1")
implementation("io.ktor:ktor-client-cio:1.2.1")
api("org.jetbrains.kotlin:kotlin-native-utils:$kotlinVersion")
// Located in <repo root>/shared and always provided by the composite build.
api("org.jetbrains.kotlin:kotlin-native-shared:$konanVersion")
}
sourceSets["main"].withConvention(KotlinSourceSet::class) {
kotlin.srcDir("$projectDir/../tools/benchmarks/shared/src")
}
gradlePlugin {
plugins {
create("benchmarkPlugin") {
id = "benchmarking"
implementationClass = "org.jetbrains.kotlin.benchmark.BenchmarkingPlugin"
}
create("compileBenchmarking") {
id = "compile-benchmarking"
implementationClass = "org.jetbrains.kotlin.benchmark.CompileBenchmarkingPlugin"
}
}
}
val compileKotlin: KotlinCompile by tasks
val compileGroovy: GroovyCompile by tasks
// Add Kotlin classes to a classpath for the Groovy compiler
compileGroovy.apply {
classpath += project.files(compileKotlin.destinationDir)
dependsOn(compileKotlin)
}
+28
View File
@@ -0,0 +1,28 @@
pluginManagement {
val rootProperties = java.util.Properties().apply {
rootDir.resolve("../gradle.properties").reader().use(::load)
}
val kotlinCompilerRepo: String by rootProperties
val kotlinVersion by rootProperties
repositories {
maven(kotlinCompilerRepo)
maven("https://cache-redirector.jetbrains.com/maven-central")
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "kotlin") {
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
if (requested.id.id == "kotlinx-serialization") {
useModule("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
}
}
}
}
rootProject.name = "kotlin-native-build-tools"
includeBuild("../shared")
+4
View File
@@ -25,10 +25,14 @@ buildscript {
repositories {
maven { url kotlinCompilerRepo }
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://cache-redirector.jetbrains.com/maven-central" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-utils:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
classpath "org.jetbrains.kotlin:kotlin-native-build-tools:$konanVersion"
}
}
import org.jetbrains.kotlin.konan.*
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
val rootBuildDirectory = "$rootDir/.."
extra["rootBuildDirectory"] = rootBuildDirectory
apply(from = "$rootBuildDirectory/gradle/loadRootProperties.gradle")
apply(from = "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle")
}
val buildKotlinCompilerRepo: String by project
val kotlinCompilerRepo: String by project
val repos = listOf(
buildKotlinCompilerRepo,
kotlinCompilerRepo,
"https://cache-redirector.jetbrains.com/maven-central",
"https://kotlin.bintray.com/kotlinx"
)
allprojects {
repositories {
repos.forEach { repoUrl ->
maven { setUrl(repoUrl) }
}
}
}
dependencies {
runtime(project(":plugins"))
}
-74
View File
@@ -1,74 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'groovy'
apply plugin: 'kotlin'
buildscript {
ext.rootBuildDirectory = "$rootDir/.."
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
dependencies{
classpath "org.jetbrains.kotlin:kotlin-serialization:$buildKotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlinx-serialization'
apply plugin: 'java-gradle-plugin'
/* don't use repositories: gradle will ignore it anyway, but may confuse gradle build engineer, see outer build.gradle */
dependencies {
compile gradleApi()
compile localGroovy()
compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$buildKotlinVersion"
compile group: 'com.ullink.slack', name: 'simpleslackapi', version: '1.2.0'
// An artifact from the included build 'shared' cannot be used here due to https://github.com/gradle/gradle/issues/3768
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin"
compile project(':shared')
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0"
implementation 'io.ktor:ktor-client-auth:1.2.1'
implementation 'io.ktor:ktor-client-core:1.2.1'
implementation 'io.ktor:ktor-client-cio:1.2.1'
}
sourceSets.main.kotlin.srcDirs = ["src", "$projectDir/../../tools/benchmarks/shared/src"]
rootProject.dependencies {
runtime project(path)
}
compileGroovy {
// Add Kotlin classes to a classpath for the Groovy compiler
classpath += project.files(compileKotlin.destinationDir)
}
gradlePlugin {
plugins {
benchmarkPlugin {
id = "benchmarking"
implementationClass = "org.jetbrains.kotlin.benchmark.BenchmarkingPlugin"
}
compileBenchmarking {
id = "compile-benchmarking"
implementationClass = "org.jetbrains.kotlin.benchmark.CompileBenchmarkingPlugin"
}
}
}
-18
View File
@@ -1,18 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
include(":plugins")
include(":shared")
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
ext {
gradleProperties = new Properties()
gradleProperties.load(new FileInputStream("$projectDir/../../gradle.properties"))
buildKotlinVersion = gradleProperties."buildKotlinVersion"
buildKotlinCompilerRepo = gradleProperties."buildKotlinCompilerRepo"
}
apply from: '../../gradle/kotlinGradlePlugin.gradle'
}
apply plugin: 'kotlin'
// We reuse the source code from the Project in buildSrc.
sourceSets.main.kotlin.srcDirs = ["$projectDir/../../shared/src/main/kotlin"]
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion"
compile "org.jetbrains.kotlin:kotlin-native-utils:$kotlinVersion"
}
rootProject.dependencies {
runtime project(path)
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
+1 -6
View File
@@ -1,5 +1,5 @@
#
# Copyright 2010-2017 JetBrains s.r.o.
# Copyright 2010-2019 JetBrains s.r.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -26,8 +26,3 @@ testKotlinCompilerVersion=1.3.50-dev-1455
konanVersion=1.3.50
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.workers.max=4
#kotlinProjectPath=/Users/jetbrains/IdeaProjects/kotlin
#sharedProjectPath=/Users/jetbrains/IdeaProjects/kotlin-native-shared
#kotlinProjectPath=/Users/jetbrains/kotlin-native/kotlin
#sharedProjectPath=/Users/jetbrains/kotlin-native/kotlin-native-shared/kotlin-native-shared
+5 -6
View File
@@ -1,13 +1,12 @@
if (!hasProperty('buildKotlinVersion')) {
throw new GradleException('Please ensure the "buildKotlinVersion" property is defined before applying this script.')
}
def properties = ['buildKotlinVersion', 'buildKotlinCompilerRepo', 'kotlinVersion', 'kotlinCompilerRepo']
if (!hasProperty('buildKotlinCompilerRepo')) {
throw new GradleException('Please ensure the "buildKotlinCompilerRepo" property is defined before applying this script.')
for (prop in properties) {
if (!hasProperty(prop)) {
throw new GradleException("Please ensure the '$prop' property is defined before applying this script.")
}
}
project.buildscript.repositories {
maven {
url buildKotlinCompilerRepo
}
+3 -11
View File
@@ -4,24 +4,16 @@ import org.jetbrains.kotlin.BuildRegister
import org.jetbrains.kotlin.MPPTools
buildscript {
ext.rootBuildDirectory = file('..')
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootProject.projectDir/gradle/kotlinGradlePlugin.gradle"
repositories {
maven {
url 'https://cache-redirector.jetbrains.com/jcenter'
}
maven {
url kotlinCompilerRepo
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
def rootBuildDirectory = rootProject.projectDir
task konanRun {
subprojects.each {
dependsOn it.getTasksByName('konanRun', true)[0]
+1 -11
View File
@@ -3,22 +3,12 @@ import org.jetbrains.kotlin.PlatformInfo
import org.jetbrains.kotlin.RunJvmTask
buildscript {
ext.rootBuildDirectory = file('../..')
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootProject.projectDir/gradle/kotlinGradlePlugin.gradle"
repositories {
maven {
url 'https://cache-redirector.jetbrains.com/jcenter'
}
maven {
url kotlinCompilerRepo
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
+1 -12
View File
@@ -6,22 +6,11 @@ import org.jetbrains.kotlin.UtilsKt
import java.nio.file.Paths
buildscript {
ext.rootBuildDirectory = file('../..')
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootProject.projectDir/gradle/kotlinGradlePlugin.gradle"
repositories {
maven {
url 'https://cache-redirector.jetbrains.com/jcenter'
}
maven {
url kotlinCompilerRepo
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
+15 -8
View File
@@ -4,8 +4,6 @@ import org.jetbrains.kotlin.konan.util.*
import static org.jetbrains.kotlin.konan.util.VisibleNamedKt.getVisibleName
apply plugin: 'konan'
buildscript {
repositories {
maven {
@@ -14,18 +12,27 @@ buildscript {
maven {
url buildKotlinCompilerRepo
}
maven {
url kotlinCompilerRepo
}
maven {
url "https://kotlin.bintray.com/kotlinx"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$gradlePluginVersion"
classpath "org.jetbrains.kotlin:kotlin-native-build-tools:$konanVersion"
}
ext.konanHome = distDir.absolutePath
def jvmArguments = [project.findProperty("platformLibsJvmArgs") ?: "-Xmx6G", *HostManager.defaultJvmArgs]
ext.jvmArgs = jvmArguments.join(" ")
ext.setProperty("org.jetbrains.kotlin.native.home", konanHome)
ext.setProperty("konan.jvmArgs", jvmArgs)
}
// These properties are used by the 'konan' plugin, thus we set them before applying it.
ext.konanHome = distDir.absolutePath
def jvmArguments = [project.findProperty("platformLibsJvmArgs") ?: "-Xmx6G", *HostManager.defaultJvmArgs]
ext.jvmArgs = jvmArguments.join(" ")
ext.setProperty("org.jetbrains.kotlin.native.home", konanHome)
ext.setProperty("konan.jvmArgs", jvmArgs)
apply plugin: 'konan'
//#region Util functions.
private ArrayList<DefFile> targetDefFiles(KonanTarget target) {
+11 -13
View File
@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.PlatformInfo
import org.jetbrains.kotlin.konan.target.HostManager
/*
* Copyright 2010-2017 JetBrains s.r.o.
@@ -32,22 +30,19 @@ include ':common'
include ':backend.native:tests'
include ':backend.native:debugger-tests'
include ':utilities'
include ':performance'
include ':performance:ring'
include ':performance:cinterop'
include ':performance:helloworld'
include ':performance:videoplayer'
include ':performance:framework'
if (PlatformInfo.isAppleTarget(HostManager.host)) {
if (System.getProperty("os.name") == "Mac OS X") {
include ':performance:objcinterop'
include ':performance:swiftinterop'
}
include ':platformLibs'
includeBuild 'shared'
includeBuild 'extracted/konan.metadata'
includeBuild 'extracted/konan.serializer'
includeBuild 'tools/kotlin-native-gradle-plugin'
include ':platformLibs'
if (hasProperty("kotlinProjectPath")) {
include ':runtime:generator'
@@ -56,12 +51,15 @@ if (hasProperty("kotlinProjectPath")) {
substitute module('org.jetbrains.kotlin:kotlin-compiler') with project(':include:kotlin-compiler')
substitute module("org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinStdlibVersion") with project(':include:kotlin-stdlib-common-sources')
substitute module("org.jetbrains.kotlin:kotlin-stdlib-gen:$kotlinStdlibVersion") with project(':tools:kotlin-stdlib-gen')
substitute module("org.jetbrains.kotlin:kotlin-util-io:$kotlinVersion") with project(':kotlin-util-io')
substitute module("org.jetbrains.kotlin:kotlin-util-klib:$kotlinVersion") with project(':kotlin-util-klib')
substitute module("org.jetbrains.kotlin:kotlin-util-io") with project(':kotlin-util-io')
substitute module("org.jetbrains.kotlin:kotlin-util-klib") with project(':kotlin-util-klib')
substitute module("org.jetbrains.kotlin:kotlin-native-utils") with project(':kotlin-native:kotlin-native-utils')
}
}
}
if (hasProperty("sharedProjectPath")) {
includeBuild(sharedProjectPath)
}
includeBuild 'shared'
includeBuild 'build-tools'
includeBuild 'extracted/konan.metadata'
includeBuild 'extracted/konan.serializer'
includeBuild 'tools/kotlin-native-gradle-plugin'