[Gradle] Fix library artifacts naming in generated podspec
^KT-56304 Verification Pending
This commit is contained in:
committed by
Space Team
parent
e821523b90
commit
70ace38788
+3
-3
@@ -47,12 +47,12 @@ class NativeLibraryDslWithCocoapodsIT : BaseGradleIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `generate podspec when assembling lib`() {
|
||||
fun `generate podspec when assembling static lib`() {
|
||||
project {
|
||||
build(":shared:assembleMylibSharedLibraryLinuxX64") {
|
||||
build(":shared:assembleMylibStaticLibraryLinuxX64") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":shared:generateMylibPodspec")
|
||||
assertFilesContentEqual("podspecs/mylib.podspec", "/shared/build/out/dynamic/mylib.podspec")
|
||||
assertFilesContentEqual("podspecs/mylib.podspec", "/shared/build/out/static/mylib.podspec")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = 'mylib'
|
||||
spec.version = '0.1'
|
||||
spec.vendored_library = 'mylib.dylib'
|
||||
spec.vendored_library = 'libmylib.a'
|
||||
|
||||
spec.description = <<-DESC
|
||||
Computes the meaning of life.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = 'myslib'
|
||||
spec.version = '0.1'
|
||||
spec.vendored_library = 'myslib.dylib'
|
||||
spec.vendored_library = 'libmyslib.dylib'
|
||||
end
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ kotlin {
|
||||
kotlinArtifacts {
|
||||
Native.Library("mylib") {
|
||||
target = linuxX64
|
||||
isStatic = true
|
||||
|
||||
withPodspec {
|
||||
attribute(
|
||||
|
||||
+4
-1
@@ -415,7 +415,10 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
||||
val podspecTaskName = lowerCamelCaseName("generate", artifactName, "podspec")
|
||||
|
||||
val artifactType = when (artifact) {
|
||||
is KotlinNativeLibrary -> GenerateArtifactPodspecTask.ArtifactType.Library
|
||||
is KotlinNativeLibrary -> when {
|
||||
artifact.isStatic -> GenerateArtifactPodspecTask.ArtifactType.StaticLibrary
|
||||
else -> GenerateArtifactPodspecTask.ArtifactType.DynamicLibrary
|
||||
}
|
||||
is KotlinNativeFramework -> GenerateArtifactPodspecTask.ArtifactType.Framework
|
||||
is KotlinNativeFatFramework -> GenerateArtifactPodspecTask.ArtifactType.FatFramework
|
||||
is KotlinNativeXCFramework -> GenerateArtifactPodspecTask.ArtifactType.XCFramework
|
||||
|
||||
+14
-6
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.gradle.utils.appendLine
|
||||
abstract class GenerateArtifactPodspecTask : DefaultTask() {
|
||||
|
||||
enum class ArtifactType {
|
||||
Library, Framework, FatFramework, XCFramework
|
||||
StaticLibrary, DynamicLibrary, Framework, FatFramework, XCFramework
|
||||
}
|
||||
|
||||
@get:Input
|
||||
@@ -126,18 +126,26 @@ abstract class GenerateArtifactPodspecTask : DefaultTask() {
|
||||
}
|
||||
|
||||
if (vendoredKeys.none { attributes.get().containsKey(it) }) {
|
||||
val vendoredKey = when (artifactTypeValue) {
|
||||
Library -> vendoredLibrary
|
||||
val key = when (artifactTypeValue) {
|
||||
StaticLibrary, DynamicLibrary -> vendoredLibrary
|
||||
Framework, FatFramework, XCFramework -> vendoredFrameworks
|
||||
}
|
||||
|
||||
val vendoredValue = specName.get() + "." + when (artifactTypeValue) {
|
||||
Library -> "dylib"
|
||||
val prefix = when (artifactTypeValue) {
|
||||
StaticLibrary, DynamicLibrary -> "lib"
|
||||
else -> ""
|
||||
}
|
||||
|
||||
val suffix = when (artifactTypeValue) {
|
||||
StaticLibrary -> "a"
|
||||
DynamicLibrary -> "dylib"
|
||||
Framework, FatFramework -> "framework"
|
||||
XCFramework -> "xcframework"
|
||||
}
|
||||
|
||||
put(vendoredKey, vendoredValue)
|
||||
val value = "$prefix${specName.get()}.$suffix"
|
||||
|
||||
put(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user