generated from cortinico/kotlin-gradle-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
161 lines (153 loc) · 5.29 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import io.github.frankois944.spmForKmp.definition.SwiftDependency
import io.github.frankois944.spmForKmp.definition.product.ProductName
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.net.URI
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.kotlinMultiplatform)
id("io.github.frankois944.spmForKmp")
}
kotlin {
androidTarget {
compilations.all {
compileTaskProvider.configure {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
}
}
listOf(
iosX64(),
iosSimulatorArm64(),
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
}
it.compilations {
val main by getting {
cinterops.create("nativeIosShared")
}
}
}
listOf(
macosArm64(),
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
}
it.compilations {
val main by getting {
cinterops.create("nativeMacosShared")
}
}
}
sourceSets {
commonMain.dependencies {
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}
val copyTestResources =
tasks.register<Copy>("copyTestResources") {
from(
"${layout.projectDirectory.asFile.path}/../plugin-build/plugin/src/functionalTest/resources" +
"/DummyFramework.xcframework/ios-arm64_x86_64-simulator/",
) {
include("*.framework/**")
}
into("${layout.projectDirectory.asFile.path}/build/bin/iosSimulatorArm64/debugTest/Frameworks/")
}
tasks.named("iosSimulatorArm64Test") {
dependsOn(copyTestResources)
}
android {
namespace = "com.example"
compileSdk = 34
defaultConfig {
minSdk = 24
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
val testResources = "${layout.projectDirectory.asFile.path}/../plugin-build/plugin/src/functionalTest/resources"
swiftPackageConfig {
create("nativeIosShared") {
// optional parameters
// the ios minimal version
// minIos = "12.0"
// the tvos minimal version
// minTvos = "12.0"
// the watchos minimal version
// minWatchos = "12.0"
// the macos minimal version
minMacos = "10.15"
// the directory where your own swift code is located
// customPackageSourcePath = "{buildDir}/src/swift"
// the swift code is built in debug by default
// debug = false :
// add a prefix to the dependencies package names
// ei :
// - packageDependencyPrefix = "customName"
// - give : "customName.FirebaseCore" instead of "FirebaseCore"
// packageDependencyPrefix = null // default null
spmWorkingPath = "${projectDir.resolve("SPM")}" // change the Swift Package Manager working Dir
dependency(
SwiftDependency.Package.Remote.Version(
// Repository URL
url = URI("https://github.com/firebase/firebase-ios-sdk.git"),
// Libraries from the package
products = {
// Export to Kotlin for use in shared Kotlin code
add("FirebaseCore", "FirebaseAnalytics", exportToKotlin = true)
// add FirebaseDatabase to your own swift code but don't export it
add(ProductName("FirebaseDatabase"))
},
// (Optional) Package name, can be required in some cases
packageName = "firebase-ios-sdk",
// Package version
version = "11.8.1",
),
SwiftDependency.Binary.Local(
path = "$testResources/DummyFramework.xcframework.zip",
packageName = "DummyFramework",
exportToKotlin = true,
),
SwiftDependency.Package.Local(
path = "$testResources/LocalSourceDummyFramework",
packageName = "LocalSourceDummyFramework",
products = {
// Export to Kotlin for use in shared Kotlin code, false by default
add("LocalSourceDummyFramework", exportToKotlin = true)
},
),
SwiftDependency.Package.Remote.Version(
url = URI("https://github.com/krzyzanowskim/CryptoSwift.git"),
version = "1.8.1",
products = {
// Can be only used in your "src/swift" code.
add("CryptoSwift")
},
),
// see SwiftDependency class for more use cases
)
}
create("nativeMacosShared") {
dependency(
SwiftDependency.Package.Local(
path = "$testResources/LocalSourceDummyFramework",
packageName = "LocalSourceDummyFramework",
products = {
// Export to Kotlin for use in shared Kotlin code, false by default
add("LocalSourceDummyFramework", exportToKotlin = false)
},
),
)
}
}