From 819e83b68b47230147bd59b726ab3484f3a7dfb4 Mon Sep 17 00:00:00 2001 From: Yaroslav Chernyshev Date: Mon, 28 Sep 2020 13:35:22 +0300 Subject: [PATCH] [Gradle, Cocoapods] Complete logging for corner-case pod configurations --- .../native/cocoapods/CocoapodsExtension.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt index e535c441128..8e1c26c4a67 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt @@ -116,17 +116,23 @@ open class CocoapodsExtension(private val project: Project) { val buildScript = project.buildFile val lines = buildScript.readLines() val lineNumber = lines.indexOfFirst { pattern.matches(it) } - val lineContent = lines[lineNumber].trimIndent() - val newContent = lineContent.replace(path.name, "") - project.logger.warn( + val warnMessage = if (lineNumber != -1) run { + val lineContent = lines[lineNumber].trimIndent() + val newContent = lineContent.replace(path.name, "") """ - |Deprecated DSL used on ${buildScript.absolutePath}${File.pathSeparator}${lineNumber + 1}: + |Deprecated DSL found on ${buildScript.absolutePath}${File.pathSeparator}${lineNumber + 1}: |Found: "${lineContent}" |Expected: "${newContent}" |Please, change the path to avoid this warning. | """.trimMargin() - ) + } else + """ + |Deprecated DSL is used for pod "$name". + |Please, change its path from ${path.path} to ${path.parentFile.path} + | + """.trimMargin() + project.logger.warn(warnMessage) podSource = path.parentFile } addToPods(CocoapodsDependency(name, moduleName, version, podSource?.let { Path(it) }))