diff --git a/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt b/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt index 428e4ee..8e3a394 100644 --- a/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt +++ b/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt @@ -6,6 +6,7 @@ @file:Suppress("PackageDirectoryMismatch") // Old package for compatibility package co.touchlab.kotlin.gradle.plugin.cocoapods +import org.gradle.api.Action import org.gradle.api.Named import org.gradle.api.NamedDomainObjectSet import org.gradle.api.Project @@ -48,22 +49,22 @@ open class CocoapodsExtension(private val project: Project) { @Input var homepage: String? = null - private fun Framework.setDefaults(){ + private fun Framework.setDefaults() { baseName = project.name.asValidFrameworkName() isStatic = true } - internal var frameworkConfiguration: Framework.() -> Unit = {} - - internal fun configureFramework(framework: Framework){ - framework.setDefaults() - framework.frameworkConfiguration() + internal fun configureFramework(frameworkToConfigure: Framework) { + frameworkToConfigure.setDefaults() + frameworkAction?.execute(frameworkToConfigure) } - @Optional - @Input - fun framework(configure: Framework.() -> Unit) { - frameworkConfiguration = configure + //Not an input because we pull relevant values from the configured frameworks instead of here + @Internal + var frameworkAction: Action? = null + + fun framework(action: Action) { + frameworkAction = action } private val _pods = project.container(CocoapodsDependency::class.java) diff --git a/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/KotlinCocoapodsPlugin.kt b/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/KotlinCocoapodsPlugin.kt index 177e13e..f4a42c4 100644 --- a/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/KotlinCocoapodsPlugin.kt +++ b/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/cocoapods/KotlinCocoapodsPlugin.kt @@ -167,22 +167,22 @@ open class KotlinCocoapodsPlugin : Plugin { cocoapodsExtension: CocoapodsExtension ) { val firstFramework = kotlinExtension.supportedTargets() - .single() + .first() .binaries .run { findFramework(NativeBuildType.RELEASE) ?: getFramework(NativeBuildType.DEBUG) } val dummyFrameworkTask = project.tasks.create("generateDummyFramework", DummyFrameworkTask::class.java) { - it.settings = cocoapodsExtension - it.framework = firstFramework + it.frameworkName = firstFramework.baseName } project.tasks.create("podspec", PodspecTask::class.java) { it.group = TASK_GROUP it.description = "Generates a podspec file for CocoaPods import" it.settings = cocoapodsExtension - it.framework = firstFramework + it.frameworkName = firstFramework.baseName + it.isStatic = firstFramework.isStatic it.dependsOn(dummyFrameworkTask) val generateWrapper = project.findProperty(GENERATE_WRAPPER_PROPERTY)?.toString()?.toBoolean() ?: false if (generateWrapper) { diff --git a/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/tasks/CocoapodsTasks.kt b/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/tasks/CocoapodsTasks.kt index 814a50d..7f1856c 100644 --- a/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/tasks/CocoapodsTasks.kt +++ b/gradle-plugin/src/main/kotlin/co/touchlab/kotlin/gradle/targets/native/tasks/CocoapodsTasks.kt @@ -32,14 +32,14 @@ open class PodspecTask : DefaultTask() { @OutputFile val outputFile: File = project.projectDir.resolve("$specName.podspec") - @Input - val frameworkNameProvider: Provider = project.provider { framework.baseName} + @get:Input + internal lateinit var frameworkName:String - @get:Nested - internal lateinit var settings: CocoapodsExtension + @get:Input + internal var isStatic:Boolean = true @get:Nested - internal lateinit var framework: Framework + internal lateinit var settings: CocoapodsExtension // TODO: Handle Framework name customization - rename the framework during sync process. @TaskAction @@ -75,8 +75,8 @@ open class PodspecTask : DefaultTask() { | spec.license = '${settings.license.orEmpty()}' | spec.summary = '${settings.summary.orEmpty()}' | - |${if(framework.isStatic){" spec.static_framework = true"}else{""}} - | spec.vendored_frameworks = "$frameworkDir/${frameworkNameProvider.get()}.framework" + |${if(isStatic){" spec.static_framework = true"}else{""}} + | spec.vendored_frameworks = "$frameworkDir/$frameworkName.framework" | spec.libraries = "c++" | spec.module_name = "#{spec.name}_umbrella" | @@ -146,17 +146,11 @@ open class DummyFrameworkTask : DefaultTask() { @OutputDirectory val destinationDir = project.cocoapodsBuildDirs.framework - @Input - val frameworkNameProvider: Provider = project.provider { framework.baseName } - - @get:Nested - internal lateinit var settings: CocoapodsExtension - - @get:Nested - internal lateinit var framework: Framework + @get:Input + lateinit var frameworkName:String private val frameworkDir: File - get() = destinationDir.resolve("${frameworkNameProvider.get()}.framework") + get() = destinationDir.resolve("$frameworkName.framework") private fun copyResource(from: String, to: File) { to.parentFile.mkdirs() @@ -202,11 +196,11 @@ open class DummyFrameworkTask : DefaultTask() { // Copy files for the dummy framework. copyFrameworkFile("Info.plist") - copyFrameworkFile("dummy", frameworkNameProvider.get()) + copyFrameworkFile("dummy", frameworkName) copyFrameworkFile("Headers/dummy.h") copyFrameworkTextFile("Modules/module.modulemap") { if (it == "framework module dummy {") { - it.replace("dummy", frameworkNameProvider.get()) + it.replace("dummy", frameworkName) } else { it }