[Endorsed libs] Provide FQ name for kotlinx-cli
Fix for https://youtrack.jetbrains.com/issue/KT-36720
This commit is contained in:
committed by
Ilya Matveev
parent
016d56bb5d
commit
003001e6c6
@@ -0,0 +1,13 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.gradle.api.Project
|
||||
|
||||
data class EndorsedLibraryInfo(val project: Project, val name: String) {
|
||||
|
||||
val projectName: String
|
||||
get() = project.name
|
||||
|
||||
val taskName: String by lazy {
|
||||
projectName.split('.').joinToString(separator = "") { it.capitalize() }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import org.jetbrains.kotlin.UtilsKt
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.tasks.KonanCacheTask
|
||||
import org.jetbrains.kotlin.EndorsedLibraryInfo
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
@@ -11,14 +12,14 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
def endorsedLibrariesList = ['kotlinx.cli']
|
||||
|
||||
def toTaskName(library) {
|
||||
def name = ""
|
||||
library.split("\\.").each { word -> name += word.capitalize() }
|
||||
return name
|
||||
ext {
|
||||
endorsedLibraries = [
|
||||
new EndorsedLibraryInfo(project('kotlinx.cli'), "org.jetbrains.kotlinx.kotlinx-cli")
|
||||
].collectEntries { [it.project, it] }
|
||||
}
|
||||
|
||||
Collection<EndorsedLibraryInfo> endorsedLibrariesList = ext.endorsedLibraries.values()
|
||||
|
||||
task clean {
|
||||
doLast {
|
||||
delete buildDir
|
||||
@@ -27,7 +28,7 @@ task clean {
|
||||
|
||||
task jvmJar {
|
||||
endorsedLibrariesList.each { library ->
|
||||
dependsOn "$library:jvmJar"
|
||||
dependsOn "$library.projectName:jvmJar"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +36,15 @@ task jvmJar {
|
||||
targetList.each { target ->
|
||||
task("${target}EndorsedLibraries", type: Copy) {
|
||||
endorsedLibrariesList.each { library ->
|
||||
dependsOn "$library:${target}${ toTaskName(library) }"
|
||||
dependsOn "$library.projectName:${target}${library.taskName}"
|
||||
}
|
||||
|
||||
destinationDir project.buildDir
|
||||
|
||||
endorsedLibrariesList.each { library ->
|
||||
from(project("$library").file("build/${target}${ toTaskName(library) }")) {
|
||||
from(library.project.file("build/${target}${library.taskName}")) {
|
||||
include('**')
|
||||
into("${library.replaceAll("\\.", "-")}")
|
||||
into(library.name)
|
||||
eachFile {
|
||||
if (name == 'manifest') {
|
||||
def existingManifest = file("$destinationDir/$path")
|
||||
@@ -61,11 +62,10 @@ targetList.each { target ->
|
||||
def cacheTask = task("${target}Cache")
|
||||
|
||||
endorsedLibrariesList.each { library ->
|
||||
def libraryName = library.replaceAll("\\.", "-")
|
||||
def dist = rootProject.file("dist")
|
||||
task("${target}${toTaskName(library)}Cache", type: KonanCacheTask) {
|
||||
task("${target}${library.taskName}Cache", type: KonanCacheTask) {
|
||||
it.target = target
|
||||
originalKlib = file("${project.buildDir}/$libraryName")
|
||||
originalKlib = file("${project.buildDir}/${library.name}")
|
||||
cacheRoot = file("$dist/klib/cache")
|
||||
compilerDistributionPath.set(distDir)
|
||||
|
||||
@@ -80,29 +80,29 @@ targetList.each { target ->
|
||||
}
|
||||
|
||||
endorsedLibrariesList.each { library ->
|
||||
task("${toTaskName(library)}CommonSources", type: Zip) {
|
||||
task("${library.taskName}CommonSources", type: Zip) {
|
||||
destinationDirectory = file("${rootProject.projectDir}/dist/sources")
|
||||
archiveFileName = "${library.replaceAll("\\.", "-")}-common-sources.zip"
|
||||
archiveFileName = "${library.name}-common-sources.zip"
|
||||
|
||||
includeEmptyDirs = false
|
||||
include('**/*.kt')
|
||||
|
||||
from(project(":endorsedLibraries:${library}").file('src/main/kotlin'))
|
||||
from(library.project.file('src/main/kotlin'))
|
||||
}
|
||||
task("${toTaskName(library)}NativeSources", type: Zip) {
|
||||
task("${library.taskName}NativeSources", type: Zip) {
|
||||
destinationDirectory = file("${rootProject.projectDir}/dist/sources")
|
||||
archiveFileName = "${library.replaceAll("\\.", "-")}-native-sources.zip"
|
||||
archiveFileName = "${library.name}-native-sources.zip"
|
||||
|
||||
includeEmptyDirs = false
|
||||
include('**/*.kt')
|
||||
|
||||
from(project(":endorsedLibraries:${library}").file('src/main/kotlin-native'))
|
||||
from(library.project.file('src/main/kotlin-native'))
|
||||
}
|
||||
}
|
||||
|
||||
task endorsedLibsSources {
|
||||
endorsedLibrariesList.each { library ->
|
||||
dependsOn "${toTaskName(library)}CommonSources"
|
||||
dependsOn "${toTaskName(library)}NativeSources"
|
||||
dependsOn "${library.taskName}CommonSources"
|
||||
dependsOn "${library.taskName}NativeSources"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.util.PlatformLibsInfo
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
@@ -84,14 +85,18 @@ targetList.each { target ->
|
||||
*project.globalBuildArgs]
|
||||
|
||||
task("${target}KotlinxCli", type: JavaExec) {
|
||||
def outputFile = project.file("build/${target}KotlinxCli")
|
||||
// See :endorsedLibraries.ext for full endorsedLibraries list.
|
||||
def moduleName = endorsedLibraries[project].name
|
||||
|
||||
dependsOn ":${target}CrossDistRuntime"
|
||||
|
||||
main = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
|
||||
classpath = project(":backend.native").configurations.cli_bc
|
||||
jvmArgs = konanJvmArgs
|
||||
args = [*konanArgs,
|
||||
'-output', project.file("build/${target}KotlinxCli"),
|
||||
'-produce', 'library', '-module-name', 'kotlinx-cli', '-XXLanguage:+AllowContractsForCustomFunctions',
|
||||
'-output', outputFile,
|
||||
'-produce', 'library', '-module-name', moduleName, '-XXLanguage:+AllowContractsForCustomFunctions',
|
||||
'-Xmulti-platform', '-Xopt-in=kotlinx.cli.ExperimentalCli',
|
||||
'-Xopt-in=kotlin.ExperimentalMultiplatform',
|
||||
'-Xallow-result-return-type',
|
||||
@@ -100,6 +105,6 @@ targetList.each { target ->
|
||||
nativeSrc]
|
||||
inputs.dir(nativeSrc)
|
||||
inputs.dir(commonSrc)
|
||||
outputs.dir(project.file("build/${target}KotlinxCli"))
|
||||
outputs.dir(outputFile)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user