-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
125 lines (110 loc) · 4.25 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import org.ajoberstar.grgit.Grgit
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
plugins {
id("build-logic")
kotlin("multiplatform") version libs.versions.kotlin
kotlin("native.cocoapods") version libs.versions.kotlin
alias(libs.plugins.grgit)
alias(libs.plugins.ktlint)
}
allprojects {
group = "org.cru.godtools.kotlin"
// configure the project version
if (!project.findProperty("releaseBuild")?.toString().toBoolean()) {
project.findProperty("versionSuffix")?.toString()
?.takeIf { it.matches(Regex("\\S+")) }
?.let { version = "$version-$it" }
version = "$version-SNAPSHOT"
}
}
kotlin {
configureIosTargets()
sourceSets {
commonMain {
dependencies {
api(project(":module:analytics"))
api(project(":module:interop"))
api(project(":module:parser"))
api(project(":module:state"))
api(project(":module:user-activity"))
}
}
}
cocoapods {
name = "GodToolsShared"
summary = "GodTools shared logic"
license = "MIT"
homepage = "https://github.com/CruGlobal/kotlin-mpp-godtools-tool-parser"
extraSpecAttributes += mapOf(
"prepare_command" to """"./gradlew generateDummyFramework"""",
"preserve_paths" to """"**/*.*"""",
)
// configure the custom xcode configurations in the godtools-swift project
xcodeConfigurationToNativeBuildType += mapOf(
"AnalyticsLogging" to NativeBuildType.DEBUG,
"Staging" to NativeBuildType.DEBUG,
"Production" to NativeBuildType.DEBUG,
)
val frameworkBaseName = "GodToolsToolParser"
framework {
baseName = frameworkBaseName
export(project(":module:analytics"))
export(project(":module:interop"))
export(project(":module:parser"))
export(project(":module:state"))
export(project(":module:user-activity"))
}
// HACK: workaround a generated framework existence check added in Kotlin 1.9.20
// We automatically generate the dummy framework via the spec.prepare_command
val framework = layout.buildDirectory
.dir("cocoapods/framework/$frameworkBaseName.framework").get().asFile
.relativeTo(projectDir)
extraSpecAttributes += "vendored_frameworks" to """"${framework.invariantSeparatorsPath}""""
ios.deploymentTarget = "14.0"
}
}
// region Cocoapods
// HACK: customize the podspec until KT-42105 is implemented
// https://youtrack.jetbrains.com/issue/KT-42105
tasks.podspec.configure {
doLast {
// we can't use the grgit extension val because it won't be present if the .git directory is missing
val grgit = project.extensions.findByName("grgit") as? Grgit
val newPodspecContent = outputFile.readLines().map {
when {
grgit != null && it.contains("spec.source") -> {
val ref = when {
isSnapshotVersion -> ":commit => \"${grgit.head().id}\""
else -> ":tag => \"v${project.version}\""
}
"""
|#$it
| spec.source = {
| :git => "https://github.com/CruGlobal/kotlin-mpp-godtools-tool-parser.git",
| $ref
| }
""".trimMargin()
}
else -> it
}
}
outputFile.writeText(newPodspecContent.joinToString(separator = "\n"))
}
}
tasks.create("cleanPodspec", Delete::class) {
delete(tasks.podspec.map { it.outputFile })
}.also { tasks.clean.configure { dependsOn(it) } }
// endregion Cocoapods
// region KtLint
allprojects {
beforeEvaluate {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
ktlint {
version.set(libs.versions.ktlint)
filter {
exclude { it.file.path.startsWith("${buildDir.path}/") }
}
}
}
}
// endregion KtLint