/
build.gradle.kts
146 lines (130 loc) · 3.71 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
@file:Suppress("UNUSED_VARIABLE")
import com.apollographql.apollo3.gradle.internal.ApolloDownloadSchemaTask
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.konan.properties.Properties
plugins {
kotlin("multiplatform")
id("com.android.library")
id("com.apollographql.apollo3")
id("com.codingfeline.buildkonfig")
}
kotlin {
android()
jvm()
val iosX64 = iosX64()
val iosArm64 = iosArm64()
val iosSimulatorArm64 = iosSimulatorArm64()
js(IR) {
browser()
nodejs()
}
targets.all {
compilations.all {
kotlinOptions {
allWarningsAsErrors = true
}
}
}
sourceSets {
// region Common
val commonMain by getting {
dependencies {
implementation(ApolloGraphql.runtime)
api(Arrow.core)
implementation(Koin.core)
implementation(Kotlinx.coroutinesCore)
implementation(Touchlab.kermit)
}
}
val commonTest by getting {
dependencies {
implementation(Kotlinx.coroutinesTest)
implementation(kotlin("test"))
}
}
// endregion
// region Android
val androidMain by getting {
dependsOn(commonMain)
dependencies {
implementation("io.ktor:ktor-client-okhttp:2.0.0-beta-1")
}
}
val androidTest by getting {
dependsOn(commonTest)
}
// endregion
// region Jvm
val jvmMain by getting {
dependsOn(commonMain)
}
val jvmTest by getting {
dependsOn(commonTest)
}
// endregion
// region Js
val jsMain by getting {
dependsOn(commonMain)
}
val jsTest by getting {
dependsOn(commonTest)
}
// endregion
// region Native
val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by creating {
dependsOn(commonTest)
}
val iosMain by creating {
dependsOn(nativeMain)
}
val iosTest by creating {
dependsOn(nativeTest)
}
listOf(
iosArm64, iosX64, iosSimulatorArm64
).forEach { target: KotlinNativeTarget ->
target.binaries.framework {
baseName = "shared"
}
getByName("${target.targetName}Main") {
dependsOn(iosMain)
}
getByName("${target.targetName}Test") {
dependsOn(iosTest)
}
}
// endregion
}
}
android {
compileSdk = AndroidSdk.compile
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = AndroidSdk.min
targetSdk = AndroidSdk.target
}
}
apollo {
service("pawFinder") {
packageName.set("xyz.stylianosgakis.pawfinder")
codegenModels.set("responseBased")
}
}
val properties = Properties().apply {
load(rootProject.file("local.properties").inputStream())
}
val backendGraphQlEndpoint: String = properties.getProperty("backendGraphQlEndpoint")
buildkonfig {
packageName = "xyz.stylianosgakis.pawfinder"
defaultConfigs {
buildConfigField(STRING, "backendGraphQlEndpoint", backendGraphQlEndpoint)
}
}
tasks.register("downloadSchema", ApolloDownloadSchemaTask::class.java) {
endpoint.set(backendGraphQlEndpoint)
schema.set("shared/src/commonMain/graphql/xyz/stylianosgakis/pawfinder/schema.graphqls")
}