[KMM] Fixed project import failure in case of cocoapods integration
#KT-49931
This commit is contained in:
committed by
Space
parent
d89680b30d
commit
077d10edef
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.native
|
||||
|
||||
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||
import org.jetbrains.kotlin.gradle.GradleVersionRequired
|
||||
import org.jetbrains.kotlin.gradle.transformProjectWithPluginsDsl
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.junit.Assume
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class CocoaPodsNonMacIT : BaseGradleIT() {
|
||||
|
||||
override val defaultGradleVersion: GradleVersionRequired
|
||||
get() = GradleVersionRequired.FOR_MPP_SUPPORT
|
||||
|
||||
@Test
|
||||
fun testImport() {
|
||||
transformProjectWithPluginsDsl(
|
||||
"native-cocoapods-tests"
|
||||
).build("podImport", "-Pkotlin.native.cocoapods.generate.wrapper=true") {
|
||||
assertSuccessful()
|
||||
assertTrue { output.contains("Kotlin Cocoapods Plugin is fully supported on mac machines only. Gradle tasks that can not run on non-mac hosts will be skipped.") }
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@BeforeClass
|
||||
@JvmStatic
|
||||
fun assumeItsNonMac() {
|
||||
Assume.assumeFalse(HostManager.hostIsMac)
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.Cocoapods
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBinary
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
|
||||
@@ -246,9 +247,11 @@ open class CocoapodsExtension(private val project: Project) {
|
||||
|
||||
binary.linkTaskProvider.configure { task ->
|
||||
|
||||
val podBuildTaskProvider = project.getPodBuildTaskProvider(binary.target, pod)
|
||||
task.inputs.file(podBuildTaskProvider.map { it.buildSettingsFile })
|
||||
task.dependsOn(podBuildTaskProvider)
|
||||
if (HostManager.hostIsMac) {
|
||||
val podBuildTaskProvider = project.getPodBuildTaskProvider(binary.target, pod)
|
||||
task.inputs.file(podBuildTaskProvider.map { it.buildSettingsFile })
|
||||
task.dependsOn(podBuildTaskProvider)
|
||||
}
|
||||
|
||||
task.doFirst { _ ->
|
||||
val podBuildSettings = project.getPodBuildSettingsProperties(binary.target, pod)
|
||||
|
||||
+11
-4
@@ -318,10 +318,11 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
||||
_extraOptsProp.addAll(project.provider { pod.extraOpts })
|
||||
}
|
||||
|
||||
val podBuildTaskProvider = project.getPodBuildTaskProvider(target, pod)
|
||||
interopTask.inputs.file(podBuildTaskProvider.map {it.buildSettingsFile })
|
||||
interopTask.dependsOn(podBuildTaskProvider)
|
||||
|
||||
if (HostManager.hostIsMac) {
|
||||
val podBuildTaskProvider = project.getPodBuildTaskProvider(target, pod)
|
||||
interopTask.inputs.file(podBuildTaskProvider.map { it.buildSettingsFile })
|
||||
interopTask.dependsOn(podBuildTaskProvider)
|
||||
}
|
||||
interopTask.doFirst { _ ->
|
||||
// Since we cannot expand the configuration phase of interop tasks
|
||||
// receiving the required environment variables happens on execution phase.
|
||||
@@ -691,6 +692,12 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
||||
If you plan to add dependencies on third party pods, don't forget to install it by executing 'gem install cocoapods-generate' in terminal.
|
||||
""".trimIndent()
|
||||
)
|
||||
} else if (!HostManager.hostIsMac) {
|
||||
logger.warn(
|
||||
"""
|
||||
Kotlin Cocoapods Plugin is fully supported on mac machines only. Gradle tasks that can not run on non-mac hosts will be skipped.
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
createInterops(project, kotlinExtension, cocoapodsExtension)
|
||||
configureTestBinaries(project, cocoapodsExtension)
|
||||
|
||||
+16
-5
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.gradle.targets.native.cocoapods.MissingSpecReposMess
|
||||
import org.jetbrains.kotlin.gradle.tasks.PodspecTask.Companion.retrievePods
|
||||
import org.jetbrains.kotlin.gradle.tasks.PodspecTask.Companion.retrieveSpecRepos
|
||||
import org.jetbrains.kotlin.konan.target.Family
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.Reader
|
||||
@@ -47,7 +48,17 @@ val CocoapodsDependency.schemeName: String
|
||||
* to obtain sources or artifacts for the declared dependencies.
|
||||
* This task is a part of CocoaPods integration infrastructure.
|
||||
*/
|
||||
open class PodInstallTask : DefaultTask() {
|
||||
|
||||
open class CocoapodsTask : DefaultTask() {
|
||||
init {
|
||||
onlyIf {
|
||||
HostManager.hostIsMac
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
open class PodInstallTask : CocoapodsTask() {
|
||||
init {
|
||||
onlyIf { podfile.isPresent }
|
||||
}
|
||||
@@ -103,7 +114,7 @@ open class PodInstallTask : DefaultTask() {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class DownloadCocoapodsTask : DefaultTask() {
|
||||
abstract class DownloadCocoapodsTask : CocoapodsTask() {
|
||||
@get:Input
|
||||
internal lateinit var podName: Provider<String>
|
||||
}
|
||||
@@ -371,7 +382,7 @@ private fun runCommand(
|
||||
* The task takes the path to the .podspec file and calls `pod gen`
|
||||
* to create synthetic xcode project and workspace.
|
||||
*/
|
||||
open class PodGenTask : DefaultTask() {
|
||||
open class PodGenTask : CocoapodsTask() {
|
||||
|
||||
init {
|
||||
onlyIf {
|
||||
@@ -442,7 +453,7 @@ open class PodGenTask : DefaultTask() {
|
||||
}
|
||||
|
||||
|
||||
open class PodSetupBuildTask : DefaultTask() {
|
||||
open class PodSetupBuildTask : CocoapodsTask() {
|
||||
|
||||
@get:Input
|
||||
lateinit var frameworkName: Provider<String>
|
||||
@@ -489,7 +500,7 @@ private fun getBuildSettingFileName(pod: CocoapodsDependency, sdk: String): Stri
|
||||
/**
|
||||
* The task compiles external cocoa pods sources.
|
||||
*/
|
||||
open class PodBuildTask : DefaultTask() {
|
||||
open class PodBuildTask : CocoapodsTask() {
|
||||
|
||||
@get:PathSensitive(PathSensitivity.ABSOLUTE)
|
||||
@get:InputFile
|
||||
|
||||
Reference in New Issue
Block a user