361d922119
Rewrite to kts and use konan plugin instead of simple JavaExec task. Produce cache in the project instead of the upper one.
110 lines
3.4 KiB
Groovy
110 lines
3.4 KiB
Groovy
import org.jetbrains.kotlin.UtilsKt
|
|
import org.jetbrains.kotlin.gradle.plugin.konan.tasks.KonanCacheTask
|
|
import org.jetbrains.kotlin.EndorsedLibraryInfo
|
|
import org.jetbrains.kotlin.UtilsKt
|
|
import org.jetbrains.kotlin.konan.target.HostManager
|
|
|
|
apply plugin: 'konan'
|
|
|
|
buildscript {
|
|
repositories {
|
|
if (UtilsKt.getCacheRedirectorEnabled(project))
|
|
maven { url 'https://cache-redirector.jetbrains.com/jcenter' }
|
|
else
|
|
jcenter()
|
|
}
|
|
}
|
|
|
|
if (HostManager.host.name == "macos_arm64") {
|
|
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_17)
|
|
}
|
|
|
|
ext {
|
|
endorsedLibraries = [
|
|
new EndorsedLibraryInfo(project('kotlinx.cli'), "org.jetbrains.kotlinx.kotlinx-cli")
|
|
].collectEntries { [it.project, it] }
|
|
}
|
|
|
|
Collection<EndorsedLibraryInfo> endorsedLibrariesList = ext.endorsedLibraries.values()
|
|
|
|
tasks.named("clean") {
|
|
doFirst {
|
|
delete buildDir
|
|
}
|
|
}
|
|
|
|
task jvmJar {
|
|
endorsedLibrariesList.each { library ->
|
|
dependsOn "$library.projectName:jvmJar"
|
|
}
|
|
}
|
|
|
|
// Build all default libraries.
|
|
targetList.each { target ->
|
|
task("${target}EndorsedLibraries") {
|
|
endorsedLibrariesList.each { library ->
|
|
dependsOn task("${target}${library.name}EndorsedLibraries", type: Copy) {
|
|
dependsOn "$library.projectName:${target}${library.name}"
|
|
destinationDir project.file("${project.buildDir}/${library.name}")
|
|
|
|
from(library.project.file("build/${target}${library.name}")) {
|
|
include('**')
|
|
eachFile {
|
|
if (name == 'manifest') {
|
|
def existingManifest = file("$destinationDir/$path")
|
|
if (existingManifest.exists()) {
|
|
UtilsKt.mergeManifestsByTargets(project, file, existingManifest)
|
|
exclude()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (target in cacheableTargetNames) {
|
|
def cacheTask = task("${target}Cache", type: Copy) {
|
|
destinationDir project.file("${project.buildDir}/cache/$target")
|
|
|
|
endorsedLibrariesList.each { library ->
|
|
from(library.project.file("build/cache/$target")) {
|
|
include('**')
|
|
}
|
|
}
|
|
}
|
|
|
|
endorsedLibrariesList.each { library ->
|
|
cacheTask.dependsOn "${library.projectName}:${target}${library.taskName}Cache"
|
|
}
|
|
}
|
|
}
|
|
|
|
endorsedLibrariesList.each { library ->
|
|
task("${library.taskName}CommonSources", type: Zip) {
|
|
destinationDirectory = file("${UtilsKt.getKotlinNativeDist(project)}/sources")
|
|
archiveFileName = "${library.name}-common-sources.zip"
|
|
|
|
includeEmptyDirs = false
|
|
include('**/*.kt')
|
|
|
|
from(library.project.file('src/main/kotlin'))
|
|
}
|
|
task("${library.taskName}NativeSources", type: Zip) {
|
|
destinationDirectory = file("${UtilsKt.getKotlinNativeDist(project)}/sources")
|
|
archiveFileName = "${library.name}-native-sources.zip"
|
|
|
|
includeEmptyDirs = false
|
|
include('**/*.kt')
|
|
|
|
from(library.project.file('src/main/kotlin-native'))
|
|
}
|
|
}
|
|
|
|
task endorsedLibsSources {
|
|
endorsedLibrariesList.each { library ->
|
|
dependsOn "${library.taskName}CommonSources"
|
|
dependsOn "${library.taskName}NativeSources"
|
|
}
|
|
}
|