[Gradle, K/N] Add consumable configuration with K/N frameworks
This commit is contained in:
+4
@@ -129,6 +129,10 @@ open class KotlinNativeTarget @Inject constructor(
|
|||||||
"org.jetbrains.kotlin.native.target",
|
"org.jetbrains.kotlin.native.target",
|
||||||
String::class.java
|
String::class.java
|
||||||
)
|
)
|
||||||
|
val konanBuildTypeAttribute = Attribute.of(
|
||||||
|
"org.jetbrains.kotlin.native.type",
|
||||||
|
String::class.java
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+34
@@ -138,8 +138,41 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget>(
|
|||||||
tasks.named(binary.compilation.target.artifactsTaskName).configure { it.dependsOn(result) }
|
tasks.named(binary.compilation.target.artifactsTaskName).configure { it.dependsOn(result) }
|
||||||
tasks.maybeCreate(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(result)
|
tasks.maybeCreate(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (binary is Framework) {
|
||||||
|
val configuration = configurations.create(configurationName(binary.target.name, binary.buildType.name.toLowerCase()) + binary.baseName) {
|
||||||
|
it.isCanBeConsumed = true
|
||||||
|
it.isCanBeResolved = false
|
||||||
|
}
|
||||||
|
with(configuration) {
|
||||||
|
usesPlatformOf(binary.target)
|
||||||
|
project.afterEvaluate {
|
||||||
|
val linkArtifact = project.artifacts.add(name, binary.outputFile) { artifact ->
|
||||||
|
artifact.name = name
|
||||||
|
artifact.extension = "framework"
|
||||||
|
artifact.type = "binary"
|
||||||
|
artifact.classifier = "framework"
|
||||||
|
artifact.builtBy(result)
|
||||||
|
}
|
||||||
|
project.extensions.getByType(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet::class.java)
|
||||||
|
.addCandidate(linkArtifact)
|
||||||
|
artifacts.add(linkArtifact)
|
||||||
|
attributes.attribute(
|
||||||
|
ArtifactAttributes.ARTIFACT_FORMAT,
|
||||||
|
NativeArtifactFormat.FRAMEWORK
|
||||||
|
)
|
||||||
|
attributes.attribute(
|
||||||
|
KotlinNativeTarget.konanBuildTypeAttribute,
|
||||||
|
binary.buildType.name
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun configurationName(name: String, type: String): String =
|
||||||
|
listOf(name, type, "frameworks").joinToString("") { it.capitalize() }.decapitalize()
|
||||||
|
|
||||||
private fun Project.createRunTask(binary: Executable) {
|
private fun Project.createRunTask(binary: Executable) {
|
||||||
val taskName = binary.runTaskName ?: return
|
val taskName = binary.runTaskName ?: return
|
||||||
registerTask<Exec>(taskName) { exec ->
|
registerTask<Exec>(taskName) { exec ->
|
||||||
@@ -399,6 +432,7 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget>(
|
|||||||
|
|
||||||
object NativeArtifactFormat {
|
object NativeArtifactFormat {
|
||||||
const val KLIB = "org.jetbrains.kotlin.klib"
|
const val KLIB = "org.jetbrains.kotlin.klib"
|
||||||
|
const val FRAMEWORK = "org.jetbrains.kotlin.framework"
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
Reference in New Issue
Block a user