[Cocoapods] Fail import if project's version wasn't specified

#Fixed KT-44000
This commit is contained in:
Yaroslav Chernyshev
2021-02-08 16:35:16 +03:00
parent c158c64ee0
commit 8acf3b1d76
2 changed files with 25 additions and 1 deletions
@@ -309,6 +309,22 @@ class CocoaPodsIT : BaseGradleIT() {
project.test(":kotlin-library:podDownload")
}
@Test
fun errorIfVersionIsNotSpecified() {
with(project.gradleBuildScript()) {
useLines { lines ->
lines.filter { line -> "version = \"1.0\"" !in line }.joinToString(separator = "\n")
}.also { writeText(it) }
}
hooks.addHook {
assertContains("Cocoapods Integration requires version of this project to be specified.")
}
project.build(POD_IMPORT_TASK_NAME, "-Pkotlin.native.cocoapods.generate.wrapper=true") {
assertFailed()
hooks.trigger(this)
}
}
// up-to-date tests
@@ -19,7 +19,15 @@ import java.net.URI
open class CocoapodsExtension(private val project: Project) {
@get:Input
val version: String
get() = project.version.toString()
get() {
require(project.version != Project.DEFAULT_VERSION) { """
Cocoapods Integration requires version of this project to be specified.
Please, add line 'version = "<version>"' to project's build file.
For more details, please, see https://guides.cocoapods.org/syntax/podspec.html#version
""".trimIndent()
}
return project.version.toString()
}
/**
* Configure authors of the pod built from this project.