diff --git a/kotlin-native/build-tools/build.gradle.kts b/kotlin-native/build-tools/build.gradle.kts index 4990093178a..0640d44b3b1 100644 --- a/kotlin-native/build-tools/build.gradle.kts +++ b/kotlin-native/build-tools/build.gradle.kts @@ -8,12 +8,9 @@ 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") + kotlin groovy `kotlin-dsl` - `java-gradle-plugin` } buildscript { @@ -52,22 +49,25 @@ version = konanVersion repositories { maven("https://cache-redirector.jetbrains.com/maven-central") mavenCentral() + gradlePluginPortal() } dependencies { - compileOnly(gradleApi()) + api(gradleApi()) + + api(kotlinStdlib()) + implementation(project(":kotlin-gradle-plugin")) + implementation(project(":kotlin-reflect")) + implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") - 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:$slackApiVersion") { exclude(group = "com.google.code.gson", module = "gson") // Workaround for Gradle dependency resolution error } - val versionPropertiesFile = project.rootProject.projectDir.resolve("gradle/versions.properties") val versionProperties = Properties() - versionPropertiesFile.inputStream().use { propInput -> + project.rootProject.projectDir.resolve("gradle/versions.properties").inputStream().use { propInput -> versionProperties.load(propInput) } + implementation(commonDependency("com.google.code.gson:gson")) configurations.all { resolutionStrategy.eachDependency { if (requested.group == "com.google.code.gson" && requested.name == "gson") { @@ -82,12 +82,10 @@ dependencies { implementation("io.ktor:ktor-client-cio:$ktorVersion") api(project(":native:kotlin-native-utils")) - - // Located in /shared and always provided by the composite build. -// api("org.jetbrains.kotlin:kotlin-native-shared:$kotlinVersion") -// implementation("gradle.plugin.com.github.johnrengelman:shadow:$shadowVersion") -// -// implementation("org.jetbrains.kotlinx:kotlinx-metadata-klib:$metadataVersion") + api(project(":kotlin-native:shared")) + api(project(":kotlinx-metadata-klib")) + api(project(":kotlin-util-klib")) + implementation("gradle.plugin.com.github.johnrengelman:shadow:${rootProject.extra["versions.shadow"]}") } sourceSets["main"].withConvention(KotlinSourceSet::class) { @@ -98,8 +96,13 @@ val compileKotlin: KotlinCompile by tasks val compileGroovy: GroovyCompile by tasks compileKotlin.apply { - kotlinOptions.jvmTarget = "1.8" - kotlinOptions.freeCompilerArgs += "-Xskip-prerelease-check" + kotlinOptions { + jvmTarget = "1.8" + freeCompilerArgs += listOf( + "-Xskip-prerelease-check", + "-Xsuppress-version-warnings", + "-opt-in=kotlin.ExperimentalStdlibApi") + } } // Add Kotlin classes to a classpath for the Groovy compiler diff --git a/kotlin-native/build-tools/settings.gradle.kts b/kotlin-native/build-tools/settings.gradle.kts deleted file mode 100644 index 0f14aff9f2f..00000000000 --- a/kotlin-native/build-tools/settings.gradle.kts +++ /dev/null @@ -1,22 +0,0 @@ -pluginManagement { - val rootProperties = java.util.Properties().apply { - rootDir.resolve("../gradle.properties").reader().use(::load) - } - - repositories { - maven("https://cache-redirector.jetbrains.com/maven-central") - mavenCentral() - } - - resolutionStrategy { - eachPlugin { - if (requested.id.id == "kotlin") { - useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") - } - } - } -} - -rootProject.name = "kotlin-native-build-tools" - -includeBuild("../shared") diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/EndorsedLibraryInfo.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/EndorsedLibraryInfo.kt index 02e722e0c8e..27bbeb0dfc5 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/EndorsedLibraryInfo.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/EndorsedLibraryInfo.kt @@ -2,6 +2,7 @@ package org.jetbrains.kotlin import org.gradle.api.Project +@OptIn(ExperimentalStdlibApi::class) data class EndorsedLibraryInfo(val project: Project, val name: String) { val projectName: String diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FileCheckTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FileCheckTest.kt index 9149c32178d..8dfc93403f8 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FileCheckTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FileCheckTest.kt @@ -10,8 +10,6 @@ import org.gradle.api.DefaultTask import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.tasks.* -import org.jetbrains.kotlin.gradle.plugin.tasks.KonanCompileProgramTask -import org.jetbrains.kotlin.gradle.plugin.tasks.KonanCompileTask import org.jetbrains.kotlin.konan.target.* import java.io.File import java.nio.file.Path diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt index 62fb0f74b80..9a436b4d30a 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt @@ -28,6 +28,7 @@ import java.nio.file.Paths * @property swiftSources Swift-language test sources that use a given framework * @property frameworks names of frameworks */ +@OptIn(ExperimentalStdlibApi::class) open class FrameworkTest : DefaultTask(), KonanTestExecutable { @Input lateinit var swiftSources: List diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RunJvmTask.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RunJvmTask.kt index c1692c775c2..c9c215dc51e 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RunJvmTask.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RunJvmTask.kt @@ -111,7 +111,7 @@ open class RunJvmTask: JavaExec() { @TaskAction override fun exec() { assert(outputFileName != null) { "Output file name should be always set" } - predefinedArgs = args ?: emptyList() + predefinedArgs = args val filterArgs = filter.splitCommaSeparatedOption("-f") val filterRegexArgs = filterRegex.splitCommaSeparatedOption("-fr") when (repeatingType) { diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt index 8c524c73cac..be7ccffb6a7 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt @@ -2,6 +2,7 @@ * 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 file. */ +@file:OptIn(ExperimentalStdlibApi::class) package org.jetbrains.kotlin diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/BenchmarkingPlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/BenchmarkingPlugin.kt index 5f84ca7d9f3..5bd2b142fc5 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/BenchmarkingPlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/BenchmarkingPlugin.kt @@ -6,7 +6,6 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.artifacts.Dependency -import org.gradle.util.ConfigureUtil import org.jetbrains.kotlin.* import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget @@ -79,7 +78,7 @@ open class BenchmarkExtension @Inject constructor(val project: Project) { dependencies.action() fun dependencies(action: Closure<*>) { - ConfigureUtil.configure(action, dependencies) + project.configure(dependencies, action) } inner class BenchmarkDependencies { @@ -209,6 +208,7 @@ abstract class BenchmarkingPlugin: Plugin { protected open fun Project.collectCodeSize(applicationName: String) = getCodeSizeBenchmark(applicationName, nativeExecutable) + @OptIn(ExperimentalStdlibApi::class) protected open fun Project.configureKonanJsonTask(nativeTarget: KotlinNativeTarget): Task { return tasks.create("konanJsonReport") { group = BENCHMARKING_GROUP diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/CompileBenchmarkingPlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/CompileBenchmarkingPlugin.kt index d24c5ead107..d75b6bc82b2 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/CompileBenchmarkingPlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/CompileBenchmarkingPlugin.kt @@ -4,7 +4,6 @@ import groovy.lang.Closure import org.gradle.api.* import org.gradle.api.tasks.Delete import org.gradle.api.tasks.Exec -import org.gradle.util.ConfigureUtil import org.jetbrains.kotlin.* import javax.inject.Inject @@ -17,12 +16,12 @@ class BuildStep (private val _name: String): Named { } } -class BuildStepContainer(project: Project): NamedDomainObjectContainer by project.container(BuildStep::class.java) { +class BuildStepContainer(val project: Project): NamedDomainObjectContainer by project.container(BuildStep::class.java) { fun step(name: String, configure: Action) = maybeCreate(name).apply { configure.execute(this) } fun step(name: String, configure: Closure) = - step(name, ConfigureUtil.configureUsing(configure)) + step(name, { project.configure(this, configure) }) } open class CompileBenchmarkExtension @Inject constructor(val project: Project) { @@ -32,7 +31,7 @@ open class CompileBenchmarkExtension @Inject constructor(val project: Project) { var compilerOpts: List = emptyList() fun buildSteps(configure: Action): Unit = buildSteps.let { configure.execute(it) } - fun buildSteps(configure: Closure): Unit = buildSteps(ConfigureUtil.configureUsing(configure)) + fun buildSteps(configure: Closure): Unit = buildSteps { project.configure(this, configure) } } open class CompileBenchmarkingPlugin : Plugin { @@ -70,7 +69,7 @@ open class CompileBenchmarkingPlugin : Plugin { isIgnoreExitValue = true konanRun.dependsOn(this) doLast { - exitCodes[name] = execResult!!.exitValue + exitCodes[name] = executionResult.get().exitValue } } } diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/KotlinNativeBenchmarkingPlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/KotlinNativeBenchmarkingPlugin.kt index 1ec9172a7ec..e76f81dbf00 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/KotlinNativeBenchmarkingPlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/KotlinNativeBenchmarkingPlugin.kt @@ -68,7 +68,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() { val mainCompilation = kotlin.jvm().compilations.getByName("main") val runtimeDependencies = configurations.getByName(mainCompilation.runtimeDependencyConfigurationName) classpath(files(mainCompilation.output.allOutputs, runtimeDependencies)) - main = "MainKt" + mainClass.set("MainKt") group = BENCHMARKING_GROUP description = "Runs the benchmark for Kotlin/JVM." diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt index b79636db2d7..ac9cd51b4f7 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ExecClang import java.io.File import javax.inject.Inject import kotlinBuildProperties -import isNativeRuntimeDebugInfoEnabled import org.gradle.api.Project import org.gradle.api.model.ObjectFactory import org.gradle.process.ExecOperations @@ -133,7 +132,7 @@ abstract class CompileToBitcode @Inject constructor( val compilerFlags: List get() { val commonFlags = listOfNotNull( - "-gdwarf-2".takeIf { project.kotlinBuildProperties.isNativeRuntimeDebugInfoEnabled }, + "-gdwarf-2".takeIf { project.kotlinBuildProperties.getBoolean("kotlin.native.isNativeRuntimeDebugInfoEnabled", false) }, "-c", "-emit-llvm") + headersDirs.map { "-I$it" } val sanitizerFlags = when (sanitizer) { null -> listOf() diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt index 33efe43df47..ffeb4b04524 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt @@ -205,6 +205,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) { private const val COMPILATION_DATABASE_TASK_NAME = "CompilationDatabase" + @OptIn(ExperimentalStdlibApi::class) private val String.capitalized: String get() = replaceFirstChar { it.uppercase() } diff --git a/kotlin-native/shared/build.gradle.kts b/kotlin-native/shared/build.gradle.kts index de15561cedf..bf11d5988f5 100644 --- a/kotlin-native/shared/build.gradle.kts +++ b/kotlin-native/shared/build.gradle.kts @@ -15,7 +15,6 @@ */ @file:Suppress("UnstableApiUsage") -import org.jetbrains.kotlin.VersionGenerator import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet @@ -26,46 +25,31 @@ plugins { val rootBuildDirectory by extra(file("..")) apply(from="../gradle/loadRootProperties.gradle") -val konanVersion: String by extra +val kotlinVersion = project.bootstrapKotlinVersion group = "org.jetbrains.kotlin" -version = konanVersion repositories { maven("https://cache-redirector.jetbrains.com/maven-central") mavenCentral() } -// FIXME(ddol): KLIB-REFACTORING-CLEANUP: drop generation of KonanVersion! -val generateCompilerVersion by tasks.registering(VersionGenerator::class) {} - sourceSets["main"].withConvention(KotlinSourceSet::class) { kotlin.srcDir("src/main/kotlin") kotlin.srcDir("src/library/kotlin") - kotlin.srcDir(generateCompilerVersion.get().versionSourceDirectory) } tasks.withType { - dependsOn(generateCompilerVersion) kotlinOptions.jvmTarget = "1.8" kotlinOptions.freeCompilerArgs = listOf("-Xskip-prerelease-check") } -tasks.clean { - doFirst { - val versionSourceDirectory = generateCompilerVersion.get().versionSourceDirectory - if (versionSourceDirectory.exists()) { - versionSourceDirectory.delete() - } - } -} - tasks.jar { archiveFileName.set("shared.jar") } dependencies { - kotlinCompilerClasspath("org.jetbrains.kotlin:kotlin-compiler-embeddable:${project.bootstrapKotlinVersion}") + kotlinCompilerClasspath("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") diff --git a/settings.gradle b/settings.gradle index af3178ffdf6..3736ee5ade5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -784,4 +784,5 @@ if (buildProperties.isKotlinNativeEnabled) { include ":kotlin-native-compiler-embeddable" project(":kotlin-native-compiler-embeddable").projectDir = "$rootDir/kotlin-native/prepare/kotlin-native-embeddable-compiler" as File include ':kotlin-native:build-tools' + include ':kotlin-native:shared' }