Remove deprecated ConfigureUtil usages in CocoapodsExtension
^KT-46019 In Progress
This commit is contained in:
+41
-18
@@ -6,13 +6,11 @@
|
|||||||
@file:Suppress("PackageDirectoryMismatch") // Old package for compatibility
|
@file:Suppress("PackageDirectoryMismatch") // Old package for compatibility
|
||||||
package org.jetbrains.kotlin.gradle.plugin.cocoapods
|
package org.jetbrains.kotlin.gradle.plugin.cocoapods
|
||||||
|
|
||||||
import groovy.lang.Closure
|
|
||||||
import org.gradle.api.Action
|
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.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.util.ConfigureUtil
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.CocoapodsDependency.PodLocation.*
|
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.CocoapodsDependency.PodLocation.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
|
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
|
||||||
@@ -23,8 +21,9 @@ import org.jetbrains.kotlin.gradle.tasks.addArgs
|
|||||||
import org.jetbrains.kotlin.konan.target.HostManager
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
open class CocoapodsExtension(private val project: Project) {
|
abstract class CocoapodsExtension @Inject constructor(private val project: Project) {
|
||||||
/**
|
/**
|
||||||
* Configure version of the pod
|
* Configure version of the pod
|
||||||
*/
|
*/
|
||||||
@@ -183,7 +182,17 @@ open class CocoapodsExtension(private val project: Project) {
|
|||||||
project.logger.warn(warnMessage)
|
project.logger.warn(warnMessage)
|
||||||
podSource = path.parentFile
|
podSource = path.parentFile
|
||||||
}
|
}
|
||||||
addToPods(CocoapodsDependency(name, moduleName, headers, version, podSource?.let { Path(it) }))
|
addToPods(
|
||||||
|
project.objects.newInstance(
|
||||||
|
CocoapodsDependency::class.java,
|
||||||
|
name,
|
||||||
|
moduleName
|
||||||
|
).apply {
|
||||||
|
this.headers = headers
|
||||||
|
this.version = version
|
||||||
|
source = podSource?.let { Path(it) }
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -194,7 +203,7 @@ open class CocoapodsExtension(private val project: Project) {
|
|||||||
// Empty string will lead to an attempt to create two podDownload tasks.
|
// Empty string will lead to an attempt to create two podDownload tasks.
|
||||||
// One is original podDownload and second is podDownload + pod.name
|
// One is original podDownload and second is podDownload + pod.name
|
||||||
require(name.isNotEmpty()) { "Please provide not empty pod name to avoid ambiguity" }
|
require(name.isNotEmpty()) { "Please provide not empty pod name to avoid ambiguity" }
|
||||||
val dependency = CocoapodsDependency(name, name.asModuleName())
|
val dependency = project.objects.newInstance(CocoapodsDependency::class.java, name, name.asModuleName())
|
||||||
dependency.configure()
|
dependency.configure()
|
||||||
addToPods(dependency)
|
addToPods(dependency)
|
||||||
}
|
}
|
||||||
@@ -202,8 +211,8 @@ open class CocoapodsExtension(private val project: Project) {
|
|||||||
/**
|
/**
|
||||||
* Add a CocoaPods dependency to the pod built from this project.
|
* Add a CocoaPods dependency to the pod built from this project.
|
||||||
*/
|
*/
|
||||||
fun pod(name: String, configure: Closure<*>) = pod(name) {
|
fun pod(name: String, configure: Action<CocoapodsDependency>) = pod(name) {
|
||||||
ConfigureUtil.configure(configure, this)
|
configure.execute(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addToPods(dependency: CocoapodsDependency) {
|
private fun addToPods(dependency: CocoapodsDependency) {
|
||||||
@@ -226,8 +235,8 @@ open class CocoapodsExtension(private val project: Project) {
|
|||||||
* for additional information.
|
* for additional information.
|
||||||
* Default sources (cdn.cocoapods.org) implicitly included.
|
* Default sources (cdn.cocoapods.org) implicitly included.
|
||||||
*/
|
*/
|
||||||
fun specRepos(configure: Closure<*>) = specRepos {
|
fun specRepos(configure: Action<SpecRepos>) = specRepos {
|
||||||
ConfigureUtil.configure(configure, this)
|
configure.execute(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun configureRegisteredFrameworks(configure: Framework.() -> Unit) {
|
private fun configureRegisteredFrameworks(configure: Framework.() -> Unit) {
|
||||||
@@ -268,15 +277,29 @@ open class CocoapodsExtension(private val project: Project) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class CocoapodsDependency(
|
abstract class CocoapodsDependency @Inject constructor(
|
||||||
private val name: String,
|
private val name: String,
|
||||||
@get:Input var moduleName: String,
|
@get:Input var moduleName: String
|
||||||
@get:Optional @get:Input var headers: String? = null,
|
|
||||||
@get:Optional @get:Input var version: String? = null,
|
|
||||||
@get:Optional @get:Nested var source: PodLocation? = null,
|
|
||||||
@get:Internal var extraOpts: List<String> = listOf(),
|
|
||||||
@get:Internal var packageName: String = "cocoapods.$moduleName"
|
|
||||||
) : Named {
|
) : Named {
|
||||||
|
|
||||||
|
@get:Optional
|
||||||
|
@get:Input
|
||||||
|
var headers: String? = null
|
||||||
|
|
||||||
|
@get:Optional
|
||||||
|
@get:Input
|
||||||
|
var version: String? = null
|
||||||
|
|
||||||
|
@get:Optional
|
||||||
|
@get:Nested
|
||||||
|
var source: PodLocation? = null
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
|
var extraOpts: List<String> = listOf()
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
|
var packageName: String = "cocoapods.$moduleName"
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
override fun getName(): String = name
|
override fun getName(): String = name
|
||||||
|
|
||||||
@@ -317,8 +340,8 @@ open class CocoapodsExtension(private val project: Project) {
|
|||||||
/**
|
/**
|
||||||
* Configure pod from git repository. The podspec file is expected to be in the repository root.
|
* Configure pod from git repository. The podspec file is expected to be in the repository root.
|
||||||
*/
|
*/
|
||||||
fun git(url: String, configure: Closure<*>) = git(url) {
|
fun git(url: String, configure: Action<Git>) = git(url) {
|
||||||
ConfigureUtil.configure(configure, this)
|
configure.execute(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class PodLocation {
|
sealed class PodLocation {
|
||||||
|
|||||||
+1
-1
@@ -688,7 +688,7 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
|
|
||||||
pluginManager.withPlugin("kotlin-multiplatform") {
|
pluginManager.withPlugin("kotlin-multiplatform") {
|
||||||
val kotlinExtension = project.multiplatformExtension
|
val kotlinExtension = project.multiplatformExtension
|
||||||
val cocoapodsExtension = CocoapodsExtension(this)
|
val cocoapodsExtension = project.objects.newInstance(CocoapodsExtension::class.java, this)
|
||||||
kotlinExtension.addExtension(COCOAPODS_EXTENSION_NAME, cocoapodsExtension)
|
kotlinExtension.addExtension(COCOAPODS_EXTENSION_NAME, cocoapodsExtension)
|
||||||
createDefaultFrameworks(kotlinExtension, cocoapodsExtension)
|
createDefaultFrameworks(kotlinExtension, cocoapodsExtension)
|
||||||
registerDummyFrameworkTask(project, cocoapodsExtension)
|
registerDummyFrameworkTask(project, cocoapodsExtension)
|
||||||
|
|||||||
Reference in New Issue
Block a user