[Cocoapods] Fix task and directory naming to avoid subspecs collision
Logics of generating name for dependencies downloaded from git or url admits producing tasks with forbidden symbols inside name for subspecs. This fix introduces replacing of forbidden symbols for such purposes. #KT-42550 Fixed
This commit is contained in:
+21
-5
@@ -28,6 +28,14 @@ import kotlin.test.assertEquals
|
|||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import kotlin.test.fail
|
import kotlin.test.fail
|
||||||
|
|
||||||
|
private val String.validFrameworkName: String
|
||||||
|
get() = replace('-', '_')
|
||||||
|
private val invalidTaskNameCharacters = "[/\\\\:<>\"?*|]".toRegex()
|
||||||
|
|
||||||
|
private val String.validTaskName
|
||||||
|
get() = replace(invalidTaskNameCharacters, "_")
|
||||||
|
|
||||||
|
|
||||||
class CocoaPodsIT : BaseGradleIT() {
|
class CocoaPodsIT : BaseGradleIT() {
|
||||||
|
|
||||||
override val defaultGradleVersion: GradleVersionRequired
|
override val defaultGradleVersion: GradleVersionRequired
|
||||||
@@ -220,6 +228,15 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
doTestGit(branch = "2974")
|
doTestGit(branch = "2974")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testPodDownloadGitSubspec() {
|
||||||
|
doTestGit(
|
||||||
|
repo = "https://github.com/SDWebImage/SDWebImage.git",
|
||||||
|
pod = "SDWebImage/MapKit",
|
||||||
|
tag = "5.9.2"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testPodDownloadGitBranchAndCommit() {
|
fun testPodDownloadGitBranchAndCommit() {
|
||||||
val branch = "2974"
|
val branch = "2974"
|
||||||
@@ -931,10 +948,11 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
branchName: String? = null,
|
branchName: String? = null,
|
||||||
commitName: String? = null,
|
commitName: String? = null,
|
||||||
tagName: String? = null,
|
tagName: String? = null,
|
||||||
aPodDownloadName: String = defaultPodName
|
aPodDownloadName: String = defaultPodName,
|
||||||
|
podspecName: String = aPodDownloadName.split("/")[0]
|
||||||
) {
|
) {
|
||||||
val gitDir = git().resolve(aPodDownloadName)
|
val gitDir = git().resolve(aPodDownloadName.validTaskName)
|
||||||
val podspecFile = gitDir.resolve("$aPodDownloadName.podspec")
|
val podspecFile = gitDir.resolve("$podspecName.podspec")
|
||||||
assertTrue(podspecFile.exists())
|
assertTrue(podspecFile.exists())
|
||||||
if (tagName != null) {
|
if (tagName != null) {
|
||||||
checkTag(gitDir, tagName)
|
checkTag(gitDir, tagName)
|
||||||
@@ -1199,8 +1217,6 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val String.validFrameworkName: String
|
|
||||||
get() = replace('-', '_')
|
|
||||||
|
|
||||||
private fun kotlinLibraryPodspecContent(frameworkName: String? = null) = """
|
private fun kotlinLibraryPodspecContent(frameworkName: String? = null) = """
|
||||||
Pod::Spec.new do |spec|
|
Pod::Spec.new do |spec|
|
||||||
|
|||||||
+5
-5
@@ -72,20 +72,20 @@ private val Family.toPodGenTaskName: String
|
|||||||
|
|
||||||
private fun String.toSetupBuildTaskName(pod: CocoapodsDependency): String = lowerCamelCaseName(
|
private fun String.toSetupBuildTaskName(pod: CocoapodsDependency): String = lowerCamelCaseName(
|
||||||
KotlinCocoapodsPlugin.POD_SETUP_BUILD_TASK_NAME,
|
KotlinCocoapodsPlugin.POD_SETUP_BUILD_TASK_NAME,
|
||||||
pod.schemeName,
|
pod.name.asValidTaskName(),
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun String.toBuildDependenciesTaskName(pod: CocoapodsDependency): String = lowerCamelCaseName(
|
private fun String.toBuildDependenciesTaskName(pod: CocoapodsDependency): String = lowerCamelCaseName(
|
||||||
KotlinCocoapodsPlugin.POD_BUILD_TASK_NAME,
|
KotlinCocoapodsPlugin.POD_BUILD_TASK_NAME,
|
||||||
pod.schemeName,
|
pod.name.asValidTaskName(),
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
|
|
||||||
private val CocoapodsDependency.toPodDownloadTaskName: String
|
private val CocoapodsDependency.toPodDownloadTaskName: String
|
||||||
get() = lowerCamelCaseName(
|
get() = lowerCamelCaseName(
|
||||||
KotlinCocoapodsPlugin.POD_DOWNLOAD_TASK_NAME,
|
KotlinCocoapodsPlugin.POD_DOWNLOAD_TASK_NAME,
|
||||||
name
|
name.asValidTaskName()
|
||||||
)
|
)
|
||||||
|
|
||||||
open class KotlinCocoapodsPlugin : Plugin<Project> {
|
open class KotlinCocoapodsPlugin : Plugin<Project> {
|
||||||
@@ -375,11 +375,11 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
val podSource = pod.source
|
val podSource = pod.source
|
||||||
val downloadPodTask = when (podSource) {
|
val downloadPodTask = when (podSource) {
|
||||||
is Git -> project.tasks.register(pod.toPodDownloadTaskName, PodDownloadGitTask::class.java) {
|
is Git -> project.tasks.register(pod.toPodDownloadTaskName, PodDownloadGitTask::class.java) {
|
||||||
it.podName = project.provider { pod.name }
|
it.podName = project.provider { pod.name.asValidTaskName() }
|
||||||
it.podSource = project.provider { podSource as Git }
|
it.podSource = project.provider { podSource as Git }
|
||||||
}
|
}
|
||||||
is Url -> project.tasks.register(pod.toPodDownloadTaskName, PodDownloadUrlTask::class.java) {
|
is Url -> project.tasks.register(pod.toPodDownloadTaskName, PodDownloadUrlTask::class.java) {
|
||||||
it.podName = project.provider { pod.name }
|
it.podName = project.provider { pod.name.asValidTaskName() }
|
||||||
it.podSource = project.provider { podSource as Url }
|
it.podSource = project.provider { podSource as Url }
|
||||||
}
|
}
|
||||||
else -> return@all
|
else -> return@all
|
||||||
|
|||||||
Reference in New Issue
Block a user