[Build] Migrate most of the build logic from Project.buildDir usage

It's going to be deprecated in Gradle 8.3

There's currently no way to pass a `org.gradle.api.provider.Provider` to the JavaExec.systemProperty or Test.systemProperty. There's a workaround using `org.gradle.process.CommandLineArgumentProvider`, but I intentionally don't rework these calls as Gradle is going to allow passing providers to configure system properties: https://github.com/gradle/gradle/issues/12247#issuecomment-1568427242
^KTI-1473 In Progress
This commit is contained in:
Alexander.Likhachev
2023-10-11 22:42:51 +02:00
committed by Space Team
parent b784544f8d
commit a19bd2ed2e
69 changed files with 328 additions and 306 deletions
+16 -7
View File
@@ -73,7 +73,7 @@ tasks.withType<Zip>().matching { it.name == "mainBenchmarkJar" }.configureEach {
val benchmarkTasks = listOf("mainBenchmark", "mainFirBenchmark", "mainNiBenchmark") val benchmarkTasks = listOf("mainBenchmark", "mainFirBenchmark", "mainNiBenchmark")
tasks.withType<JavaExec>().matching { it.name in benchmarkTasks }.configureEach { tasks.withType<JavaExec>().matching { it.name in benchmarkTasks }.configureEach {
dependsOn(":createIdeaHomeForTests") dependsOn(":createIdeaHomeForTests")
systemProperty("idea.home.path", ideaHomePathForTests().canonicalPath) systemProperty("idea.home.path", ideaHomePathForTests().get().asFile.canonicalPath)
systemProperty("idea.use.native.fs.for.win", false) systemProperty("idea.use.native.fs.for.win", false)
} }
@@ -81,17 +81,26 @@ tasks.register<JavaExec>("runBenchmark") {
dependsOn(":createIdeaHomeForTests") dependsOn(":createIdeaHomeForTests")
// jmhArgs example: -PjmhArgs='CommonCalls -p size=500 -p isIR=true -p useNI=true -f 1' // jmhArgs example: -PjmhArgs='CommonCalls -p size=500 -p isIR=true -p useNI=true -f 1'
val jmhArgs = if (project.hasProperty("jmhArgs")) project.property("jmhArgs").toString() else "" val jmhArgs = project.providers.gradleProperty("jvmArgs")
val resultFilePath = "$buildDir/benchmarks/jmh-result.json" val resultFilePath = project.layout.buildDirectory.file("benchmarks/jmh-result.json")
val ideaHome = ideaHomePathForTests().canonicalPath val ideaHome = ideaHomePathForTests()
val benchmarkJarPath = "$buildDir/benchmarks/main/jars/benchmarks.jar" val benchmarkJarPath = project.layout.buildDirectory.file("benchmarks/main/jars/benchmarks.jar")
args = mutableListOf("-Didea.home.path=$ideaHome", benchmarkJarPath, "-rf", "json", "-rff", resultFilePath) + jmhArgs.split("\\s".toRegex()) argumentProviders.add {
listOf(
"-Didea.home.path=${ideaHome.get().asFile.canonicalPath}",
benchmarkJarPath.get().asFile.toString(),
"-rf",
"json",
"-rff",
resultFilePath.get().asFile.toString(),
) + jmhArgs.map { it.split("\\s".toRegex()) }.orElse(emptyList()).get()
}
mainClass.set("-jar") mainClass.set("-jar")
doLast { doLast {
if (project.kotlinBuildProperties.isTeamcityBuild) { if (project.kotlinBuildProperties.isTeamcityBuild) {
val jsonArray = com.google.gson.JsonParser.parseString(File(resultFilePath).readText()).asJsonArray val jsonArray = com.google.gson.JsonParser.parseString(resultFilePath.get().asFile.readText()).asJsonArray
jsonArray.forEach { jsonArray.forEach {
val benchmark = it.asJsonObject val benchmark = it.asJsonObject
// remove unnecessary name parts from string like this "org.jetbrains.kotlin.benchmarks.CommonCallsBenchmark.benchmark" // remove unnecessary name parts from string like this "org.jetbrains.kotlin.benchmarks.CommonCallsBenchmark.benchmark"
+7 -4
View File
@@ -692,14 +692,17 @@ tasks.register("createIdeaHomeForTests") {
val intellijSdkVersion = rootProject.extra["versions.intellijSdk"] val intellijSdkVersion = rootProject.extra["versions.intellijSdk"]
outputs.file(ideaBuildNumberFileForTests) outputs.file(ideaBuildNumberFileForTests)
doFirst { doFirst {
ideaBuildNumberFileForTests.parentFile.mkdirs() with(ideaBuildNumberFileForTests.get().asFile) {
ideaBuildNumberFileForTests.writeText("IC-$intellijSdkVersion") parentFile.mkdirs()
writeText("IC-$intellijSdkVersion")
}
} }
} }
tasks { tasks {
named<Delete>("clean") { named<Delete>("clean") {
delete += setOf("$buildDir/repo", distDir) delete(distDir)
delete(layout.buildDirectory.dir("repo"))
} }
register<Delete>("cleanupArtifacts") { register<Delete>("cleanupArtifacts") {
@@ -1046,7 +1049,7 @@ val zipCompilerWithSignature by secureZipTask(zipCompiler)
configure<IdeaModel> { configure<IdeaModel> {
module { module {
excludeDirs = files( excludeDirs = files(
project.buildDir, project.layout.buildDirectory,
commonLocalDataDir, commonLocalDataDir,
".gradle", ".gradle",
"dependencies", "dependencies",
+1 -1
View File
@@ -55,7 +55,7 @@ projectTest(
defineJDKEnvVariables = listOf(JdkMajorVersion.JDK_1_8, JdkMajorVersion.JDK_11_0, JdkMajorVersion.JDK_17_0) defineJDKEnvVariables = listOf(JdkMajorVersion.JDK_1_8, JdkMajorVersion.JDK_11_0, JdkMajorVersion.JDK_17_0)
) { ) {
dependsOn(":dist") dependsOn(":dist")
useJsIrBoxTests(version = version, buildDir = "$buildDir/") useJsIrBoxTests(version = version, buildDir = layout.buildDirectory)
workingDir = rootDir workingDir = rootDir
systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator)) systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator))
+1 -1
View File
@@ -68,7 +68,7 @@ fun Test.configureTest(configureJUnit: JUnitPlatformOptions.() -> Unit = {}) {
useJUnitPlatform { useJUnitPlatform {
configureJUnit() configureJUnit()
} }
useJsIrBoxTests(version = version, buildDir = "$buildDir/") useJsIrBoxTests(version = version, buildDir = layout.buildDirectory)
} }
@@ -43,12 +43,12 @@ sourceSets {
projectTest(parallel = true) { projectTest(parallel = true) {
workingDir = rootDir workingDir = rootDir
useJsIrBoxTests(version = version, buildDir = "$buildDir/") useJsIrBoxTests(version = version, buildDir = layout.buildDirectory)
} }
projectTest("testJvmICWithJdk11", parallel = true) { projectTest("testJvmICWithJdk11", parallel = true) {
workingDir = rootDir workingDir = rootDir
useJsIrBoxTests(version = version, buildDir = "$buildDir/") useJsIrBoxTests(version = version, buildDir = layout.buildDirectory)
filter { filter {
includeTestsMatching("org.jetbrains.kotlin.incremental.IncrementalK1JvmCompilerRunnerTestGenerated*") includeTestsMatching("org.jetbrains.kotlin.incremental.IncrementalK1JvmCompilerRunnerTestGenerated*")
includeTestsMatching("org.jetbrains.kotlin.incremental.IncrementalK2JvmCompilerRunnerTestGenerated*") includeTestsMatching("org.jetbrains.kotlin.incremental.IncrementalK2JvmCompilerRunnerTestGenerated*")
+1 -1
View File
@@ -31,7 +31,7 @@ sourceSets {
ant.importBuild("buildLexer.xml") ant.importBuild("buildLexer.xml")
ant.properties["builddir"] = buildDir.absolutePath ant.properties["builddir"] = layout.buildDirectory.get().asFile.absolutePath
tasks.findByName("lexer")!!.apply { tasks.findByName("lexer")!!.apply {
doFirst { doFirst {
+1 -1
View File
@@ -32,7 +32,7 @@ val testDataDir = project(":compiler").projectDir.resolve("testData/klib/dump-ab
projectTest(jUnitMode = JUnitMode.JUnit5) { projectTest(jUnitMode = JUnitMode.JUnit5) {
inputs.dir(testDataDir) inputs.dir(testDataDir)
outputs.dir("$buildDir/t") outputs.dir(layout.buildDirectory.dir("t"))
dependsOn(":dist") dependsOn(":dist")
workingDir = rootDir workingDir = rootDir
+22 -18
View File
@@ -1,5 +1,4 @@
import org.gradle.api.tasks.PathSensitivity.RELATIVE import org.gradle.api.tasks.PathSensitivity.RELATIVE
import java.io.File
plugins { plugins {
base base
@@ -13,9 +12,6 @@ val kotlinReflectJvm = fileFrom(rootDir, "libraries/stdlib/jvm/src/kotlin/reflec
val kotlinRangesCommon = fileFrom(rootDir, "libraries/stdlib/src/kotlin/ranges") val kotlinRangesCommon = fileFrom(rootDir, "libraries/stdlib/src/kotlin/ranges")
val kotlinCollectionsCommon = fileFrom(rootDir, "libraries/stdlib/src/kotlin/collections") val kotlinCollectionsCommon = fileFrom(rootDir, "libraries/stdlib/src/kotlin/collections")
val kotlinAnnotationsCommon = fileFrom(rootDir, "libraries/stdlib/src/kotlin/annotations") val kotlinAnnotationsCommon = fileFrom(rootDir, "libraries/stdlib/src/kotlin/annotations")
val builtinsCherryPicked = fileFrom(buildDir, "src/reflect")
val rangesCherryPicked = fileFrom(buildDir, "src/ranges")
val builtinsCherryPickedJvm = fileFrom(buildDir, "src-jvm/reflect")
val runtimeElements by configurations.creating { val runtimeElements by configurations.creating {
isCanBeResolved = false isCanBeResolved = false
@@ -47,7 +43,7 @@ val prepareRangeSources by tasks.registering(Sync::class) {
include("WasExperimental.kt") include("WasExperimental.kt")
} }
into(rangesCherryPicked) into(layout.buildDirectory.dir("src/ranges"))
} }
val prepareSources by tasks.registering(Sync::class) { val prepareSources by tasks.registering(Sync::class) {
@@ -55,7 +51,7 @@ val prepareSources by tasks.registering(Sync::class) {
exclude("typeOf.kt") exclude("typeOf.kt")
exclude("KClasses.kt") exclude("KClasses.kt")
} }
into(builtinsCherryPicked) into(layout.buildDirectory.dir("src/reflect"))
} }
val prepareSourcesJvm by tasks.registering(Sync::class) { val prepareSourcesJvm by tasks.registering(Sync::class) {
@@ -69,13 +65,16 @@ val prepareSourcesJvm by tasks.registering(Sync::class) {
include("KTypeParameter.kt") include("KTypeParameter.kt")
include("KVariance.kt") include("KVariance.kt")
} }
into(builtinsCherryPickedJvm) into(layout.buildDirectory.dir("src-jvm/reflect"))
} }
fun serializeTask(name: String, sourcesTask: TaskProvider<*>, inDirs: List<File>) = /**
* @param inDirs a list of input directories. Each value is evaluated as per [Project.file].
*/
fun serializeTask(name: String, sourcesTask: TaskProvider<*>, inDirs: List<Any>) =
tasks.register(name, NoDebugJavaExec::class) { tasks.register(name, NoDebugJavaExec::class) {
dependsOn(sourcesTask, prepareRangeSources) dependsOn(sourcesTask, prepareRangeSources)
val outDir = buildDir.resolve(this.name) val outDir = layout.buildDirectory.dir(this.name)
inDirs.forEach { inputs.dir(it).withPathSensitivity(RELATIVE) } inDirs.forEach { inputs.dir(it).withPathSensitivity(RELATIVE) }
outputs.dir(outDir) outputs.dir(outDir)
outputs.cacheIf { true } outputs.cacheIf { true }
@@ -83,30 +82,35 @@ fun serializeTask(name: String, sourcesTask: TaskProvider<*>, inDirs: List<File>
classpath(rootProject.buildscript.configurations["bootstrapCompilerClasspath"]) classpath(rootProject.buildscript.configurations["bootstrapCompilerClasspath"])
mainClass.set("org.jetbrains.kotlin.serialization.builtins.RunKt") mainClass.set("org.jetbrains.kotlin.serialization.builtins.RunKt")
jvmArguments.add("-Didea.io.use.nio2=true") jvmArguments.add("-Didea.io.use.nio2=true")
args(
pathRelativeToWorkingDir(outDir), val inputDirectories = project.files(inDirs)
*inDirs.map(::pathRelativeToWorkingDir).toTypedArray() argumentProviders.add {
) listOf(
pathRelativeToWorkingDir(outDir.get().asFile),
*inputDirectories.map(::pathRelativeToWorkingDir).toTypedArray()
)
}
doFirst { doFirst {
if (logger.isInfoEnabled) jvmArguments.add("-Dkotlin.builtins.serializer.log=true") if (logger.isInfoEnabled) jvmArguments.add("-Dkotlin.builtins.serializer.log=true")
} }
} }
val serialize = serializeTask("serialize", prepareSources, listOf(builtinsSrc, builtinsNative, builtinsCherryPicked, rangesCherryPicked)) val serialize = serializeTask("serialize", prepareSources, listOf(builtinsSrc, builtinsNative, prepareSources.map { it.destinationDir }, prepareRangeSources.map { it.destinationDir }))
val serializeJvm = serializeTask("serializeJvm", prepareSourcesJvm, listOf(builtinsSrc, builtinsNative, builtinsCherryPickedJvm, rangesCherryPicked)) val serializeJvm = serializeTask("serializeJvm", prepareSourcesJvm, listOf(builtinsSrc, builtinsNative, prepareSourcesJvm.map { it.destinationDir }, prepareRangeSources.map { it.destinationDir }))
val builtinsJar by task<Jar> { val builtinsJar by task<Jar> {
dependsOn(serialize) dependsOn(serialize)
from(serialize) { include("kotlin/**") } from(serialize) { include("kotlin/**") }
destinationDirectory.set(File(buildDir, "libs")) destinationDirectory.set(layout.buildDirectory.dir("libs"))
} }
val builtinsJvmJar by task<Jar> { val builtinsJvmJar by task<Jar> {
dependsOn(serializeJvm) dependsOn(serializeJvm)
from(serializeJvm) { include("kotlin/**") } from(serializeJvm) { include("kotlin/**") }
archiveClassifier.set("jvm") archiveClassifier.set("jvm")
destinationDirectory.set(File(buildDir, "libs")) destinationDirectory.set(layout.buildDirectory.dir("libs"))
} }
val assemble by tasks.getting { val assemble by tasks.getting {
@@ -125,6 +129,6 @@ publishing {
} }
repositories { repositories {
maven("${rootProject.buildDir}/internal/repo") maven(rootProject.layout.buildDirectory.dir("internal/repo"))
} }
} }
+6 -9
View File
@@ -1,6 +1,5 @@
import org.gradle.internal.os.OperatingSystem import org.gradle.internal.os.OperatingSystem
import java.net.URI import java.net.URI
import javax.inject.Inject
repositories { repositories {
ivy { ivy {
@@ -54,8 +53,7 @@ val androidPlatform by configurations.creating
val buildTools by configurations.creating val buildTools by configurations.creating
val androidEmulator by configurations.creating val androidEmulator by configurations.creating
val libsDestDir = File(buildDir, "androidSdk/platforms/android-26") val sdkDestDirName = "androidSdk"
val sdkDestDir = File(buildDir, "androidSdk")
val toolsOs = when { val toolsOs = when {
OperatingSystem.current().isWindows -> "windows" OperatingSystem.current().isWindows -> "windows"
@@ -107,12 +105,11 @@ fun unzipSdkTask(
val dependency = "google:$sdkName:$sdkVer${coordinatesSuffix.takeIf { it.isNotEmpty() }?.let { ":$it" } ?: ""}@$ext" val dependency = "google:$sdkName:$sdkVer${coordinatesSuffix.takeIf { it.isNotEmpty() }?.let { ":$it" } ?: ""}@$ext"
dependencies.add(createdCfg.name, dependency) dependencies.add(createdCfg.name, dependency)
val sdkDestDir = sdkDestDir
val unzipTask = tasks.register("unzip_$id") { val unzipTask = tasks.register("unzip_$id") {
val cfg = project.configurations.getByName(id) val cfg = project.configurations.getByName(id)
dependsOn(cfg) dependsOn(cfg)
inputs.files(cfg) inputs.files(cfg)
val targetDir = project.file("$sdkDestDir/$destinationSubdir") val targetDir = project.layout.buildDirectory.dir("$sdkDestDirName/$destinationSubdir")
outputs.dirs(targetDir) outputs.dirs(targetDir)
val injected = project.objects.newInstance<Injected>() val injected = project.objects.newInstance<Injected>()
val fs = injected.fs val fs = injected.fs
@@ -159,17 +156,17 @@ unzipSdkTask("armeabi-v7a", "19", "system-images/android-19/default","r05", prep
unzipSdkTask("x86", "19", "system-images/android-19/default", "r06", prepareTask = prepareEmulator) unzipSdkTask("x86", "19", "system-images/android-19/default", "r06", prepareTask = prepareEmulator)
val clean by task<Delete> { val clean by task<Delete> {
delete(buildDir) delete(layout.buildDirectory)
} }
artifacts.add(androidSdk.name, file("$sdkDestDir")) { artifacts.add(androidSdk.name, layout.buildDirectory.dir(sdkDestDirName)) {
builtBy(prepareSdk) builtBy(prepareSdk)
} }
artifacts.add(androidJar.name, file("$libsDestDir/android.jar")) { artifacts.add(androidJar.name, layout.buildDirectory.file("$sdkDestDirName/platforms/android-26/android.jar")) {
builtBy(preparePlatform) builtBy(preparePlatform)
} }
artifacts.add(androidEmulator.name, file("$sdkDestDir")) { artifacts.add(androidEmulator.name, layout.buildDirectory.dir(sdkDestDirName)) {
builtBy(prepareEmulator) builtBy(prepareEmulator)
} }
+10 -5
View File
@@ -1,6 +1,10 @@
import org.jetbrains.org.objectweb.asm.* import org.jetbrains.org.objectweb.asm.AnnotationVisitor
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.ClassReader.SKIP_CODE import org.jetbrains.org.objectweb.asm.ClassReader.SKIP_CODE
import org.jetbrains.org.objectweb.asm.Opcodes.* import org.jetbrains.org.objectweb.asm.ClassVisitor
import org.jetbrains.org.objectweb.asm.ClassWriter
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_PUBLIC
import org.jetbrains.org.objectweb.asm.Opcodes.API_VERSION
import java.util.zip.ZipFile import java.util.zip.ZipFile
plugins { plugins {
@@ -20,7 +24,7 @@ val toolsJarStubs by tasks.registering {
val toolsJarFile = toolsJar().singleFile val toolsJarFile = toolsJar().singleFile
inputs.file(toolsJarFile) inputs.file(toolsJarFile)
val outDir = buildDir.resolve(name) val outDir = layout.buildDirectory.dir(name)
outputs.dir(outDir) outputs.dir(outDir)
val usedInternalApiPackages = listOf( val usedInternalApiPackages = listOf(
@@ -28,7 +32,8 @@ val toolsJarStubs by tasks.registering {
) )
doLast { doLast {
outDir.deleteRecursively() val outputDirectoryFile = outDir.get().asFile
outputDirectoryFile.deleteRecursively()
val zipFile = ZipFile(toolsJarFile) val zipFile = ZipFile(toolsJarFile)
zipFile.stream() zipFile.stream()
.filter { it.name.endsWith(".class") } .filter { it.name.endsWith(".class") }
@@ -63,7 +68,7 @@ val toolsJarStubs by tasks.registering {
}, SKIP_CODE) }, SKIP_CODE)
if (isExported) { if (isExported) {
val result = File(outDir, zipEntry.name) val result = File(outputDirectoryFile, zipEntry.name)
result.parentFile.mkdirs() result.parentFile.mkdirs()
result.writeBytes(classWriter.toByteArray()) result.writeBytes(classWriter.toByteArray())
} }
+1 -1
View File
@@ -5,10 +5,10 @@ import java.util.zip.ZipFile
val isTeamcityBuild = project.hasProperty("teamcity") || System.getenv("TEAMCITY_VERSION") != null val isTeamcityBuild = project.hasProperty("teamcity") || System.getenv("TEAMCITY_VERSION") != null
val distDir: String by rootProject.extra val distDir: String by rootProject.extra
val repoDir: String = "${rootProject.buildDir}/repo"
val kotlinVersion: String by rootProject.extra val kotlinVersion: String by rootProject.extra
val checkMavenArtifacts = tasks.register("checkMavenArtifacts") { val checkMavenArtifacts = tasks.register("checkMavenArtifacts") {
val repoDir = rootProject.layout.buildDirectory.dir("repo")
doLast { doLast {
fileTree(repoDir).checkArtifacts { zip -> fileTree(repoDir).checkArtifacts { zip ->
if (!zip.name.endsWith("-sources.jar")) if (!zip.name.endsWith("-sources.jar"))
+12 -14
View File
@@ -1,11 +1,11 @@
import com.github.gradle.node.npm.task.NpmTask import com.github.gradle.node.npm.task.NpmTask
import com.github.gradle.node.variant.computeNodeExec import com.github.gradle.node.variant.computeNodeExec
import org.apache.tools.ant.filters.FixCrLfFilter
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
import org.jetbrains.kotlin.ideaExt.idea
import org.apache.tools.ant.filters.FixCrLfFilter
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
import java.util.Properties import org.jetbrains.kotlin.ideaExt.idea
import java.util.*
plugins { plugins {
kotlin("jvm") kotlin("jvm")
@@ -14,13 +14,12 @@ plugins {
id("com.github.node-gradle.node") version "5.0.0" id("com.github.node-gradle.node") version "5.0.0"
} }
val nodeDir = buildDir.resolve("node")
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
node { node {
download.set(true) download.set(true)
version.set(nodejsVersion) version.set(nodejsVersion)
nodeProjectDir.set(nodeDir) nodeProjectDir.set(layout.buildDirectory.dir("node"))
if (cacheRedirectorEnabled) { if (cacheRedirectorEnabled) {
distBaseUrl.set("https://cache-redirector.jetbrains.com/nodejs.org/dist") distBaseUrl.set("https://cache-redirector.jetbrains.com/nodejs.org/dist")
} }
@@ -361,7 +360,7 @@ fun Test.setUpBoxTests() {
systemProperty("kotlin.ant.launcher.class", "org.apache.tools.ant.Main") systemProperty("kotlin.ant.launcher.class", "org.apache.tools.ant.Main")
} }
systemProperty("kotlin.js.test.root.out.dir", "$nodeDir/") systemProperty("kotlin.js.test.root.out.dir", "${node.nodeProjectDir.get().asFile}/")
systemProperty( systemProperty(
"overwrite.output", project.providers.gradleProperty("overwrite.output").orNull ?: "false" "overwrite.output", project.providers.gradleProperty("overwrite.output").orNull ?: "false"
) )
@@ -378,8 +377,8 @@ val test = projectTest(jUnitMode = JUnitMode.JUnit5) {
inputs.dir(rootDir.resolve("dist")) inputs.dir(rootDir.resolve("dist"))
inputs.dir(rootDir.resolve("compiler/testData")) inputs.dir(rootDir.resolve("compiler/testData"))
outputs.dir("$buildDir/out") outputs.dir(layout.buildDirectory.dir("out"))
outputs.dir("$buildDir/out-min") outputs.dir(layout.buildDirectory.dir("out-min"))
configureTestDistribution() configureTestDistribution()
} }
@@ -448,26 +447,25 @@ val packageJsonFile = testDataDir.resolve("package.json")
val prepareNpmTestData by task<Copy> { val prepareNpmTestData by task<Copy> {
inputs.files(testJsFile, packageJsonFile) inputs.files(testJsFile, packageJsonFile)
outputs.dir(nodeDir)
from(testJsFile) from(testJsFile)
from(packageJsonFile) from(packageJsonFile)
into(nodeDir) into(node.nodeProjectDir)
} }
val npmInstall by tasks.getting(NpmTask::class) { val npmInstall by tasks.getting(NpmTask::class) {
val packageLockFile = testDataDir.resolve("package-lock.json") val packageLockFile = testDataDir.resolve("package-lock.json")
inputs.file(nodeDir.resolve("package.json")) inputs.file(node.nodeProjectDir.file("package.json"))
outputs.file(packageLockFile) outputs.file(packageLockFile)
outputs.upToDateWhen { packageLockFile.exists() } outputs.upToDateWhen { packageLockFile.exists() }
workingDir.set(nodeDir) workingDir.fileProvider(node.nodeProjectDir.asFile)
dependsOn(prepareNpmTestData) dependsOn(prepareNpmTestData)
} }
val mochaTest by task<MochaTestTask> { val mochaTest by task<MochaTestTask> {
workingDir.set(nodeDir) workingDir.fileProvider(node.nodeProjectDir.asFile)
val target = if (project.hasProperty("teamcity")) "runOnTeamcity" else "test" val target = if (project.hasProperty("teamcity")) "runOnTeamcity" else "test"
args.set(listOf("run", target)) args.set(listOf("run", target))
@@ -493,7 +491,7 @@ val runMocha by tasks.registering {
projectTest("invalidationTest", jUnitMode = JUnitMode.JUnit5) { projectTest("invalidationTest", jUnitMode = JUnitMode.JUnit5) {
workingDir = rootDir workingDir = rootDir
useJsIrBoxTests(version = version, buildDir = "$buildDir/") useJsIrBoxTests(version = version, buildDir = layout.buildDirectory)
include("org/jetbrains/kotlin/incremental/*") include("org/jetbrains/kotlin/incremental/*")
dependsOn(":dist") dependsOn(":dist")
forwardProperties() forwardProperties()
@@ -22,7 +22,7 @@ plugins {
val libclangextProject = project(":kotlin-native:libclangext") val libclangextProject = project(":kotlin-native:libclangext")
val libclangextTask = libclangextProject.path + ":build" val libclangextTask = libclangextProject.path + ":build"
val libclangextDir = libclangextProject.buildDir val libclangextDir = libclangextProject.layout.buildDirectory.get().asFile
val libclangextIsEnabled = libclangextProject.findProperty("isEnabled")!! as Boolean val libclangextIsEnabled = libclangextProject.findProperty("isEnabled")!! as Boolean
@@ -148,8 +148,8 @@ val nativelibs = project.tasks.register<Copy>("nativelibs") {
val clangstubsSolib = solib("clangstubs") val clangstubsSolib = solib("clangstubs")
dependsOn(clangstubsSolib) dependsOn(clangstubsSolib)
from("$buildDir/$clangstubsSolib") from(layout.buildDirectory.dir(clangstubsSolib))
into("$buildDir/nativelibs/") into(layout.buildDirectory.dir("nativelibs"))
} }
kotlinNativeInterop { kotlinNativeInterop {
@@ -183,7 +183,7 @@ tasks.withType<Test>().configureEach {
dependsOn(projectsWithNativeLibs.map { "${it.path}:nativelibs" }) dependsOn(projectsWithNativeLibs.map { "${it.path}:nativelibs" })
dependsOn(nativeDependencies.llvmDependency) dependsOn(nativeDependencies.llvmDependency)
systemProperty("java.library.path", projectsWithNativeLibs.joinToString(File.pathSeparator) { systemProperty("java.library.path", projectsWithNativeLibs.joinToString(File.pathSeparator) {
File(it.buildDir, "nativelibs").absolutePath it.layout.buildDirectory.dir("nativelibs").get().asFile.absolutePath
}) })
systemProperty("kotlin.native.llvm.libclang", "${nativeDependencies.llvmPath}/" + if (HostManager.hostIsMingw) { systemProperty("kotlin.native.llvm.libclang", "${nativeDependencies.llvmPath}/" + if (HostManager.hostIsMingw) {
@@ -192,7 +192,7 @@ tasks.withType<Test>().configureEach {
"lib/${System.mapLibraryName("clang")}" "lib/${System.mapLibraryName("clang")}"
}) })
systemProperty("kotlin.native.interop.indexer.temp", File(buildDir, "testTemp")) systemProperty("kotlin.native.interop.indexer.temp", layout.buildDirectory.dir("testTemp").get().asFile)
} }
// Please note that list of headers should be fixed manually. // Please note that list of headers should be fixed manually.
@@ -202,14 +202,14 @@ tasks.register("updatePrebuilt") {
doLast { doLast {
copy { copy {
from("$buildDir/nativeInteropStubs/clang/kotlin") { from(layout.buildDirectory.dir("nativeInteropStubs/clang/kotlin")) {
include("clang/clang.kt") include("clang/clang.kt")
} }
into("prebuilt/nativeInteropStubs/kotlin") into("prebuilt/nativeInteropStubs/kotlin")
} }
copy { copy {
from("$buildDir/interopTemp") { from(layout.buildDirectory.dir("interopTemp")) {
include("clangstubs.c") include("clangstubs.c")
} }
into("prebuilt/nativeInteropStubs/c") into("prebuilt/nativeInteropStubs/c")
@@ -36,7 +36,7 @@ native {
tool(*hostPlatform.clangForJni.clangCXX("").toTypedArray()) tool(*hostPlatform.clangForJni.clangCXX("").toTypedArray())
flags("-shared", flags("-shared",
"-o",ruleOut(), *ruleInAll(), "-o",ruleOut(), *ruleInAll(),
"-L${project(":kotlin-native:libclangext").buildDir}", "-L${project(":kotlin-native:libclangext").layout.buildDirectory.get().asFile}",
"${nativeDependencies.libffiPath}/lib/libffi.$lib", "${nativeDependencies.libffiPath}/lib/libffi.$lib",
"-lclangext") "-lclangext")
} }
@@ -54,7 +54,7 @@ dependencies {
val prepareSharedSourcesForJvm by tasks.registering(Sync::class) { val prepareSharedSourcesForJvm by tasks.registering(Sync::class) {
from("src/main/kotlin") from("src/main/kotlin")
into("$buildDir/src/main/kotlin") into(project.layout.buildDirectory.dir("src/main/kotlin"))
} }
val prepareKotlinIdeaImport by tasks.registering { val prepareKotlinIdeaImport by tasks.registering {
dependsOn(prepareSharedSourcesForJvm) dependsOn(prepareSharedSourcesForJvm)
@@ -83,6 +83,6 @@ val nativelibs = project.tasks.create<Copy>("nativelibs") {
val callbacksSolib = solib("callbacks") val callbacksSolib = solib("callbacks")
dependsOn(callbacksSolib) dependsOn(callbacksSolib)
from("$buildDir/$callbacksSolib") from(layout.buildDirectory.dir(callbacksSolib))
into("$buildDir/nativelibs/") into(layout.buildDirectory.dir("nativelibs"))
} }
@@ -62,7 +62,7 @@ tasks {
dependsOn(projectsWithNativeLibs.map { "${it.path}:nativelibs" }) dependsOn(projectsWithNativeLibs.map { "${it.path}:nativelibs" })
dependsOn(nativeDependencies.llvmDependency) dependsOn(nativeDependencies.llvmDependency)
systemProperty("java.library.path", projectsWithNativeLibs.joinToString(File.pathSeparator) { systemProperty("java.library.path", projectsWithNativeLibs.joinToString(File.pathSeparator) {
File(it.buildDir, "nativelibs").absolutePath it.layout.buildDirectory.dir("nativelibs").get().asFile.absolutePath
}) })
val libclangPath = "${nativeDependencies.llvmPath}/" + if (org.jetbrains.kotlin.konan.target.HostManager.hostIsMingw) { val libclangPath = "${nativeDependencies.llvmPath}/" + if (org.jetbrains.kotlin.konan.target.HostManager.hostIsMingw) {
"bin/libclang.dll" "bin/libclang.dll"
@@ -70,7 +70,7 @@ tasks {
"lib/${System.mapLibraryName("clang")}" "lib/${System.mapLibraryName("clang")}"
} }
systemProperty("kotlin.native.llvm.libclang", libclangPath) systemProperty("kotlin.native.llvm.libclang", libclangPath)
systemProperty("kotlin.native.interop.stubgenerator.temp", File(buildDir, "stubGeneratorTestTemp")) systemProperty("kotlin.native.interop.stubgenerator.temp", layout.buildDirectory.dir("stubGeneratorTestTemp").get().asFile)
// Set the konan.home property because we run the cinterop tool not from a distribution jar // Set the konan.home property because we run the cinterop tool not from a distribution jar
// so it will not be able to determine this path by itself. // so it will not be able to determine this path by itself.
+1 -1
View File
@@ -89,7 +89,7 @@ kotlinNativeInterop {
// To enforce linking with proper libc++, pass the default path explicitly: // To enforce linking with proper libc++, pass the default path explicitly:
linkerOpts "-L${hostPlatform.absoluteTargetSysRoot}/usr/lib" linkerOpts "-L${hostPlatform.absoluteTargetSysRoot}/usr/lib"
} }
linkerOpts "-L$llvmDir/lib", "-L${rootProject.project(':kotlin-native:llvmDebugInfoC').buildDir}", "-L${rootProject.project(':kotlin-native:libllvmext').buildDir}" linkerOpts "-L$llvmDir/lib", "-L${rootProject.project(':kotlin-native:llvmDebugInfoC').layout.buildDirectory.get().asFile}", "-L${rootProject.project(':kotlin-native:libllvmext').layout.buildDirectory.get().asFile}"
} }
files { files {
+82 -64
View File
@@ -3016,16 +3016,17 @@ KotlinNativeTestKt.createTest(project, "kt39548", KonanStandaloneTest) { task ->
task.enabled = isWindowsTarget(project) task.enabled = isWindowsTarget(project)
if (task.enabled) { if (task.enabled) {
def ktFile = project.layout.buildDirectory.file("kt39548/kt39548.kt").get().asFile
konanArtifacts { konanArtifacts {
program(name, targets: [target.name]) { program(name, targets: [target.name]) {
baseDir "$testOutputLocal/$name" baseDir "$testOutputLocal/$name"
srcFiles "$buildDir/kt39548/kt39548.kt" // Generated by doBeforeBuild task. srcFiles ktFile.toString() // Generated by doBeforeBuild task.
extraOpts task.flags extraOpts task.flags
extraOpts project.globalTestArgs extraOpts project.globalTestArgs
} }
} }
doBeforeBuild { doBeforeBuild {
GenTestKT39548Kt.genTestKT39548(file("$buildDir/kt39548/kt39548.kt")) GenTestKT39548Kt.genTestKT39548(ktFile)
} }
} }
} }
@@ -3311,15 +3312,16 @@ linkTest("inline_innerInlineFunCapturesOuter_linkTest") {
} }
def generateWithSpaceDefFile() { def generateWithSpaceDefFile() {
def mapOption = "--Map \"${buildDir}/cutom map.map\"" def buildDirectory = project.layout.buildDirectory.get().asFile
def mapOption = "--Map \"$buildDirectory/cutom map.map\""
if (isAppleTarget(project)) { if (isAppleTarget(project)) {
mapOption = "-map \"${buildDir}/cutom map.map\"" mapOption = "-map \"$buildDirectory/cutom map.map\""
} else if (isWindowsTarget(project)) { } else if (isWindowsTarget(project)) {
mapOption = "\"-Wl,--Map,${buildDir}/cutom map.map\"" mapOption = "\"-Wl,--Map,$buildDirectory/cutom map.map\""
} }
buildDir.mkdirs() buildDirectory.mkdirs()
def file = new File("${buildDir}/withSpaces.def") def file = new File("${buildDirectory}/withSpaces.def")
file.write """ file.write """
headers = stdio.h "${projectDir}/interop/basics/custom headers/custom.h" headers = stdio.h "${projectDir}/interop/basics/custom headers/custom.h"
linkerOpts = $mapOption linkerOpts = $mapOption
@@ -3429,7 +3431,7 @@ createInterop("embedStaticLibraries") {
it.headers "$projectDir/interop/embedStaticLibraries/embedStaticLibraries.h" it.headers "$projectDir/interop/embedStaticLibraries/embedStaticLibraries.h"
// Note: also hardcoded in def file. // Note: also hardcoded in def file.
final String libDir = "$buildDir/embedStaticLibraries/" final File libDir = project.layout.buildDirectory.dir("embedStaticLibraries").get().asFile
it.getByTarget(target.name).configure { it.getByTarget(target.name).configure {
doFirst { doFirst {
@@ -3456,7 +3458,7 @@ createInterop("kt43502") {
it.defFile 'interop/kt43502/kt43502.def' it.defFile 'interop/kt43502/kt43502.def'
it.headers "$projectDir/interop/kt43502/kt43502.h" it.headers "$projectDir/interop/kt43502/kt43502.h"
// Note: also hardcoded in def file. // Note: also hardcoded in def file.
final String libDir = "$buildDir/kt43502/" final File libDir = project.layout.buildDirectory.dir("kt43502").get().asFile
// Construct library that contains actual symbol definition. // Construct library that contains actual symbol definition.
it.getByTarget(target.name).configure { it.getByTarget(target.name).configure {
doFirst { doFirst {
@@ -3700,7 +3702,7 @@ Task interopTestBase(String name, boolean multiFile, boolean interop2ForMainOnly
} }
srcFiles multiFile ? fileTree(task.source) { include '**/*.kt' } : task.getSources() srcFiles multiFile ? fileTree(task.source) { include '**/*.kt' } : task.getSources()
baseDir "$testOutputLocal/$name" baseDir "$testOutputLocal/$name"
linkerOpts "-L$buildDir" linkerOpts "-L${project.layout.buildDirectory.get().asFile}"
extraOpts task.flags extraOpts task.flags
extraOpts project.globalTestArgs extraOpts project.globalTestArgs
} }
@@ -3869,7 +3871,7 @@ interopTest("interop_withSpaces") {
source = "interop/basics/withSpaces.kt" source = "interop/basics/withSpaces.kt"
doLast { doLast {
assert file("${buildDir}/cutom map.map").exists() assert project.layout.buildDirectory.file("cutom map.map").get().asFile.exists()
} }
} }
@@ -3992,16 +3994,17 @@ if (PlatformInfo.isAppleTarget(project)) {
source = "interop/objc/smoke.kt" source = "interop/objc/smoke.kt"
interop = 'objcSmoke' interop = 'objcSmoke'
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjcsmoke.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/smoke.m" args "$projectDir/interop/objc/smoke.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjcsmoke.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
// Enable ARC optimizations to prevent some objects from leaking in Obj-C code due to exceptions: // Enable ARC optimizations to prevent some objects from leaking in Obj-C code due to exceptions:
args '-O2' args '-O2'
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjcsmoke.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
copy { copy {
@@ -4018,16 +4021,17 @@ if (PlatformInfo.isAppleTarget(project)) {
interop = 'objcSmoke' interop = 'objcSmoke'
verifyIr = false // KT-57716 verifyIr = false // KT-57716
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjcsmoke.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/smoke.m" args "$projectDir/interop/objc/smoke.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjcsmoke.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
// Enable ARC optimizations to prevent some objects from leaking in Obj-C code due to exceptions: // Enable ARC optimizations to prevent some objects from leaking in Obj-C code due to exceptions:
args '-O2' args '-O2'
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjcsmoke.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
copy { copy {
@@ -4056,16 +4060,17 @@ if (PlatformInfo.isAppleTarget(project)) {
} }
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjctests.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args fileTree("$projectDir/interop/objc/tests/") { include '**/*.m' } args fileTree("$projectDir/interop/objc/tests/") { include '**/*.m' }
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjctests.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
// Enable ARC optimizations to prevent some objects from leaking in Obj-C code due to exceptions: // Enable ARC optimizations to prevent some objects from leaking in Obj-C code due to exceptions:
args '-O2' args '-O2'
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjctests.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
@@ -4100,14 +4105,15 @@ if (PlatformInfo.isAppleTarget(project)) {
interop = 'objcMisc' interop = 'objcMisc'
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjcmisc.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc_with_initializer/objc_misc.m" args "$projectDir/interop/objc_with_initializer/objc_misc.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjcmisc.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjcmisc.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
@@ -4117,14 +4123,15 @@ if (PlatformInfo.isAppleTarget(project)) {
interop = 'objcMessaging' interop = 'objcMessaging'
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjcmessaging.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/msg_send/messaging.m" args "$projectDir/interop/objc/msg_send/messaging.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjcmessaging.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjcmessaging.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
@@ -4146,14 +4153,15 @@ if (PlatformInfo.isAppleTarget(project)) {
UtilsKt.dependsOnPlatformLibs(it) UtilsKt.dependsOnPlatformLibs(it)
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjcexception.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/foreignException/objc_wrap.m" args "$projectDir/interop/objc/foreignException/objc_wrap.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjcexception.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjcexception.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
@@ -4165,14 +4173,15 @@ if (PlatformInfo.isAppleTarget(project)) {
UtilsKt.dependsOnPlatformLibs(it) UtilsKt.dependsOnPlatformLibs(it)
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjcexception.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/foreignException/objc_wrap.m" args "$projectDir/interop/objc/foreignException/objc_wrap.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjcexception.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjcexception.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
@@ -4184,14 +4193,15 @@ if (PlatformInfo.isAppleTarget(project)) {
UtilsKt.dependsOnPlatformLibs(it) UtilsKt.dependsOnPlatformLibs(it)
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjcexception.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/foreignException/objc_wrap.m" args "$projectDir/interop/objc/foreignException/objc_wrap.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjcexception.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjcexception.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
@@ -4217,14 +4227,15 @@ if (PlatformInfo.isAppleTarget(project)) {
useGoldenData = true useGoldenData = true
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjc_kt42172.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/kt42172/objclib.m" args "$projectDir/interop/objc/kt42172/objclib.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjc_kt42172.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjc_kt42172.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
@@ -4282,29 +4293,31 @@ if (PlatformInfo.isAppleTarget(project)) {
} }
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjc_kt55938.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/kt55938/objclib.m" args "$projectDir/interop/objc/kt55938/objclib.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjc_kt55938.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjc_kt55938.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
standaloneTest("objc_arc_contract") { standaloneTest("objc_arc_contract") {
def bcFile = project.layout.buildDirectory.file("objc_arc_contract.bc").get().asFile
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) mkdir(bcFile.parentFile)
ExecLlvmKt.execLlvmUtility(project, "llvm-as") { ExecLlvmKt.execLlvmUtility(project, "llvm-as") {
args "$projectDir/interop/objc_arc_contract/main.ll" args "$projectDir/interop/objc_arc_contract/main.ll"
args "-o", "$buildDir/objc_arc_contract.bc" args "-o", bcFile.toString()
} }
} }
source = "interop/objc_arc_contract/main.kt" source = "interop/objc_arc_contract/main.kt"
useGoldenData = true useGoldenData = true
flags = ["-native-library", "$buildDir/objc_arc_contract.bc"] flags = ["-native-library", bcFile.toString()]
} }
interopTest("interop_objc_include_categories") { interopTest("interop_objc_include_categories") {
@@ -4312,14 +4325,15 @@ if (PlatformInfo.isAppleTarget(project)) {
source = "interop/objc/include_categories/main.kt" source = "interop/objc/include_categories/main.kt"
interop = "objc_include_categories" interop = "objc_include_categories"
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjcincludecategories.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/include_categories/objc_include_categories.m" args "$projectDir/interop/objc/include_categories/objc_include_categories.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjcincludecategories.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjcincludecategories.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
@@ -4349,16 +4363,17 @@ if (PlatformInfo.isAppleTarget(project)) {
flags = ["-tr", "-e", "runAllTests"] // Generate test suites, but use custom entrypoint. flags = ["-tr", "-e", "runAllTests"] // Generate test suites, but use custom entrypoint.
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjc_kt56402.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/kt56402/objclib.m" args "$projectDir/interop/objc/kt56402/objclib.m"
args "-g" args "-g"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjc_kt56402.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
args '-framework', 'AppKit' args '-framework', 'AppKit'
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjc_kt56402.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
} }
@@ -4370,14 +4385,15 @@ if (PlatformInfo.isAppleTarget(project)) {
flags = ["-tr"] flags = ["-tr"]
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjc_friendly_dealloc.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/objc_friendly_dealloc/objclib.m" args "$projectDir/interop/objc/objc_friendly_dealloc/objclib.m"
args "-lobjc", '-fno-objc-arc' args "-lobjc", '-fno-objc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjc_friendly_dealloc.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjc_friendly_dealloc.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
UtilsKt.dependsOnPlatformLibs(it) UtilsKt.dependsOnPlatformLibs(it)
@@ -4388,14 +4404,15 @@ if (PlatformInfo.isAppleTarget(project)) {
interop = "objCAction" interop = "objCAction"
flags = ["-tr"] flags = ["-tr"]
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) def dylibFile = project.layout.buildDirectory.file("libobjCAction.dylib").get().asFile
mkdir(dylibFile.parentFile)
project.extensions.execClang.execClangForCompilerTests(project.target) { project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/objCAction/objclib.m" args "$projectDir/interop/objc/objCAction/objclib.m"
args "-lobjc", '-fobjc-arc' args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjCAction.dylib" args '-fPIC', '-shared', '-o', dylibFile.toString()
} }
if (UtilsKt.isSimulatorTarget(project, project.target)) { if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjCAction.dylib") UtilsKt.codesign(project, dylibFile.toString())
} }
} }
UtilsKt.dependsOnPlatformLibs(it) UtilsKt.dependsOnPlatformLibs(it)
@@ -4413,15 +4430,16 @@ tasks.register("KT-50983", KonanDriverTest) {
// The test is not working on Windows Server 2019-based TeamCity agents for the unknown reason. // The test is not working on Windows Server 2019-based TeamCity agents for the unknown reason.
// TODO: Re-enable it after LLVM update where llvm-windres will be added. // TODO: Re-enable it after LLVM update where llvm-windres will be added.
enabled = false enabled = false
def resFile = project.layout.buildDirectory.file("File.res").get().asFile
doBeforeBuild { doBeforeBuild {
mkdir(buildDir) mkdir(resFile.parentFile)
exec { exec {
commandLine UtilsKt.binaryFromToolchain(project, "windres") commandLine UtilsKt.binaryFromToolchain(project, "windres")
args "$projectDir/windows/KT-50983/File.rc", "-O", "coff", "-o", "$buildDir/File.res" args "$projectDir/windows/KT-50983/File.rc", "-O", "coff", "-o", resFile.toString()
} }
} }
source = "windows/KT-50983/main.kt" source = "windows/KT-50983/main.kt"
flags = ['-linker-option', "$buildDir/File.res"] flags = ['-linker-option', resFile.toString()]
} }
standaloneTest("interop_libiconv") { standaloneTest("interop_libiconv") {
@@ -4601,7 +4619,7 @@ standaloneTest("library_ir_provider_mismatch") {
String invalidManifest = "$projectDir/link/ir_providers/library/manifest.properties" String invalidManifest = "$projectDir/link/ir_providers/library/manifest.properties"
String mainSource = "$projectDir/link/ir_providers/hello.kt" String mainSource = "$projectDir/link/ir_providers/hello.kt"
String outputDir = "$buildDir/$name" File outputDir = project.layout.buildDirectory.dir(name).get().asFile
String currentTarget = project.target.name String currentTarget = project.target.name
inputs.files(librarySource, invalidManifest) inputs.files(librarySource, invalidManifest)
@@ -4666,7 +4684,7 @@ standaloneTest("split_compilation_pipeline") {
// Also, it is failing for some reason on Windows CI, but since MinGW targets are not inteneded // Also, it is failing for some reason on Windows CI, but since MinGW targets are not inteneded
// to use this mode, we can disable it for these targets. // to use this mode, we can disable it for these targets.
enabled = !twoStageEnabled && project.target.name != "mingw_x64" && project.target.name != "mingw_x86" enabled = !twoStageEnabled && project.target.name != "mingw_x64" && project.target.name != "mingw_x86"
def dir = buildDir.absolutePath def dir = project.layout.buildDirectory.get().asFile.absolutePath
source = "link/private_fake_overrides/override_main.kt" source = "link/private_fake_overrides/override_main.kt"
doBeforeBuild { doBeforeBuild {
konanc("$projectDir/link/private_fake_overrides/override_lib.kt -p library -target ${target.name} -o $dir/lib.klib") konanc("$projectDir/link/private_fake_overrides/override_lib.kt -p library -target ${target.name} -o $dir/lib.klib")
@@ -4709,7 +4727,7 @@ Task frameworkTest(String name, Closure<FrameworkTest> configurator) {
libraries { libraries {
klibFile konanArtifacts[library].getArtifactByTarget(target.name) klibFile konanArtifacts[library].getArtifactByTarget(target.name)
} }
linkerOpts "-L$buildDir" linkerOpts "-L${project.layout.buildDirectory.get().asFile}"
UtilsKt.dependsOnKonanBuildingTask(task, library, target) UtilsKt.dependsOnKonanBuildingTask(task, library, target)
} }
@@ -5183,7 +5201,7 @@ Task pluginTest(String name, String pluginName, Closure configureClosure) {
sourceSets[pluginName].output sourceSets[pluginName].output
} }
archiveBaseName = pluginName archiveBaseName = pluginName
destinationDirectory = buildDir destinationDirectory = project.layout.buildDirectory.get().asFile
} }
def taskName = "$name-with-$pluginName" def taskName = "$name-with-$pluginName"
return KotlinNativeTestKt.createTest(project, taskName, KonanStandaloneTest) { task -> return KotlinNativeTestKt.createTest(project, taskName, KonanStandaloneTest) { task ->
@@ -5194,7 +5212,7 @@ Task pluginTest(String name, String pluginName, Closure configureClosure) {
program(taskName, targets: [target.name]) { program(taskName, targets: [target.name]) {
baseDir "$testOutputLocal/$taskName" baseDir "$testOutputLocal/$taskName"
srcFiles task.getSources() srcFiles task.getSources()
extraOpts task.flags + "-Xplugin=$buildDir/nop-plugin.jar" extraOpts task.flags + "-Xplugin=${project.layout.buildDirectory.file("nop-plugin.jar").get().asFile}"
extraOpts project.globalTestArgs extraOpts project.globalTestArgs
} }
} }
@@ -146,15 +146,15 @@ class NamedNativeInteropConfig implements Named {
} }
File getNativeLibsDir() { File getNativeLibsDir() {
return new File(project.buildDir, "nativelibs/$target") return project.layout.buildDirectory.dir("nativelibs/$target").get().asFile
} }
File getGeneratedSrcDir() { File getGeneratedSrcDir() {
return new File(project.buildDir, "nativeInteropStubs/$name/kotlin") return project.layout.buildDirectory.dir("nativeInteropStubs/$name/kotlin").get().asFile
} }
File getTemporaryFilesDir() { File getTemporaryFilesDir() {
return new File(project.buildDir, "interopTemp") return project.layout.buildDirectory.dir("interopTemp").get().asFile
} }
String getLlvmDir() { String getLlvmDir() {
@@ -213,8 +213,8 @@ class NamedNativeInteropConfig implements Named {
jvmArgs '-ea' jvmArgs '-ea'
systemProperties "java.library.path" : project.files( systemProperties "java.library.path" : project.files(
new File(project.findProject(":kotlin-native:Interop:Indexer").buildDir, "nativelibs"), project.findProject(":kotlin-native:Interop:Indexer").layout.buildDirectory.dir("nativelibs"),
new File(project.findProject(":kotlin-native:Interop:Runtime").buildDir, "nativelibs") project.findProject(":kotlin-native:Interop:Runtime").layout.buildDirectory.dir("nativelibs"),
).asPath ).asPath
// Set the konan.home property because we run the cinterop tool not from a distribution jar // Set the konan.home property because we run the cinterop tool not from a distribution jar
// so it will not be able to determine this path by itself. // so it will not be able to determine this path by itself.
@@ -16,7 +16,7 @@ open class CopyCommonSources : DefaultTask() {
val sourcePaths: ConfigurableFileCollection = project.files() val sourcePaths: ConfigurableFileCollection = project.files()
@OutputDirectory @OutputDirectory
var outputDir: File = project.buildDir.resolve("sources") var outputDir: File = project.layout.buildDirectory.get().asFile.resolve("sources")
fun zipSources(needToZip: Boolean) { fun zipSources(needToZip: Boolean) {
zipSources = needToZip zipSources = needToZip
@@ -46,7 +46,7 @@ open class CopyCommonSources : DefaultTask() {
val filePrefix = sourcePath.name.replace(Regex("-\\d+.*"), "") val filePrefix = sourcePath.name.replace(Regex("-\\d+.*"), "")
val targetFileName = "$filePrefix-sources.zip" val targetFileName = "$filePrefix-sources.zip"
val tempDir = project.buildDir.resolve(name).resolve(filePrefix).also { val tempDir = project.layout.buildDirectory.dir("$name/$filePrefix").get().asFile.also {
it.deleteRecursively() it.deleteRecursively()
it.mkdirs() it.mkdirs()
} }
@@ -89,7 +89,7 @@ internal val Project.konanVersion: String
?.toString() ?.toString()
?: project.version.toString() ?: project.version.toString()
internal val Project.konanBuildRoot get() = buildDir.resolve("konan") internal val Project.konanBuildRoot get() = layout.buildDirectory.get().asFile.resolve("konan")
internal val Project.konanBinBaseDir get() = konanBuildRoot.resolve("bin") internal val Project.konanBinBaseDir get() = konanBuildRoot.resolve("bin")
internal val Project.konanLibsBaseDir get() = konanBuildRoot.resolve("libs") internal val Project.konanLibsBaseDir get() = konanBuildRoot.resolve("libs")
internal val Project.konanBitcodeBaseDir get() = konanBuildRoot.resolve("bitcode") internal val Project.konanBitcodeBaseDir get() = konanBuildRoot.resolve("bitcode")
@@ -92,7 +92,7 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
protected fun directoryToKt(dir: Any) = project.fileTree(dir).apply { protected fun directoryToKt(dir: Any) = project.fileTree(dir).apply {
include("**/*.kt") include("**/*.kt")
exclude { it.file.startsWith(project.buildDir) } exclude { it.file.startsWith(project.layout.buildDirectory.get().asFile) }
} }
// Command line ------------------------------------------------------------ // Command line ------------------------------------------------------------
@@ -121,7 +121,7 @@ open class SourceSet(
return SourceSet( return SourceSet(
sourceSets, sourceSets,
name, name,
sourceSets.project.file("${sourceSets.project.buildDir}/$name/${suffixes.first}_${suffixes.second}/"), sourceSets.project.file(sourceSets.project.layout.buildDirectory.dir("$name/${suffixes.first}_${suffixes.second}/")),
this, this,
suffixes suffixes
) )
@@ -218,7 +218,7 @@ open class NativeToolsExtension(val project: Project) {
dependsOn(it.implicitTasks()) dependsOn(it.implicitTasks())
} }
val deps = objSet.flatMap { it.collection.files }.map { it.path } val deps = objSet.flatMap { it.collection.files }.map { it.path }
val toolConfiguration = ToolPatternImpl(sourceSets.extension, "${project.buildDir.path}/$name", *deps.toTypedArray()) val toolConfiguration = ToolPatternImpl(sourceSets.extension, "${project.layout.buildDirectory.get().asFile.path}/$name", *deps.toTypedArray())
toolConfiguration.configuration() toolConfiguration.configuration()
toolConfiguration.configure(this, false ) toolConfiguration.configure(this, false )
} }
+2 -2
View File
@@ -455,7 +455,7 @@ targetList.each { target ->
destinationDir project.file("$distDir/klib/cache/") destinationDir project.file("$distDir/klib/cache/")
from("${project(":kotlin-native:runtime").buildDir}/cache/$target") { from(project(":kotlin-native:runtime").layout.buildDirectory.dir("cache/$target")) {
include('**') include('**')
} }
} }
@@ -747,7 +747,7 @@ tasks.named("clean", Delete) {
dependsOn subprojects.collect { it.tasks.matching { it.name == "clean" } } dependsOn subprojects.collect { it.tasks.matching { it.name == "clean" } }
doFirst { doFirst {
delete distDir delete distDir
delete buildDir delete layout.buildDirectory
delete bundle.outputs.files delete bundle.outputs.files
delete "${projectDir}/compile_commands.json" delete "${projectDir}/compile_commands.json"
} }
+1 -1
View File
@@ -33,5 +33,5 @@ tasks.register("build") {
} }
tasks.register<Delete>("clean") { tasks.register<Delete>("clean") {
delete(buildDir) delete(layout.buildDirectory)
} }
@@ -20,9 +20,7 @@ task clean {
subprojects.each { subprojects.each {
dependsOn it.getTasksByName('clean', true)[0] dependsOn it.getTasksByName('clean', true)[0]
} }
doLast { delete(layout.buildDirectory)
delete "${buildDir.absolutePath}"
}
} }
defaultTasks 'konanRun' defaultTasks 'konanRun'
+10 -12
View File
@@ -121,9 +121,7 @@ task clean {
dependsOn "${it.path}:clean" dependsOn "${it.path}:clean"
} }
} }
doLast { delete(layout.buildDirectory)
delete "${buildDir.absolutePath}"
}
} }
defaultTasks 'konanRun' defaultTasks 'konanRun'
@@ -166,7 +164,7 @@ private def uploadBenchmarkResultToArtifactory(String fileName) {
buildProperties.load(new FileInputStream(teamcityConfig)) buildProperties.load(new FileInputStream(teamcityConfig))
def password = buildProperties.getProperty("artifactory.apikey") def password = buildProperties.getProperty("artifactory.apikey")
MPPTools.uploadFileToArtifactory("${artifactoryUrl}", "${artifactoryRepo}", MPPTools.uploadFileToArtifactory("${artifactoryUrl}", "${artifactoryRepo}",
uploadedFile, "${buildDir.absolutePath}/${fileName}", password) uploadedFile, layout.buildDirectory.file(fileName).get().asFile.toString(), password)
} }
} }
@@ -176,7 +174,7 @@ task registerExternalBenchmarks {
def reports = externalReports.split(';') def reports = externalReports.split(';')
def jsonReports = [] def jsonReports = []
reports.each { reports.each {
def reportFile = new File(buildDir, it) def reportFile = layout.buildDirectory.file(it).get().asFile
if (!reportFile.exists()) if (!reportFile.exists())
return return
@@ -222,14 +220,14 @@ task registerExternalBenchmarks {
properties += ["codeSize": MPPTools.toCodeSizeBenchmark(codeSize, status, name)] properties += ["codeSize": MPPTools.toCodeSizeBenchmark(codeSize, status, name)]
} }
def output = MPPTools.createJsonReport(properties) def output = MPPTools.createJsonReport(properties)
def jsonFile = new File(buildDir, it.replace(".txt", ".json")) def jsonFile = layout.buildDirectory.file(it.replace(".txt", ".json")).get().asFile
jsonFile.write(output) jsonFile.write(output)
jsonReports.add(jsonFile) jsonReports.add(jsonFile)
} }
def merged = MPPTools.mergeReports(jsonReports) def merged = MPPTools.mergeReports(jsonReports)
if (!merged.isEmpty()) { if (!merged.isEmpty()) {
mkdir buildDir.absolutePath mkdir layout.buildDirectory.get().asFile.absolutePath
new File(buildDir, externalBenchmarksReport).write(merged) layout.buildDirectory.file(externalBenchmarksReport).get().asFile.write(merged)
uploadBenchmarkResultToArtifactory(externalBenchmarksReport) uploadBenchmarkResultToArtifactory(externalBenchmarksReport)
} }
} }
@@ -269,14 +267,14 @@ registerExternalBenchmarks.finalizedBy registerExternalBuild
def mergeReports(String fileName) { def mergeReports(String fileName) {
def reports = [] def reports = []
subprojects.each { subprojects.each {
def reportFile = new File("${it.buildDir.absolutePath}/${fileName}") def reportFile = it.layout.buildDirectory.file(fileName).get().asFile
if (reportFile.exists()) { if (reportFile.exists()) {
reports.add(reportFile) reports.add(reportFile)
} }
} }
def output = MPPTools.mergeReports(reports) def output = MPPTools.mergeReports(reports)
mkdir buildDir.absolutePath mkdir layout.buildDirectory.get().asFile.absolutePath
new File("${buildDir.absolutePath}/${fileName}").write(output) new File("${layout.buildDirectory.get().asFile.absolutePath}/${fileName}").write(output)
} }
task mergeNativeReports { task mergeNativeReports {
@@ -313,7 +311,7 @@ task teamCityStat(type:Exec) {
"--artifactory-url", "https://repo.labs.intellij.net/kotlin-native-benchmarks", "--artifactory-url", "https://repo.labs.intellij.net/kotlin-native-benchmarks",
"--teamcity-url", "http://buildserver.labs.intellij.net", "--teamcity-url", "http://buildserver.labs.intellij.net",
"--server-url", findProperty("kotlin.native.performance.server.url")?.toString() ?: "http://localhost:3000", "--server-url", findProperty("kotlin.native.performance.server.url")?.toString() ?: "http://localhost:3000",
"${buildDir.absolutePath}/${nativeJson}" "${layout.buildDirectory.file(nativeJson).get().asFile}"
} }
task cinterop { task cinterop {
@@ -180,7 +180,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
protected open fun Project.configureNativeTask(nativeTarget: KotlinNativeTarget): Task { protected open fun Project.configureNativeTask(nativeTarget: KotlinNativeTarget): Task {
val konanRun = createRunTask(this, "konanRun", nativeLinkTask, val konanRun = createRunTask(this, "konanRun", nativeLinkTask,
nativeExecutable, buildDir.resolve(nativeBenchResults).absolutePath).apply { nativeExecutable, layout.buildDirectory.file(nativeBenchResults).get().asFile.absolutePath).apply {
group = BENCHMARKING_GROUP group = BENCHMARKING_GROUP
description = "Runs the benchmark for Kotlin/Native." description = "Runs the benchmark for Kotlin/Native."
} }
@@ -222,7 +222,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
doLast { doLast {
val applicationName = benchmark.applicationName val applicationName = benchmark.applicationName
val benchContents = buildDir.resolve(nativeBenchResults).readText() val benchContents = layout.buildDirectory.file(nativeBenchResults).get().asFile.readText()
val nativeCompileTasks = if (benchmark.compileTasks.isEmpty()) { val nativeCompileTasks = if (benchmark.compileTasks.isEmpty()) {
listOf("linkBenchmark${benchmark.buildType.name.lowercase().replaceFirstChar { it.uppercase() }}ExecutableNative") listOf("linkBenchmark${benchmark.buildType.name.lowercase().replaceFirstChar { it.uppercase() }}ExecutableNative")
} else benchmark.compileTasks } else benchmark.compileTasks
@@ -239,7 +239,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
) )
val output = createJsonReport(properties) val output = createJsonReport(properties)
buildDir.resolve(nativeJson).writeText(output) layout.buildDirectory.file(nativeJson).get().asFile.writeText(output)
} }
} }
} }
@@ -40,11 +40,11 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
private fun Project.configureUtilityTasks() { private fun Project.configureUtilityTasks() {
tasks.create("configureBuild") { tasks.create("configureBuild") {
doLast { mkdir(buildDir) } doLast { mkdir(layout.buildDirectory.get().asFile) }
} }
tasks.create("clean", Delete::class.java) { tasks.create("clean", Delete::class.java) {
delete(buildDir) delete(layout.buildDirectory)
} }
} }
@@ -90,7 +90,7 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
repeatNumber, repeatNumber,
exitCodes exitCodes
) )
val nativeExecutable = buildDir.resolve("program${getNativeProgramExtension()}") val nativeExecutable = layout.buildDirectory.file("program${getNativeProgramExtension()}").get().asFile
val properties = commonBenchmarkProperties + mapOf( val properties = commonBenchmarkProperties + mapOf(
"type" to "native", "type" to "native",
"compilerVersion" to konanVersion, "compilerVersion" to konanVersion,
@@ -100,7 +100,7 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
"codeSize" to getCodeSizeBenchmark(applicationName, nativeExecutable.absolutePath) "codeSize" to getCodeSizeBenchmark(applicationName, nativeExecutable.absolutePath)
) )
val output = createJsonReport(properties) val output = createJsonReport(properties)
buildDir.resolve(nativeJson).writeText(output) layout.buildDirectory.file(nativeJson).get().asFile.writeText(output)
} }
konanRun.finalizedBy(this) konanRun.finalizedBy(this)
} }
@@ -44,7 +44,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
val applicationName = benchmark.applicationName val applicationName = benchmark.applicationName
val jarPath = (tasks.getByName("jvmJar") as Jar).archiveFile.get().asFile val jarPath = (tasks.getByName("jvmJar") as Jar).archiveFile.get().asFile
val jvmCompileTime = getJvmCompileTime(project, applicationName) val jvmCompileTime = getJvmCompileTime(project, applicationName)
val benchContents = buildDir.resolve(jvmBenchResults).readText() val benchContents = layout.buildDirectory.file(jvmBenchResults).get().asFile.readText()
val properties: Map<String, Any> = commonBenchmarkProperties + mapOf( val properties: Map<String, Any> = commonBenchmarkProperties + mapOf(
"type" to "jvm", "type" to "jvm",
@@ -55,7 +55,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
) )
val output = createJsonReport(properties) val output = createJsonReport(properties)
buildDir.resolve(jvmJson).writeText(output) layout.buildDirectory.file(jvmJson).get().asFile.writeText(output)
} }
jvmRun.finalizedBy(this) jvmRun.finalizedBy(this)
@@ -78,7 +78,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
args("-p", "${benchmark.applicationName}::") args("-p", "${benchmark.applicationName}::")
warmupCount = jvmWarmup warmupCount = jvmWarmup
repeatCount = attempts repeatCount = attempts
outputFileName = buildDir.resolve(jvmBenchResults).absolutePath outputFileName = layout.buildDirectory.file(jvmBenchResults).get().asFile.absolutePath
repeatingType = benchmark.repeatingType repeatingType = benchmark.repeatingType
} }
} }
@@ -53,7 +53,7 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
override val benchmarkExtensionName: String = "swiftBenchmark" override val benchmarkExtensionName: String = "swiftBenchmark"
override val Project.nativeExecutable: String override val Project.nativeExecutable: String
get() = Paths.get(buildDir.absolutePath, benchmark.applicationName).toString() get() = Paths.get(layout.buildDirectory.get().asFile.absolutePath, benchmark.applicationName).toString()
override val Project.nativeLinkTask: Task override val Project.nativeLinkTask: Task
get() = tasks.getByName("buildSwift") get() = tasks.getByName("buildSwift")
@@ -92,7 +92,7 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
val frameworkParentDirPath = framework.outputDirectory.absolutePath val frameworkParentDirPath = framework.outputDirectory.absolutePath
val options = listOf("-O", "-wmo", "-Xlinker", "-rpath", "-Xlinker", frameworkParentDirPath, "-F", frameworkParentDirPath) val options = listOf("-O", "-wmo", "-Xlinker", "-rpath", "-Xlinker", frameworkParentDirPath, "-F", frameworkParentDirPath)
compileSwift(project, nativeTarget.konanTarget, benchmark.swiftSources, options, compileSwift(project, nativeTarget.konanTarget, benchmark.swiftSources, options,
Paths.get(buildDir.absolutePath, benchmark.applicationName), false) Paths.get(layout.buildDirectory.get().asFile.absolutePath, benchmark.applicationName), false)
} }
} }
} }
@@ -1,6 +1,5 @@
import org.jetbrains.kotlin.MPPTools import org.jetbrains.kotlin.MPPTools
import org.jetbrains.kotlin.PlatformInfo import org.jetbrains.kotlin.PlatformInfo
import org.jetbrains.kotlin.RunJvmTask
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
buildscript { buildscript {
@@ -106,7 +105,7 @@ task konanJsonReport {
'compileTime' : [nativeCompileTime], 'compileTime' : [nativeCompileTime],
'codeSize' : MPPTools.getCodeSizeBenchmark(applicationName, nativeExecutable)] 'codeSize' : MPPTools.getCodeSizeBenchmark(applicationName, nativeExecutable)]
def output = MPPTools.createJsonReport(properties) def output = MPPTools.createJsonReport(properties)
new File("${buildDir.absolutePath}/${nativeJson}").write(output) layout.buildDirectory.file(nativeJson).get().asFile.write(output)
} }
} }
} }
@@ -16,7 +16,7 @@ task konanRun {
task configureBuild { task configureBuild {
doLast { doLast {
mkdir "${buildDir.absolutePath}" mkdir "${layout.buildDirectory.get().asFile.absolutePath}"
} }
} }
@@ -33,23 +33,21 @@ task configureBuild {
} }
task clean { task clean {
doLast { delete(layout.buildDirectory)
delete "${buildDir.absolutePath}"
}
} }
task konanJsonReport { task konanJsonReport {
doLast { doLast {
def nativeCompileTime = MPPTools.getCompileBenchmarkTime(project.ext.applicationName, project.ext.buildSteps.keySet(), def nativeCompileTime = MPPTools.getCompileBenchmarkTime(project.ext.applicationName, project.ext.buildSteps.keySet(),
project.ext.repeatNumber, exitCodes) project.ext.repeatNumber, exitCodes)
def nativeExecutable = "${buildDir.absolutePath}/program${MPPTools.getNativeProgramExtension()}" def nativeExecutable = layout.buildDirectory.file("program${MPPTools.getNativeProgramExtension()}").get().asFile.toString()
def properties = getCommonProperties() + ['type': 'native', def properties = getCommonProperties() + ['type': 'native',
'compilerVersion': "${konanVersion}".toString(), 'compilerVersion': "${konanVersion}".toString(),
'benchmarks': "[]", 'benchmarks': "[]",
'compileTime': nativeCompileTime, 'compileTime': nativeCompileTime,
'codeSize': MPPTools.getCodeSizeBenchmark(project.ext.applicationName, nativeExecutable) ] 'codeSize': MPPTools.getCodeSizeBenchmark(project.ext.applicationName, nativeExecutable) ]
def output = MPPTools.createJsonReport(properties) def output = MPPTools.createJsonReport(properties)
new File("${buildDir.absolutePath}/${nativeJson}").write(output) layout.buildDirectory.file(nativeJson).get().asFile.write(output)
} }
} }
task jvmRun { task jvmRun {
@@ -77,7 +77,7 @@ compileBenchmark {
command = listOf( command = listOf(
"$dist/bin/konanc$toolSuffix", "$dist/bin/konanc$toolSuffix",
"-ea", "-p", "program", "-ea", "-p", "program",
"-o", "${buildDir.absolutePath}/program$binarySuffix", "-o", layout.buildDirectory.file("program$binarySuffix").get().asFile.toString(),
"-l", "$videoplayerDir/build/classes/kotlin/videoPlayer/main/videoplayer-cinterop-ffmpeg.klib", "-l", "$videoplayerDir/build/classes/kotlin/videoPlayer/main/videoplayer-cinterop-ffmpeg.klib",
"-l", "$videoplayerDir/build/classes/kotlin/videoPlayer/main/videoplayer-cinterop-sdl.klib", "-l", "$videoplayerDir/build/classes/kotlin/videoPlayer/main/videoplayer-cinterop-sdl.klib",
"-Xmulti-platform", "$videoplayerDir/src/videoPlayerMain/kotlin", "-Xmulti-platform", "$videoplayerDir/src/videoPlayerMain/kotlin",
+1 -1
View File
@@ -70,7 +70,7 @@ konanTargetList.forEach { target ->
klibFiles(df.config.depends.map { "$konanHome/klib/platform/$targetName/${fileNamePrefix}${it}" }) klibFiles(df.config.depends.map { "$konanHome/klib/platform/$targetName/${fileNamePrefix}${it}" })
} }
extraOpts("-Xpurge-user-libs", "-Xshort-module-name", df.name, "-Xdisable-experimental-annotation") extraOpts("-Xpurge-user-libs", "-Xshort-module-name", df.name, "-Xdisable-experimental-annotation")
compilerOpts("-fmodules-cache-path=${project.buildDir}/clangModulesCache") compilerOpts("-fmodules-cache-path=${project.layout.buildDirectory.dir("clangModulesCache").get().asFile}")
} }
} }
+5 -7
View File
@@ -502,9 +502,7 @@ val hostAssemble by tasks.registering {
} }
tasks.named("clean") { tasks.named("clean") {
doFirst { delete(layout.buildDirectory)
delete(buildDir)
}
} }
// region: Stdlib // region: Stdlib
@@ -535,7 +533,7 @@ lateinit var stdlibBuildTask: TaskProvider<Task>
konanArtifacts { konanArtifacts {
library("stdlib") { library("stdlib") {
baseDir(project.buildDir.resolve("stdlib")) baseDir(project.layout.buildDirectory.dir("stdlib").get().asFile)
enableMultiplatform(true) enableMultiplatform(true)
noStdLib(true) noStdLib(true)
@@ -578,9 +576,9 @@ targetList.forEach { targetName ->
dependsOn(stdlibBuildTask) dependsOn(stdlibBuildTask)
dependsOn("${targetName}Runtime") dependsOn("${targetName}Runtime")
destinationDir = project.buildDir.resolve("${targetName}Stdlib") into(project.layout.buildDirectory.dir("${targetName}Stdlib"))
from(project.buildDir.resolve("stdlib/${hostName}/stdlib")) from(project.layout.buildDirectory.dir("stdlib/${hostName}/stdlib"))
val runtimeFiles = runtimeBitcode.incoming.artifactView { val runtimeFiles = runtimeBitcode.incoming.artifactView {
attributes { attributes {
attribute(TargetWithSanitizer.TARGET_ATTRIBUTE, project.platformManager.targetByName(targetName).withSanitizer()) attribute(TargetWithSanitizer.TARGET_ATTRIBUTE, project.platformManager.targetByName(targetName).withSanitizer())
@@ -614,7 +612,7 @@ targetList.forEach { targetName ->
target = targetName target = targetName
originalKlib.fileProvider(stdlibTask.map { it.destinationDir }) originalKlib.fileProvider(stdlibTask.map { it.destinationDir })
klibUniqName = "stdlib" klibUniqName = "stdlib"
cacheRoot = project.buildDir.resolve("cache/$targetName").absolutePath cacheRoot = project.layout.buildDirectory.dir("cache/$targetName").get().asFile.absolutePath
dependsOn(":kotlin-native:${targetName}CrossDistRuntime") dependsOn(":kotlin-native:${targetName}CrossDistRuntime")
} }
+3 -3
View File
@@ -13,17 +13,17 @@ val commonMainSources by task<Sync> {
"$rootDir/libraries/kotlin.test/common/src/main/kotlin", "$rootDir/libraries/kotlin.test/common/src/main/kotlin",
"$rootDir/libraries/kotlin.test/annotations-common/src/main/kotlin" "$rootDir/libraries/kotlin.test/annotations-common/src/main/kotlin"
) )
into("$buildDir/commonMainSources") into(layout.buildDirectory.dir("commonMainSources"))
} }
val commonTestSources by task<Sync> { val commonTestSources by task<Sync> {
from("$rootDir/libraries/kotlin.test/common/src/test/kotlin") from("$rootDir/libraries/kotlin.test/common/src/test/kotlin")
into("$buildDir/commonTestSources") into(layout.buildDirectory.dir("commonTestSources"))
} }
val jsMainSources by task<Sync> { val jsMainSources by task<Sync> {
from("$rootDir/libraries/kotlin.test/js/src/main/kotlin") from("$rootDir/libraries/kotlin.test/js/src/main/kotlin")
into("$buildDir/jsMainSources") into(layout.buildDirectory.dir("jsMainSources"))
} }
kotlin { kotlin {
+12 -12
View File
@@ -19,12 +19,12 @@ node {
val jsMainSources by task<Sync> { val jsMainSources by task<Sync> {
from("$rootDir/libraries/kotlin.test/js/it/src") from("$rootDir/libraries/kotlin.test/js/it/src")
into("$buildDir/jsMainSources") into(layout.buildDirectory.dir("jsMainSources"))
} }
val jsSources by task<Sync> { val jsSources by task<Sync> {
from("$rootDir/libraries/kotlin.test/js/it/js") from("$rootDir/libraries/kotlin.test/js/it/js")
into("$buildDir/jsSources") into(layout.buildDirectory.dir("jsSources"))
} }
val ignoreTestFailures by extra(project.kotlinBuildProperties.ignoreTestFailures) val ignoreTestFailures by extra(project.kotlinBuildProperties.ignoreTestFailures)
@@ -75,7 +75,7 @@ val populateNodeModules = tasks.register<Copy>("populateNodeModules") {
} }
} }
into("${buildDir}/node_modules") into(layout.buildDirectory.dir("node_modules"))
} }
fun createFrameworkTest(name: String): TaskProvider<NpmTask> { fun createFrameworkTest(name: String): TaskProvider<NpmTask> {
@@ -83,12 +83,12 @@ fun createFrameworkTest(name: String): TaskProvider<NpmTask> {
dependsOn(compileTestDevelopmentExecutableKotlinJs, populateNodeModules, "npmInstall") dependsOn(compileTestDevelopmentExecutableKotlinJs, populateNodeModules, "npmInstall")
val testName = name val testName = name
val lowerName = name.lowercase() val lowerName = name.lowercase()
val tcOutput = project.file("$buildDir/tc-${lowerName}.log") val tcOutput = layout.buildDirectory.file("tc-${lowerName}.log")
val stdOutput = "$buildDir/test-${lowerName}.log" val stdOutput = layout.buildDirectory.file("test-${lowerName}.log")
val errOutput = "$buildDir/test-${lowerName}.err.log" val errOutput = layout.buildDirectory.file("test-${lowerName}.err.log")
val exitCodeFile = project.file("$buildDir/test-${lowerName}.exit-code") val exitCodeFile = layout.buildDirectory.file("test-${lowerName}.exit-code")
// inputs.files(sourceSets.test.output) // inputs.files(sourceSets.test.output)
inputs.dir("${buildDir}/node_modules") inputs.dir(layout.buildDirectory.dir("node_modules"))
outputs.files(tcOutput, stdOutput, errOutput, exitCodeFile) outputs.files(tcOutput, stdOutput, errOutput, exitCodeFile)
args.set(listOf("run", "test-$lowerName")) args.set(listOf("run", "test-$lowerName"))
@@ -98,12 +98,12 @@ fun createFrameworkTest(name: String): TaskProvider<NpmTask> {
execOverrides { execOverrides {
isIgnoreExitValue = true isIgnoreExitValue = true
standardOutput = FileOutputStream(stdOutput) standardOutput = FileOutputStream(stdOutput.get().asFile)
errorOutput = FileOutputStream(errOutput) errorOutput = FileOutputStream(errOutput.get().asFile)
} }
doLast { doLast {
println(tcOutput.readText()) println(tcOutput.get().asFile.readText())
if (exitCodeFile.readText() != "0" /* && !rootProject.ignoreTestFailures*/) { if (exitCodeFile.get().asFile.readText() != "0" /* && !rootProject.ignoreTestFailures*/) {
throw GradleException("$testName integration test failed") throw GradleException("$testName integration test failed")
} }
@@ -79,7 +79,7 @@ apiValidation {
} }
tasks.dokkaHtml.configure { tasks.dokkaHtml.configure {
outputDirectory.set(buildDir.resolve("dokka")) outputDirectory.set(layout.buildDirectory.dir("dokka"))
pluginsMapConfiguration.set( pluginsMapConfiguration.set(
mapOf( mapOf(
"org.jetbrains.dokka.base.DokkaBase" "org.jetbrains.dokka.base.DokkaBase"
+1 -1
View File
@@ -25,7 +25,7 @@ configureJavaOnlyToolchain(JdkMajorVersion.JDK_1_8)
publish() publish()
val core = "$rootDir/core" val core = "$rootDir/core"
val relocatedCoreSrc = "$buildDir/core-relocated" val relocatedCoreSrc = "${layout.buildDirectory.get().asFile}/core-relocated"
val proguardDeps by configurations.creating val proguardDeps by configurations.creating
val proguardAdditionalInJars by configurations.creating val proguardAdditionalInJars by configurations.creating
@@ -68,7 +68,7 @@ val mavenPackagesToRelocate = listOf(
val relocatedJar by task<ShadowJar> { val relocatedJar by task<ShadowJar> {
configurations = listOf(embedded) configurations = listOf(embedded)
duplicatesStrategy = DuplicatesStrategy.INCLUDE duplicatesStrategy = DuplicatesStrategy.INCLUDE
destinationDirectory.set(File(buildDir, "libs")) destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("relocated") archiveClassifier.set("relocated")
transform(ComponentsXmlResourceTransformer()) transform(ComponentsXmlResourceTransformer())
@@ -82,8 +82,7 @@ val relocatedJar by task<ShadowJar> {
val normalizeComponentsXmlEndings by tasks.registering { val normalizeComponentsXmlEndings by tasks.registering {
dependsOn(relocatedJar) dependsOn(relocatedJar)
val outputDirectory = buildDir.resolve(name) val outputFile = layout.buildDirectory.file("$name/${ComponentsXmlResourceTransformer.COMPONENTS_XML_PATH}")
val outputFile = outputDirectory.resolve(ComponentsXmlResourceTransformer.COMPONENTS_XML_PATH)
val relocatedJarFile = project.provider { relocatedJar.get().singleOutputFile() } val relocatedJarFile = project.provider { relocatedJar.get().singleOutputFile() }
val archiveOperations = serviceOf<ArchiveOperations>() val archiveOperations = serviceOf<ArchiveOperations>()
outputs.file(outputFile) outputs.file(outputFile)
@@ -93,8 +92,9 @@ val normalizeComponentsXmlEndings by tasks.registering {
include { it.path == ComponentsXmlResourceTransformer.COMPONENTS_XML_PATH } include { it.path == ComponentsXmlResourceTransformer.COMPONENTS_XML_PATH }
}.single().readText() }.single().readText()
val processedComponentsXml = componentsXml.replace("\r\n", "\n") val processedComponentsXml = componentsXml.replace("\r\n", "\n")
outputDirectory.mkdirs() val outputAsFile = outputFile.get().asFile
outputFile.writeText(processedComponentsXml) outputAsFile.parentFile.mkdirs()
outputAsFile.writeText(processedComponentsXml)
} }
} }
@@ -123,7 +123,7 @@ val proguard by task<CacheableProguardTask> {
injars(mapOf("filter" to "!META-INF/versions/**,!kotlinx/coroutines/debug/**"), normalizedJar.get().outputs.files) injars(mapOf("filter" to "!META-INF/versions/**,!kotlinx/coroutines/debug/**"), normalizedJar.get().outputs.files)
outjars(fileFrom(buildDir, "libs", "$jarBaseName-$version-after-proguard.jar")) outjars(layout.buildDirectory.file("libs/$jarBaseName-$version-after-proguard.jar"))
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8)) javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8))
+6 -6
View File
@@ -46,10 +46,10 @@ dependencies {
} }
val builtinsDir = "${rootDir}/core/builtins" val builtinsDir = "${rootDir}/core/builtins"
val builtinsSrcDir = "${buildDir}/src/builtin-sources" val builtinsSrcDir = "${layout.buildDirectory.get().asFile}/src/builtin-sources"
val jsDir = "${projectDir}/js" val jsDir = "${projectDir}/js"
val jsBuiltinsSrcDir = "${buildDir}/src/js-builtin-sources" val jsBuiltinsSrcDir = "${layout.buildDirectory.get().asFile}/src/js-builtin-sources"
val commonOptIns = listOf( val commonOptIns = listOf(
"kotlin.ExperimentalMultiplatform", "kotlin.ExperimentalMultiplatform",
@@ -473,7 +473,7 @@ kotlin {
} }
} }
into("$buildDir/src/wasm-builtin-sources") into(layout.buildDirectory.dir("src/wasm-builtin-sources"))
} }
} }
@@ -527,7 +527,7 @@ kotlin {
val prepareKotlinTestCommonNativeSources by tasks.registering(Sync::class) { val prepareKotlinTestCommonNativeSources by tasks.registering(Sync::class) {
from("../kotlin.test/common/src/main/kotlin") from("../kotlin.test/common/src/main/kotlin")
from("../kotlin.test/annotations-common/src/main/kotlin") from("../kotlin.test/annotations-common/src/main/kotlin")
into("$buildDir/src/native-kotlin-test-common-sources") into(layout.buildDirectory.dir("src/native-kotlin-test-common-sources"))
} }
kotlin { kotlin {
@@ -642,13 +642,13 @@ tasks {
from(jsJar) from(jsJar)
rename { _ -> "full-runtime.klib" } rename { _ -> "full-runtime.klib" }
// some tests expect stdlib-js klib in this location // some tests expect stdlib-js klib in this location
into(rootProject.buildDir.resolve("js-ir-runtime")) into(rootProject.layout.buildDirectory.dir("js-ir-runtime"))
} }
val jsRearrangedSourcesJar by registering(Jar::class) { val jsRearrangedSourcesJar by registering(Jar::class) {
archiveClassifier.set("js-sources") archiveClassifier.set("js-sources")
archiveVersion.set("") archiveVersion.set("")
destinationDirectory.set(file("$buildDir/lib")) destinationDirectory.set(layout.buildDirectory.dir("lib"))
includeEmptyDirs = false includeEmptyDirs = false
duplicatesStrategy = DuplicatesStrategy.FAIL duplicatesStrategy = DuplicatesStrategy.FAIL
@@ -25,7 +25,7 @@ val commonMainFullSources by task<Sync> {
} }
} }
into("$buildDir/commonMainFullSources") into(layout.buildDirectory.dir("commonMainFullSources"))
} }
val commonMainSources by task<Sync> { val commonMainSources by task<Sync> {
@@ -72,7 +72,7 @@ val commonMainSources by task<Sync> {
commonMainFullSources.get().outputs.files.singleFile commonMainFullSources.get().outputs.files.singleFile
} }
into("$buildDir/commonMainSources") into(layout.buildDirectory.dir("commonMainSources"))
} }
val commonMainCollectionSources by task<Sync> { val commonMainCollectionSources by task<Sync> {
@@ -82,7 +82,7 @@ val commonMainCollectionSources by task<Sync> {
commonMainFullSources.get().outputs.files.singleFile commonMainFullSources.get().outputs.files.singleFile
} }
into("$buildDir/commonMainCollectionSources") into(layout.buildDirectory.dir("commonMainCollectionSources"))
} }
val jsMainSources by task<Sync> { val jsMainSources by task<Sync> {
@@ -131,7 +131,7 @@ val jsMainSources by task<Sync> {
into("builtins") into("builtins")
} }
into("$buildDir/jsMainSources") into(layout.buildDirectory.dir("jsMainSources"))
} }
kotlin { kotlin {
@@ -25,7 +25,7 @@ dependencies {
sourceSets { sourceSets {
"main" { "main" {
java.apply { java.apply {
srcDir(File(buildDir, "src")) srcDir(layout.buildDirectory.dir("src"))
} }
} }
"test" {} "test" {}
@@ -50,7 +50,7 @@ val copySources by task<Sync> {
"kotlin/enums/EnumEntries.kt", "kotlin/enums/EnumEntries.kt",
"kotlin/collections/AbstractList.kt", "kotlin/collections/AbstractList.kt",
"kotlin/io/Serializable.kt") "kotlin/io/Serializable.kt")
into(File(buildDir, "src")) into(layout.buildDirectory.dir("src"))
} }
@@ -91,6 +91,6 @@ publishing {
} }
repositories { repositories {
maven("${rootProject.buildDir}/internal/repo") maven(rootProject.layout.buildDirectory.dir("internal/repo"))
} }
} }
@@ -25,7 +25,7 @@ dependencies {
signature("org.codehaus.mojo.signature:java16:1.1@signature") signature("org.codehaus.mojo.signature:java16:1.1@signature")
} }
val signaturesDirectory = buildDir.resolve("signatures") val signaturesDirectory = layout.buildDirectory.get().asFile.resolve("signatures")
val collectSignatures by tasks.registering(Sync::class) { val collectSignatures by tasks.registering(Sync::class) {
from(signature) from(signature)
@@ -64,7 +64,7 @@ val outgoingClasspath by configurations.creating {
} }
tasks.register<Delete>("clean") { tasks.register<Delete>("clean") {
delete(project.buildDir) delete(layout.buildDirectory)
} }
//endregion //endregion
@@ -94,11 +94,12 @@ run {
implicitDependencies("com.google.protobuf:protoc:3.21.9:windows-x86_64@exe") implicitDependencies("com.google.protobuf:protoc:3.21.9:windows-x86_64@exe")
} }
val protocExecutable = buildDir.resolve("protoc/bin") val protocExecutable = layout.buildDirectory.file("protoc/bin")
val setupProtoc = tasks.register("setupProtoc") { val setupProtoc = tasks.register("setupProtoc") {
doFirst { doFirst {
protoc.files.single().copyTo(protocExecutable, overwrite = true) val protocFile = protocExecutable.get().asFile
protocExecutable.setExecutable(true) protoc.files.single().copyTo(protocFile, overwrite = true)
protocFile.setExecutable(true)
} }
} }
@@ -122,16 +123,16 @@ run {
workingDir(project.projectDir) workingDir(project.projectDir)
commandLine( argumentProviders.add {
*arrayOf( listOf(
protocExecutable.absolutePath, protocExecutable.get().asFile.absolutePath,
"-I=$protoSources", "-I=$protoSources",
"--java_out=${javaOutput.absolutePath}", "--java_out=${javaOutput.absolutePath}",
"--kotlin_out=${kotlinOutput.absolutePath}" "--kotlin_out=${kotlinOutput.absolutePath}"
) + protoSources.listFiles().orEmpty() ) + protoSources.listFiles().orEmpty()
.filter { it.extension == "proto" } .filter { it.extension == "proto" }
.map { it.path }, .map { it.path }
) }
} }
} }
@@ -126,7 +126,7 @@ val cleanTestKitCacheTask = tasks.register<Delete>("cleanTestKitCache") {
group = "Build" group = "Build"
description = "Deletes temporary Gradle TestKit cache" description = "Deletes temporary Gradle TestKit cache"
delete(project.buildDir.resolve("testKitCache")) delete(layout.buildDirectory.dir("testKitCache"))
} }
tasks.register<Delete>("cleanUserHomeKonanDir") { tasks.register<Delete>("cleanUserHomeKonanDir") {
@@ -7,7 +7,7 @@ plugins {
} }
repositories { repositories {
maven(project(":producer").buildDir.resolve("repo")) maven(project(":producer").layout.buildDirectory.dir("repo"))
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
} }
@@ -68,7 +68,7 @@ noDefaultJar()
val relocatedJar by task<ShadowJar> { val relocatedJar by task<ShadowJar> {
configurations = listOf(relocatedJarContents) configurations = listOf(relocatedJarContents)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDirectory.set(File(buildDir, "libs")) destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("before-proguard") archiveClassifier.set("before-proguard")
// don't add this files to resources classpath to avoid IDE exceptions on kotlin project // don't add this files to resources classpath to avoid IDE exceptions on kotlin project
@@ -87,7 +87,7 @@ val proguard by task<CacheableProguardTask> {
injars(mapOf("filter" to "!META-INF/versions/**,!kotlinx/coroutines/debug/**"), relocatedJar.get().outputs.files) injars(mapOf("filter" to "!META-INF/versions/**,!kotlinx/coroutines/debug/**"), relocatedJar.get().outputs.files)
outjars(fileFrom(buildDir, "libs", "$jarBaseName-$version-after-proguard.jar")) outjars(layout.buildDirectory.file("libs/$jarBaseName-$version-after-proguard.jar"))
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8)) javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8))
@@ -68,7 +68,7 @@ javadocJar()
testsJar() testsJar()
val robolectricDependencyDir = "$buildDir/robolectricDependencies" val robolectricDependencyDir = layout.buildDirectory.dir("robolectricDependencies")
val prepareRobolectricDependencies by tasks.registering(Copy::class) { val prepareRobolectricDependencies by tasks.registering(Copy::class) {
from(robolectricDependency) from(robolectricDependency)
into(robolectricDependencyDir) into(robolectricDependencyDir)
@@ -100,7 +100,7 @@ projectTest {
systemProperty("robolectric.classpath", robolectricClasspathProvider.get()) systemProperty("robolectric.classpath", robolectricClasspathProvider.get())
systemProperty("robolectric.offline", "true") systemProperty("robolectric.offline", "true")
systemProperty("robolectric.dependency.dir", robolectricDependencyDir) systemProperty("robolectric.dependency.dir", robolectricDependencyDir.get().asFile)
systemProperty("layoutLib.path", layoutLibConf.singleFile.canonicalPath) systemProperty("layoutLib.path", layoutLibConf.singleFile.canonicalPath)
systemProperty("layoutLibApi.path", layoutLibApiConf.singleFile.canonicalPath) systemProperty("layoutLibApi.path", layoutLibApiConf.singleFile.canonicalPath)
@@ -168,7 +168,7 @@ projectTest(jUnitMode = JUnitMode.JUnit5) {
// Exclude all tests with the "atomicfu-native" tag. They should be launched by another test task. // Exclude all tests with the "atomicfu-native" tag. They should be launched by another test task.
excludeTags("atomicfu-native") excludeTags("atomicfu-native")
} }
useJsIrBoxTests(version = version, buildDir = "$buildDir/") useJsIrBoxTests(version = version, buildDir = layout.buildDirectory)
workingDir = rootDir workingDir = rootDir
@@ -118,7 +118,7 @@ projectTest(parallel = true, jUnitMode = JUnitMode.JUnit5) {
val generateTests by generator("org.jetbrains.kotlinx.serialization.TestGeneratorKt") val generateTests by generator("org.jetbrains.kotlinx.serialization.TestGeneratorKt")
fun Test.setUpJsIrBoxTests() { fun Test.setUpJsIrBoxTests() {
useJsIrBoxTests(version = version, buildDir = "$buildDir/") useJsIrBoxTests(version = version, buildDir = layout.buildDirectory)
val localJsCoreRuntimeForTests: FileCollection = coreJsIrRuntimeForTests val localJsCoreRuntimeForTests: FileCollection = coreJsIrRuntimeForTests
val localJsJsonRuntimeForTests: FileCollection = jsonJsIrRuntimeForTests val localJsJsonRuntimeForTests: FileCollection = jsonJsIrRuntimeForTests
@@ -87,7 +87,7 @@ sourcesJar()
javadocJar() javadocJar()
testsJar() testsJar()
val robolectricDependencyDir = "$buildDir/robolectricDependencies" val robolectricDependencyDir = layout.buildDirectory.dir("robolectricDependencies")
val prepareRobolectricDependencies by tasks.registering(Copy::class) { val prepareRobolectricDependencies by tasks.registering(Copy::class) {
from(robolectricDependency) from(robolectricDependency)
into(robolectricDependencyDir) into(robolectricDependencyDir)
@@ -113,7 +113,7 @@ projectTest(jUnitMode = JUnitMode.JUnit5) {
systemProperty("robolectric.classpath", robolectricClasspathConf.asPath) systemProperty("robolectric.classpath", robolectricClasspathConf.asPath)
systemProperty("robolectric.offline", "true") systemProperty("robolectric.offline", "true")
systemProperty("robolectric.dependency.dir", robolectricDependencyDir) systemProperty("robolectric.dependency.dir", robolectricDependencyDir.get().asFile)
systemProperty("layoutLib.path", layoutLibConf.singleFile.canonicalPath) systemProperty("layoutLib.path", layoutLibConf.singleFile.canonicalPath)
systemProperty("layoutLibApi.path", layoutLibApiConf.singleFile.canonicalPath) systemProperty("layoutLibApi.path", layoutLibApiConf.singleFile.canonicalPath)
+7 -5
View File
@@ -2,23 +2,25 @@
import java.io.File import java.io.File
val buildVersionFilePath = "$buildDir/build.txt" val buildVersionFilePath = layout.buildDirectory.file("build.txt")
val buildVersion by configurations.creating val buildVersion by configurations.creating
val buildNumber: String by rootProject.extra val buildNumber: String by rootProject.extra
val kotlinVersion: String by rootProject.extra val kotlinVersion: String by rootProject.extra
val writeBuildNumber by tasks.registering { val writeBuildNumber by tasks.registering {
val versionFile = File(buildVersionFilePath) val versionFile = buildVersionFilePath
val buildNumber = buildNumber val buildNumber = buildNumber
inputs.property("version", buildNumber) inputs.property("version", buildNumber)
outputs.file(versionFile) outputs.file(versionFile)
doLast { doLast {
versionFile.parentFile.mkdirs() with(versionFile.get().asFile) {
versionFile.writeText(buildNumber) parentFile.mkdirs()
writeText(buildNumber)
}
} }
} }
artifacts.add(buildVersion.name, file(buildVersionFilePath)) { artifacts.add(buildVersion.name, buildVersionFilePath) {
builtBy(writeBuildNumber) builtBy(writeBuildNumber)
} }
+3 -5
View File
@@ -80,8 +80,6 @@ val buildNumber by configurations.creating
val compilerBaseName = name val compilerBaseName = name
val outputJar = fileFrom(buildDir, "libs", "$compilerBaseName.jar")
val compilerModules: Array<String> by rootProject.extra val compilerModules: Array<String> by rootProject.extra
val distLibraryProjects = listOfNotNull( val distLibraryProjects = listOfNotNull(
@@ -261,7 +259,7 @@ val distSbomTask = configureSbom(
val packCompiler by task<Jar> { val packCompiler by task<Jar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDirectory.set(File(buildDir, "libs")) destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("before-proguard") archiveClassifier.set("before-proguard")
dependsOn(fatJarContents) dependsOn(fatJarContents)
@@ -315,7 +313,7 @@ val proguard by task<CacheableProguardTask> {
provider { packCompiler.get().outputs.files.singleFile } provider { packCompiler.get().outputs.files.singleFile }
) )
outjars(fileFrom(buildDir, "libs", "$compilerBaseName-after-proguard.jar")) outjars(layout.buildDirectory.file("libs/$compilerBaseName-after-proguard.jar"))
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraries) libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraries)
libraryjars( libraryjars(
@@ -340,7 +338,7 @@ val proguard by task<CacheableProguardTask> {
) )
) )
printconfiguration("$buildDir/compiler.pro.dump") printconfiguration(layout.buildDirectory.file("compiler.pro.dump"))
} }
val pack = if (kotlinBuildProperties.proguard) proguard else packCompiler val pack = if (kotlinBuildProperties.proguard) proguard else packCompiler
@@ -44,7 +44,7 @@ idePluginDependency {
val shadowJar by task<ShadowJar> { val shadowJar by task<ShadowJar> {
configurations = listOf(embedded) configurations = listOf(embedded)
duplicatesStrategy = DuplicatesStrategy.FAIL duplicatesStrategy = DuplicatesStrategy.FAIL
destinationDirectory.set(File(buildDir, "libs")) destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("shadow") archiveClassifier.set("shadow")
} }
@@ -53,7 +53,7 @@ idePluginDependency {
configuration(fileFrom(projectDir, "backend-native-for-ide.pro")) configuration(fileFrom(projectDir, "backend-native-for-ide.pro"))
injars(mapOf("filter" to "!META-INF/versions/**"), shadowJar.get().outputs.files) injars(mapOf("filter" to "!META-INF/versions/**"), shadowJar.get().outputs.files)
outjars(fileFrom(buildDir, "libs", "$jarBaseName-$version-after-proguard.jar")) outjars(layout.buildDirectory.file("libs/$jarBaseName-$version-after-proguard.jar"))
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8)) javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8))
@@ -80,15 +80,16 @@ fun Project.configureCommonPublicationSettingsForGradle(
.configureEach { .configureEach {
configureKotlinPomAttributes(project) configureKotlinPomAttributes(project)
if (sbom && project.name !in internalPlugins) { if (sbom && project.name !in internalPlugins) {
val buildDirectory = project.layout.buildDirectory
if (name == "pluginMaven") { if (name == "pluginMaven") {
val sbomTask = configureSbom(target = "PluginMaven") val sbomTask = configureSbom(target = "PluginMaven")
artifact("$buildDir/spdx/PluginMaven/PluginMaven.spdx.json") { artifact(buildDirectory.file("spdx/PluginMaven/PluginMaven.spdx.json")) {
extension = "spdx.json" extension = "spdx.json"
builtBy(sbomTask) builtBy(sbomTask)
} }
} else if (name == "Main") { } else if (name == "Main") {
val sbomTask = configureSbom() val sbomTask = configureSbom()
artifact("$buildDir/spdx/MainPublication/MainPublication.spdx.json") { artifact(buildDirectory.file("spdx/MainPublication/MainPublication.spdx.json")) {
extension = "spdx.json" extension = "spdx.json"
builtBy(sbomTask) builtBy(sbomTask)
} }
@@ -28,7 +28,7 @@ class InstrumentJava(@Transient val javaInstrumentator: Configuration) : Action<
// Javac.execute() - https://github.com/apache/ant/blob/9943641/src/main/org/apache/tools/ant/taskdefs/Javac.java#L1086 // Javac.execute() - https://github.com/apache/ant/blob/9943641/src/main/org/apache/tools/ant/taskdefs/Javac.java#L1086
// InstrumentIdeaExtensions - https://github.com/JetBrains/intellij-community/blob/9c40bdd/java/compiler/javac2/src/com/intellij/ant/InstrumentIdeaExtensions.java // InstrumentIdeaExtensions - https://github.com/JetBrains/intellij-community/blob/9c40bdd/java/compiler/javac2/src/com/intellij/ant/InstrumentIdeaExtensions.java
// Javac2.compile() - https://github.com/JetBrains/intellij-community/blob/9c40bdd/java/compiler/javac2/src/com/intellij/ant/Javac2.java#L237 // Javac2.compile() - https://github.com/JetBrains/intellij-community/blob/9c40bdd/java/compiler/javac2/src/com/intellij/ant/Javac2.java#L237
val dummyInstrumentSrcDir = File(task.project.buildDir, "instrument_dummy_src") val dummyInstrumentSrcDir = task.project.layout.buildDirectory.dir("instrument_dummy_src").get().asFile
val dummyInstrumentSrcRelativePath = dummyInstrumentSrcDir.relativeTo(task.project.projectDir).path.replace("\\", "/") val dummyInstrumentSrcRelativePath = dummyInstrumentSrcDir.relativeTo(task.project.projectDir).path.replace("\\", "/")
task.doLast { task.doLast {
@@ -163,15 +163,14 @@ fun Project.configureKotlinCompilationOptions() {
} }
} }
val relativePathBaseArg: String? = val layout = project.layout
"-Xklib-relative-path-base=$buildDir,$projectDir,$rootDir".takeIf { val rootDir = rootDir
!kotlinBuildProperties.getBoolean("kotlin.build.use.absolute.paths.in.klib") val useAbsolutePathsInKlib = kotlinBuildProperties.getBoolean("kotlin.build.use.absolute.paths.in.klib")
}
// Workaround to avoid remote build cache misses due to absolute paths in relativePathBaseArg // Workaround to avoid remote build cache misses due to absolute paths in relativePathBaseArg
doFirst { doFirst {
if (relativePathBaseArg != null) { if (!useAbsolutePathsInKlib) {
kotlinOptions.freeCompilerArgs += relativePathBaseArg kotlinOptions.freeCompilerArgs += "-Xklib-relative-path-base=${layout.buildDirectory.get().asFile},${layout.projectDirectory.asFile},$rootDir"
} }
} }
} }
@@ -88,7 +88,7 @@ private fun Project.compilerShadowJar(taskName: String, body: ShadowJar.() -> Un
dependencies.add(compilerJar.name, dependencies.project(":kotlin-compiler")) { isTransitive = false } dependencies.add(compilerJar.name, dependencies.project(":kotlin-compiler")) { isTransitive = false }
return tasks.register<ShadowJar>(taskName) { return tasks.register<ShadowJar>(taskName) {
destinationDirectory.set(project.file(File(buildDir, "libs"))) destinationDirectory.set(project.layout.buildDirectory.dir("libs"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(compilerJar) from(compilerJar)
body() body()
@@ -136,7 +136,7 @@ fun Project.embeddableCompilerDummyForDependenciesRewriting(
) )
return tasks.register<ShadowJar>(taskName) { return tasks.register<ShadowJar>(taskName) {
destinationDirectory.set(project.file(File(buildDir, "libs"))) destinationDirectory.set(project.layout.buildDirectory.dir("libs"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(compilerDummyJar) from(compilerDummyJar)
configureEmbeddableCompilerRelocation(withJavaxInject = false) configureEmbeddableCompilerRelocation(withJavaxInject = false)
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.ideaExt.*
val ideaSdkPath: String val ideaSdkPath: String
get() = rootProject.ideaHomePathForTests().absolutePath get() = rootProject.ideaHomePathForTests().get().asFile.absolutePath
val distDir by extra("$rootDir/dist") val distDir by extra("$rootDir/dist")
val distKotlinHomeDir by extra("$distDir/kotlinc") val distKotlinHomeDir by extra("$distDir/kotlinc")
@@ -126,11 +126,11 @@ object IntellijRootUtils {
} }
} }
fun Project.ideaHomePathForTests() = rootProject.buildDir.resolve("ideaHomeForTests") fun Project.ideaHomePathForTests() = rootProject.layout.buildDirectory.dir("ideaHomeForTests")
fun Project.ideaBuildNumberFileForTests() = File(ideaHomePathForTests(), "build.txt") fun Project.ideaBuildNumberFileForTests() = objects.directoryProperty().value(ideaHomePathForTests()).file("build.txt")
fun Project.writeIdeaBuildNumberForTests() { fun Project.writeIdeaBuildNumberForTests() {
ideaHomePathForTests().mkdirs() ideaHomePathForTests().get().asFile.mkdirs()
ideaBuildNumberFileForTests().writeText("IC-${rootProject.extra["versions.intellijSdk"]}") ideaBuildNumberFileForTests().get().asFile.writeText("IC-${rootProject.extra["versions.intellijSdk"]}")
} }
@@ -1,17 +1,10 @@
@file:Suppress("UnstableApiUsage") @file:Suppress("UnstableApiUsage")
import org.gradle.jvm.tasks.Jar
import org.jetbrains.gradle.ext.ActionDelegationConfig
import org.jetbrains.gradle.ext.JUnit
import org.jetbrains.gradle.ext.RecursiveArtifact
import org.jetbrains.gradle.ext.TopLevelArtifact
import org.jetbrains.kotlin.ideaExt.*
val distDir: String by extra val distDir: String by extra
val ideaSandboxDir: File by extra val ideaSandboxDir: File by extra
val ideaSdkPath: String val ideaSdkPath: String
get() = rootProject.ideaHomePathForTests().absolutePath get() = rootProject.ideaHomePathForTests().get().asFile.absolutePath
fun MutableList<String>.addModularizedTestArgs(prefix: String, path: String, additionalParameters: Map<String, String>, benchFilter: String?) { fun MutableList<String>.addModularizedTestArgs(prefix: String, path: String, additionalParameters: Map<String, String>, benchFilter: String?) {
add("-${prefix}fir.bench.prefix=$path") add("-${prefix}fir.bench.prefix=$path")
@@ -23,7 +23,11 @@ fun Project.preparePublication() {
val sonatypeSnapshotsUrl = "https://oss.sonatype.org/content/repositories/snapshots/".takeIf { repo == "sonatype-nexus-snapshots" } val sonatypeSnapshotsUrl = "https://oss.sonatype.org/content/repositories/snapshots/".takeIf { repo == "sonatype-nexus-snapshots" }
val repoUrl: String by extra((deployRepoUrl ?: sonatypeSnapshotsUrl ?: "file://${rootProject.buildDir}/repo").toString()) val repoUrl: String by extra(
(deployRepoUrl ?: sonatypeSnapshotsUrl ?: "file://${
rootProject.layout.buildDirectory.dir("repo").get().asFile
}").toString()
)
val username: String? by extra( val username: String? by extra(
properties["kotlin.build.deploy-username"]?.toString() ?: properties["kotlin.${repoProvider}.user"]?.toString() properties["kotlin.build.deploy-username"]?.toString() ?: properties["kotlin.${repoProvider}.user"]?.toString()
@@ -2,11 +2,13 @@
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * 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.gradle.api.file.Directory
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.Test
fun Test.useJsIrBoxTests( fun Test.useJsIrBoxTests(
version: Any, version: Any,
buildDir: String = "", buildDir: Provider<Directory>,
fullStdLib: String = "libraries/stdlib/build/classes/kotlin/js/main", fullStdLib: String = "libraries/stdlib/build/classes/kotlin/js/main",
reducedStdlibPath: String = "libraries/stdlib/js-ir-minimal-for-test/build/classes/kotlin/js/main", reducedStdlibPath: String = "libraries/stdlib/js-ir-minimal-for-test/build/classes/kotlin/js/main",
kotlinJsTestPath: String = "libraries/kotlin.test/js-ir/build/classes/kotlin/js/main", kotlinJsTestPath: String = "libraries/kotlin.test/js-ir/build/classes/kotlin/js/main",
@@ -20,7 +22,7 @@ fun Test.useJsIrBoxTests(
dependsOn(":kotlin-stdlib-js-ir-minimal-for-test:compileKotlinJs") dependsOn(":kotlin-stdlib-js-ir-minimal-for-test:compileKotlinJs")
dependsOn(":kotlin-dom-api-compat:compileKotlinJs") dependsOn(":kotlin-dom-api-compat:compileKotlinJs")
systemProperty("kotlin.js.test.root.out.dir", buildDir) systemProperty("kotlin.js.test.root.out.dir", "${buildDir.get().asFile}/")
systemProperty("kotlin.js.full.stdlib.path", fullStdLib) systemProperty("kotlin.js.full.stdlib.path", fullStdLib)
systemProperty("kotlin.js.reduced.stdlib.path", reducedStdlibPath) systemProperty("kotlin.js.reduced.stdlib.path", reducedStdlibPath)
systemProperty("kotlin.js.kotlin.test.path", kotlinJsTestPath) systemProperty("kotlin.js.kotlin.test.path", kotlinJsTestPath)
@@ -206,12 +206,12 @@ fun Project.projectTest(
} }
systemProperty("idea.is.unit.test", "true") systemProperty("idea.is.unit.test", "true")
systemProperty("idea.home.path", project.ideaHomePathForTests().canonicalPath) systemProperty("idea.home.path", project.ideaHomePathForTests().get().asFile.canonicalPath)
systemProperty("idea.use.native.fs.for.win", false) systemProperty("idea.use.native.fs.for.win", false)
systemProperty("java.awt.headless", "true") systemProperty("java.awt.headless", "true")
environment("NO_FS_ROOTS_ACCESS_CHECK", "true") environment("NO_FS_ROOTS_ACCESS_CHECK", "true")
environment("PROJECT_CLASSES_DIRS", project.testSourceSet.output.classesDirs.asPath) environment("PROJECT_CLASSES_DIRS", project.testSourceSet.output.classesDirs.asPath)
environment("PROJECT_BUILD_DIR", project.buildDir) environment("PROJECT_BUILD_DIR", project.layout.buildDirectory.get().asFile)
systemProperty("jps.kotlin.home", project.rootProject.extra["distKotlinHomeDir"]!!) systemProperty("jps.kotlin.home", project.rootProject.extra["distKotlinHomeDir"]!!)
systemProperty("org.jetbrains.kotlin.skip.muted.tests", if (project.rootProject.hasProperty("skipMutedTests")) "true" else "false") systemProperty("org.jetbrains.kotlin.skip.muted.tests", if (project.rootProject.hasProperty("skipMutedTests")) "true" else "false")
systemProperty("cacheRedirectorEnabled", project.rootProject.findProperty("cacheRedirectorEnabled")?.toString() ?: "false") systemProperty("cacheRedirectorEnabled", project.rootProject.findProperty("cacheRedirectorEnabled")?.toString() ?: "false")
@@ -19,13 +19,13 @@ private fun Project.createCommonMainSources() = tasks.register("commonMainSource
"$rootDir/libraries/kotlin.test/common/src/main/kotlin", "$rootDir/libraries/kotlin.test/common/src/main/kotlin",
"$rootDir/libraries/kotlin.test/annotations-common/src/main/kotlin", "$rootDir/libraries/kotlin.test/annotations-common/src/main/kotlin",
) )
into("$buildDir/commonMainSources") into(layout.buildDirectory.dir("commonMainSources"))
} }
private fun Project.createCommonWasmSources() = tasks.register<Sync>("commonWasmSources") { private fun Project.createCommonWasmSources() = tasks.register<Sync>("commonWasmSources") {
from( from(
"$rootDir/libraries/kotlin.test/wasm/src/main/kotlin" "$rootDir/libraries/kotlin.test/wasm/src/main/kotlin"
) )
into("$buildDir/commonWasmSources") into(layout.buildDirectory.dir("commonWasmSources"))
} }
fun Project.configureWasmKotlinTest( fun Project.configureWasmKotlinTest(
+2 -2
View File
@@ -26,10 +26,10 @@ repositories {
} }
} }
val wabtDir = File(buildDir, "wabt") val wabtDir = File(layout.buildDirectory.get().asFile, "wabt")
val wabtVersion = "1.0.19" val wabtVersion = "1.0.19"
val testSuiteRevision = "18f8340" val testSuiteRevision = "18f8340"
val testSuiteDir = File(buildDir, "testsuite") val testSuiteDir = File(layout.buildDirectory.get().asFile, "testsuite")
val gradleOs = org.gradle.internal.os.OperatingSystem.current() val gradleOs = org.gradle.internal.os.OperatingSystem.current()
val wabtOS = when { val wabtOS = when {
+2 -5
View File
@@ -113,15 +113,12 @@ fun Test.setupGradlePropertiesForwarding() {
} }
} }
val downloadedTools = File(buildDir, "tools")
val unzipJsShell by task<Copy> { val unzipJsShell by task<Copy> {
dependsOn(jsShell) dependsOn(jsShell)
from { from {
zipTree(jsShell.singleFile) zipTree(jsShell.singleFile)
} }
val unpackedDir = File(downloadedTools, "jsshell-$jsShellSuffix-$jsShellVersion") into(layout.buildDirectory.dir("tools/jsshell-$jsShellSuffix-$jsShellVersion"))
into(unpackedDir)
} }
fun Test.setupSpiderMonkey() { fun Test.setupSpiderMonkey() {
@@ -153,7 +150,7 @@ fun Project.wasmProjectTest(
setupWasmStdlib("js") setupWasmStdlib("js")
setupWasmStdlib("wasi") setupWasmStdlib("wasi")
setupGradlePropertiesForwarding() setupGradlePropertiesForwarding()
systemProperty("kotlin.wasm.test.root.out.dir", "$buildDir/") systemProperty("kotlin.wasm.test.root.out.dir", "${layout.buildDirectory.get().asFile}/")
body() body()
} }
} }