[Gradle, Cocoapods] Add Podfile missing info to podInstall error report
#KT-42243 Fixed
This commit is contained in:
+2
-2
@@ -91,7 +91,7 @@ open class CocoapodsExtension(private val project: Project) {
|
|||||||
|
|
||||||
// For some reason Gradle doesn't consume the @Nested annotation on NamedDomainObjectContainer.
|
// For some reason Gradle doesn't consume the @Nested annotation on NamedDomainObjectContainer.
|
||||||
@get:Nested
|
@get:Nested
|
||||||
protected val podsAsTaskInput: List<CocoapodsDependency>
|
val podsAsTaskInput: List<CocoapodsDependency>
|
||||||
get() = _pods.toList()
|
get() = _pods.toList()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,7 +273,7 @@ open class CocoapodsExtension(private val project: Project) {
|
|||||||
|
|
||||||
class SpecRepos {
|
class SpecRepos {
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal val specRepos = mutableSetOf<URI>()
|
internal val specRepos = mutableSetOf(URI("https://cdn.cocoapods.org"))
|
||||||
|
|
||||||
fun url(url: String) {
|
fun url(url: String) {
|
||||||
specRepos.add(URI(url))
|
specRepos.add(URI(url))
|
||||||
|
|||||||
+1
-1
@@ -89,7 +89,6 @@ private val CocoapodsDependency.toPodDownloadTaskName: String
|
|||||||
)
|
)
|
||||||
|
|
||||||
open class KotlinCocoapodsPlugin : Plugin<Project> {
|
open class KotlinCocoapodsPlugin : Plugin<Project> {
|
||||||
|
|
||||||
private fun KotlinMultiplatformExtension.supportedTargets() = targets
|
private fun KotlinMultiplatformExtension.supportedTargets() = targets
|
||||||
.withType(KotlinNativeTarget::class.java)
|
.withType(KotlinNativeTarget::class.java)
|
||||||
.matching { it.konanTarget.family.isAppleFamily }
|
.matching { it.konanTarget.family.isAppleFamily }
|
||||||
@@ -354,6 +353,7 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
it.group = TASK_GROUP
|
it.group = TASK_GROUP
|
||||||
it.description = "Invokes `pod install` call within Podfile location directory"
|
it.description = "Invokes `pod install` call within Podfile location directory"
|
||||||
it.podfile.set(cocoapodsExtension.podfile)
|
it.podfile.set(cocoapodsExtension.podfile)
|
||||||
|
it.frameworkName = project.provider { cocoapodsExtension.frameworkName }
|
||||||
it.onlyIf { isAvailableToProduceSynthetic }
|
it.onlyIf { isAvailableToProduceSynthetic }
|
||||||
|
|
||||||
//TODO avoid subproject task management here
|
//TODO avoid subproject task management here
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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.targets.native.cocoapods
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.CocoapodsDependency
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.SpecRepos
|
||||||
|
|
||||||
|
interface MissingInfoMessage<T> {
|
||||||
|
val missingInfo: T
|
||||||
|
val missingMessage: String
|
||||||
|
}
|
||||||
|
|
||||||
|
class MissingSpecReposMessage(override val missingInfo: SpecRepos) : MissingInfoMessage<SpecRepos> {
|
||||||
|
override val missingMessage: String
|
||||||
|
get() = missingInfo.getAll().joinToString(separator = "\n") { "source '$it'" }
|
||||||
|
}
|
||||||
|
|
||||||
|
class MissingCocoapodsMessage(override val missingInfo: CocoapodsDependency, private val project: Project) :
|
||||||
|
MissingInfoMessage<CocoapodsDependency> {
|
||||||
|
override val missingMessage: String
|
||||||
|
get() = "pod '${missingInfo.name}'${missingInfo.source?.let { ", :path => '${it.getLocalPath(project, missingInfo.name)}'" } ?: ""}"
|
||||||
|
}
|
||||||
|
|
||||||
+28
-4
@@ -16,6 +16,10 @@ import org.gradle.api.tasks.Optional
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.*
|
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension.*
|
||||||
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.cocoapods.cocoapodsBuildDirs
|
import org.jetbrains.kotlin.gradle.plugin.cocoapods.cocoapodsBuildDirs
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.native.cocoapods.MissingCocoapodsMessage
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.native.cocoapods.MissingSpecReposMessage
|
||||||
|
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.Family
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
@@ -46,6 +50,9 @@ open class PodInstallTask : DefaultTask() {
|
|||||||
onlyIf { podfile.isPresent }
|
onlyIf { podfile.isPresent }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
|
internal lateinit var frameworkName: Provider<String>
|
||||||
|
|
||||||
@get:Optional
|
@get:Optional
|
||||||
@get:Input
|
@get:Input
|
||||||
internal val podfile = project.objects.property(File::class.java)
|
internal val podfile = project.objects.property(File::class.java)
|
||||||
@@ -68,10 +75,28 @@ open class PodInstallTask : DefaultTask() {
|
|||||||
val podInstallOutput = podInstallProcess.inputStream.use { it.reader().readText() }
|
val podInstallOutput = podInstallProcess.inputStream.use { it.reader().readText() }
|
||||||
|
|
||||||
check(podInstallRetCode == 0) {
|
check(podInstallRetCode == 0) {
|
||||||
listOf(
|
val specReposMessages = retrieveSpecRepos(project)?.let { MissingSpecReposMessage(it).missingMessage }
|
||||||
|
val cocoapodsMessages = retrievePods(project)?.map { MissingCocoapodsMessage(it, project).missingMessage }
|
||||||
|
|
||||||
|
listOfNotNull(
|
||||||
"Executing of 'pod install' failed with code $podInstallRetCode.",
|
"Executing of 'pod install' failed with code $podInstallRetCode.",
|
||||||
"Error message:",
|
"Error message:",
|
||||||
podInstallOutput
|
podInstallOutput,
|
||||||
|
specReposMessages?.let {
|
||||||
|
"""
|
||||||
|
|Please, check that file "${podfile.get().path}" contains following lines in header:
|
||||||
|
|$it
|
||||||
|
|
|
||||||
|
""".trimMargin()
|
||||||
|
},
|
||||||
|
cocoapodsMessages?.let {
|
||||||
|
"""
|
||||||
|
|Please, check that each target depended on ${frameworkName.get()} contains following dependencies:
|
||||||
|
|${it.joinToString("\n")}
|
||||||
|
|
|
||||||
|
""".trimMargin()
|
||||||
|
}
|
||||||
|
|
||||||
).joinToString("\n")
|
).joinToString("\n")
|
||||||
}
|
}
|
||||||
with(podsXcodeProjDirProvider) {
|
with(podsXcodeProjDirProvider) {
|
||||||
@@ -350,8 +375,7 @@ open class PodGenTask : DefaultTask() {
|
|||||||
val syntheticDir = project.cocoapodsBuildDirs.synthetic(family).apply { mkdirs() }
|
val syntheticDir = project.cocoapodsBuildDirs.synthetic(family).apply { mkdirs() }
|
||||||
val localPodspecPaths = pods.get().mapNotNull { it.source?.getLocalPath(project, it.name) }
|
val localPodspecPaths = pods.get().mapNotNull { it.source?.getLocalPath(project, it.name) }
|
||||||
|
|
||||||
val specRepos = specRepos.get().getAll().toMutableList()
|
val specRepos = specRepos.get().getAll()
|
||||||
specRepos += URI("https://cdn.cocoapods.org")
|
|
||||||
|
|
||||||
val podGenProcessArgs = listOfNotNull(
|
val podGenProcessArgs = listOfNotNull(
|
||||||
"pod", "gen",
|
"pod", "gen",
|
||||||
|
|||||||
+3
@@ -189,6 +189,9 @@ open class PodspecTask : DefaultTask() {
|
|||||||
if (project.rootProject == project) project.multiplatformExtensionOrNull?.cocoapodsExtensionOrNull?.podfile != null
|
if (project.rootProject == project) project.multiplatformExtensionOrNull?.cocoapodsExtensionOrNull?.podfile != null
|
||||||
else project.multiplatformExtensionOrNull?.cocoapodsExtensionOrNull?.podfile != null
|
else project.multiplatformExtensionOrNull?.cocoapodsExtensionOrNull?.podfile != null
|
||||||
|| (project.parent?.let { hasPodfileOwnOrParent(it) } ?: false)
|
|| (project.parent?.let { hasPodfileOwnOrParent(it) } ?: false)
|
||||||
|
|
||||||
|
internal fun retrieveSpecRepos(project: Project): SpecRepos? = project.multiplatformExtensionOrNull?.cocoapodsExtensionOrNull?.specRepos
|
||||||
|
internal fun retrievePods(project: Project): List<CocoapodsDependency>? = project.multiplatformExtensionOrNull?.cocoapodsExtensionOrNull?.podsAsTaskInput
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user