CocoaPods: Generate wrapper if the corresponding property enabled

This commit is contained in:
Ilya Matveev
2019-03-21 17:27:01 +07:00
parent 07c3ed5bd1
commit 0a27699591
2 changed files with 9 additions and 2 deletions
@@ -163,6 +163,10 @@ open class KotlinCocoapodsPlugin: Plugin<Project> {
it.description = "Generates a podspec file for CocoaPods import" it.description = "Generates a podspec file for CocoaPods import"
it.settings = cocoapodsExtension it.settings = cocoapodsExtension
it.dependsOn(dummyFrameworkTask) it.dependsOn(dummyFrameworkTask)
val generateWrapper = project.findProperty(GENERATE_WRAPPER_PROPERTY)?.toString()?.toBoolean() ?: false
if (generateWrapper) {
it.dependsOn(":wrapper")
}
} }
} }
@@ -231,6 +235,8 @@ open class KotlinCocoapodsPlugin: Plugin<Project> {
const val HEADER_PATHS_PROPERTY = "kotlin.native.cocoapods.paths.headers" const val HEADER_PATHS_PROPERTY = "kotlin.native.cocoapods.paths.headers"
const val FRAMEWORK_PATHS_PROPERTY = "kotlin.native.cocoapods.paths.frameworks" const val FRAMEWORK_PATHS_PROPERTY = "kotlin.native.cocoapods.paths.frameworks"
const val GENERATE_WRAPPER_PROPERTY = "kotlin.native.cocoapods.generate.wrapper"
// Used in Xcode script phase to indicate that the framework is being built for a device // Used in Xcode script phase to indicate that the framework is being built for a device
// so we should generate a fat framework with arm32 and arm64 binaries. // so we should generate a fat framework with arm32 and arm64 binaries.
const val KOTLIN_TARGET_FOR_DEVICE = "ios_arm" const val KOTLIN_TARGET_FOR_DEVICE = "ios_arm"
@@ -10,6 +10,7 @@ import org.gradle.api.tasks.*
import org.gradle.api.tasks.wrapper.Wrapper import org.gradle.api.tasks.wrapper.Wrapper
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension
import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin
import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Companion.GENERATE_WRAPPER_PROPERTY
import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Companion.KOTLIN_TARGET_FOR_DEVICE import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Companion.KOTLIN_TARGET_FOR_DEVICE
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
import org.jetbrains.kotlin.gradle.plugin.cocoapods.cocoapodsBuildDirs import org.jetbrains.kotlin.gradle.plugin.cocoapods.cocoapodsBuildDirs
@@ -41,9 +42,9 @@ open class PodspecTask : DefaultTask() {
val gradleWrapper = (project.rootProject.tasks.getByName("wrapper") as? Wrapper)?.scriptFile val gradleWrapper = (project.rootProject.tasks.getByName("wrapper") as? Wrapper)?.scriptFile
require(gradleWrapper != null && gradleWrapper.exists()) { require(gradleWrapper != null && gradleWrapper.exists()) {
""" """
The Gradle wrapper is required to run the build from Xcode. To generate the wrapper, run: The Gradle wrapper is required to run the build from Xcode.
gradle :wrapper Please run the same command with `-P$GENERATE_WRAPPER_PROPERTY=true` or run the `:wrapper` task to generate the wrapper manually.
See details about the wrapper at https://docs.gradle.org/current/userguide/gradle_wrapper.html See details about the wrapper at https://docs.gradle.org/current/userguide/gradle_wrapper.html
""".trimIndent() """.trimIndent()