KMM: can't set isAllowInsecureProtocol using cocoapods plugin

#KT-48259

Merge-request: KT-MR-4728
This commit is contained in:
Viacheslav Kormushkin
2021-10-13 12:59:49 +00:00
committed by Space
parent 4e74e9baee
commit fcb8f331dc
2 changed files with 9 additions and 9 deletions
@@ -11,7 +11,6 @@ import org.gradle.api.Action
import org.gradle.api.Named
import org.gradle.api.NamedDomainObjectSet
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.tasks.*
import org.gradle.util.ConfigureUtil
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
@@ -19,7 +18,6 @@ import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.Cocoapods
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBinary
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
import java.io.File
import java.net.URI
@@ -281,9 +279,10 @@ open class CocoapodsExtension(private val project: Project) {
*
* @param url url to tar, jar or zip archive.
* @param flatten does archive contains subdirectory that needs to be expanded
* @param isAllowInsecureProtocol enables communication with a repository over an insecure HTTP connection.
*/
@JvmOverloads
fun url(url: String, flatten: Boolean = false): PodLocation = Url(URI(url), flatten)
fun url(url: String, flatten: Boolean = false, isAllowInsecureProtocol: Boolean = false): PodLocation = Url(URI(url), flatten, isAllowInsecureProtocol)
/**
* Path to local pod
@@ -319,7 +318,8 @@ open class CocoapodsExtension(private val project: Project) {
data class Url(
@get:Input val url: URI,
@get:Input var flatten: Boolean
@get:Input var flatten: Boolean,
@get:Input var isAllowInsecureProtocol: Boolean
) : PodLocation() {
override fun getLocalPath(project: Project, podName: String): String {
return project.cocoapodsBuildDirs.externalSources("url").resolve(podName).absolutePath
@@ -117,14 +117,12 @@ open class PodDownloadUrlTask : DownloadCocoapodsTask() {
@TaskAction
fun download() {
val podLocation = podSource.get()
val url = podLocation.url.toString()
val repoUrl = url.substringBeforeLast("/")
val fileName = url.substringAfterLast("/")
val fileName = podLocation.url.toString().substringAfterLast("/")
val fileNameWithoutExtension = fileName.substringBefore(".")
val extension = fileName.substringAfter(".")
require(permittedFileExtensions.contains(extension)) { "Unknown file extension" }
val repo = setupRepo(repoUrl)
val repo = setupRepo(podLocation)
val dependency = createDependency(fileNameWithoutExtension, extension)
val configuration = project.configurations.detachedConfiguration(dependency)
val artifact = configuration.singleFile
@@ -132,8 +130,9 @@ open class PodDownloadUrlTask : DownloadCocoapodsTask() {
project.repositories.remove(repo)
}
private fun setupRepo(repoUrl: String): ArtifactRepository {
private fun setupRepo(podUrl: CocoapodsDependency.PodLocation.Url): ArtifactRepository {
return project.repositories.ivy { repo ->
val repoUrl = podUrl.url.toString().substringBeforeLast("/")
repo.setUrl(repoUrl)
repo.patternLayout {
it.artifact("[artifact].[ext]")
@@ -141,6 +140,7 @@ open class PodDownloadUrlTask : DownloadCocoapodsTask() {
repo.metadataSources {
it.artifact()
}
repo.isAllowInsecureProtocol = podUrl.isAllowInsecureProtocol
}
}