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