Revert "CocoaPods: Skip synthetic task on non-mac hosts"

This reverts commit ce029822
This commit is contained in:
Nikolay Krasko
2020-08-24 18:30:33 +03:00
parent 621c87ee84
commit 6040491373
2 changed files with 14 additions and 48 deletions
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Compan
import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Companion.POD_SETUP_BUILD_TASK_NAME
import org.jetbrains.kotlin.gradle.util.modify
import org.jetbrains.kotlin.konan.target.HostManager
import org.junit.Assume.assumeFalse
import org.junit.Assume.assumeTrue
import org.junit.Test
import java.io.File
@@ -169,28 +168,6 @@ class CocoaPodsIT : BaseGradleIT() {
mapOf("kotlin-library" to "foobaz")
)
@Test
fun testSkippingTasksOnOtherHosts() {
assumeFalse(HostManager.hostIsMac)
with(transformProjectWithPluginsDsl(cocoapodsSingleKtPod, gradleVersion)) {
val syntheticTasks = arrayOf(
":podInstall",
":kotlin-library:generateDummyFramework",
":kotlin-library:podGenIOS",
":kotlin-library:podSetupBuildIOS",
":kotlin-library:podBuildDependenciesIOS",
":kotlin-library:podImport"
)
build(*syntheticTasks, "-Pkotlin.native.cocoapods.generate.wrapper=true") {
// Check that tasks working with synthetic projects are skipped on non-mac hosts.
assertSuccessful()
assertTasksSkipped(*syntheticTasks)
}
}
}
private fun BaseGradleIT.Project.useCustomFrameworkName(subproject: String, frameworkName: String, iosAppLocation: String? = null) {
// Change the name at the Gradle side.
gradleBuildScript(subproject).appendText(
@@ -257,7 +234,7 @@ class CocoaPodsIT : BaseGradleIT() {
subprojectsToFrameworkNamesMap: Map<String, String?>,
) {
assumeTrue(HostManager.hostIsMac)
assumeTrue(KotlinCocoapodsPlugin.isAvailableToProduceSynthetic)
assumeTrue(KotlinCocoapodsPlugin.isAvailableToProduceSynthetic())
val subprojects = subprojectsToFrameworkNamesMap.keys
val gradleProject = transformProjectWithPluginsDsl(projectName, gradleVersion)
@@ -213,8 +213,8 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
interop.packageName = "cocoapods.${pod.moduleName}"
if (
isAvailableToProduceSynthetic
if (//TODO ychernyshev improve first check
isAvailableToProduceSynthetic()
&& project.findProperty(TARGET_PROPERTY) == null
&& project.findProperty(CONFIGURATION_PROPERTY) == null
) {
@@ -239,8 +239,8 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
// Since we cannot expand the configuration phase of interop tasks
// receiving the required environment variables happens on execution phase.
// TODO This needs to be fixed to improve UP-TO-DATE checks.
if (
isAvailableToProduceSynthetic
if (// TODO ychernyshev improve first check
isAvailableToProduceSynthetic()
&& project.findProperty(TARGET_PROPERTY) == null
&& project.findProperty(CONFIGURATION_PROPERTY) == null
) {
@@ -305,8 +305,6 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
it.group = TASK_GROUP
it.description = "Invokes `pod install` call within Podfile location directory"
it.cocoapodsExtension = cocoapodsExtension
it.onlyIf { isAvailableToProduceSynthetic }
//TODO avoid subproject task management here
project.allprojects.map { it.tasks.named(POD_SPEC_TASK_NAME, PodspecTask::class.java) }
.forEach { podspecTaskProvider ->
@@ -330,7 +328,6 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
it.kotlinNativeTarget = target
it.cocoapodsExtension = cocoapodsExtension
it.dependsOn(podspecTaskProvider)
it.onlyIf { isAvailableToProduceSynthetic }
}
}
}
@@ -355,7 +352,6 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
val podGenTaskProvider = project.tasks.named(target.toPodGenTaskName, PodGenTask::class.java)
it.podsXcodeProjDirProvider = podGenTaskProvider.get().podsXcodeProjDirProvider
it.dependsOn(podGenTaskProvider)
it.onlyIf { isAvailableToProduceSynthetic }
}
}
}
@@ -378,7 +374,6 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
it.podsXcodeProjDirProvider = podSetupBuildTaskProvider.get().podsXcodeProjDirProvider
it.buildSettingsFileProvider = podSetupBuildTaskProvider.get().buildSettingsFileProvider
it.dependsOn(podSetupBuildTaskProvider)
it.onlyIf { isAvailableToProduceSynthetic }
}
}
}
@@ -393,7 +388,6 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
it.group = TASK_GROUP
it.description = "Called on Gradle sync, depends on Cinterop tasks for every used pod"
it.dependsOn(podInstallTaskProvider)
it.onlyIf { isAvailableToProduceSynthetic }
kotlinExtension.supportedTargets().all { target ->
target.compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME).cinterops.all { interop ->
@@ -414,14 +408,13 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
registerDummyFrameworkTask(project, cocoapodsExtension)
createSyncTask(project, kotlinExtension)
registerPodspecTask(project, cocoapodsExtension)
registerPodGenTask(project, kotlinExtension, cocoapodsExtension)
registerPodInstallTask(project, cocoapodsExtension)
registerPodSetupBuildTasks(project, kotlinExtension, cocoapodsExtension)
registerPodBuildTasks(project, kotlinExtension, cocoapodsExtension)
registerPodImportTask(project, kotlinExtension)
if (HostManager.hostIsMac && !isAvailableToProduceSynthetic) {
if (isAvailableToProduceSynthetic()) {
registerPodGenTask(project, kotlinExtension, cocoapodsExtension)
registerPodInstallTask(project, cocoapodsExtension)
registerPodSetupBuildTasks(project, kotlinExtension, cocoapodsExtension)
registerPodBuildTasks(project, kotlinExtension, cocoapodsExtension)
registerPodImportTask(project, kotlinExtension)
} else {
logger.quiet(
"""
To take advantage of the new functionality for Cocoapods Integration like synchronizing with the Xcode project
@@ -464,17 +457,13 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
const val KOTLIN_TARGET_FOR_IOS_DEVICE = "ios_arm"
const val KOTLIN_TARGET_FOR_WATCHOS_DEVICE = "watchos_arm"
val isAvailableToProduceSynthetic: Boolean by lazy {
if (!HostManager.hostIsMac) {
return@lazy false
}
fun isAvailableToProduceSynthetic(): Boolean {
val gemListProcess = ProcessBuilder("gem", "list").start()
val gemListRetCode = gemListProcess.waitFor()
val gemListOutput = gemListProcess.inputStream.use {
it.reader().readText()
}
gemListRetCode == 0 && gemListOutput.contains("cocoapods-generate")
return gemListRetCode == 0 && gemListOutput.contains("cocoapods-generate")
}
}
}