-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
215 lines (188 loc) · 5.96 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
import java.text.SimpleDateFormat
import java.util.Date
import uk.gov.hmrc.Dependencies
buildscript{
repositories {
maven {
url = uri("https://maven.pkg.github.com/hmrc/mobile-gradle-plugins")
credentials {
username = System.getenv("GITHUB_USER_NAME")
password = System.getenv("GITHUB_TOKEN")
}
}
}
dependencies {
classpath("uk.gov.hmrc.gradle:spotless:1.1.1")
}
}
apply(plugin = "uk.gov.hmrc.spotless")
group = "uk.gov.hmrc"
description = "Multiplatform Help To Save Calculator library"
version = System.getenv("BITRISE_GIT_TAG") ?: ("SNAPSHOT-" + getDate())
plugins {
`maven-publish`
kotlin("multiplatform").version("1.8.10")
java
id("io.gitlab.arturbosch.detekt").version("1.6.0")
id("com.chromaticnoise.multiplatform-swiftpackage").version("2.0.3")
id("org.jetbrains.kotlinx.kover") version "0.5.0"
}
repositories {
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
// Configure source sets
kotlin {
jvm()
val iosX64 = iosX64("ios")
val iosArm32 = iosArm32()
val iosArm64 = iosArm64()
val iosSimulatorArm64 = iosSimulatorArm64()
val xcFramework = XCFramework(Config.frameworkName)
targets{
configure(listOf(iosX64, iosArm32, iosArm64, iosSimulatorArm64)) {
binaries.framework {
baseName = Config.frameworkName
xcFramework.add(this)
embedBitcode("disable")
}
}
}
sourceSets.all {
languageSettings.optIn("kotlin.Experimental")
}
sourceSets {
val commonMain by getting {
dependencies {
with(Dependencies.Common.Main) {
implementation(kotlin(stdlib))
implementation(klock)
implementation(kermit)
}
}
}
val commonTest by getting {
dependencies {
with(Dependencies.Common.Test) {
implementation(kotlin(uk.gov.hmrc.Dependencies.Common.Test.common))
implementation(kotlin(uk.gov.hmrc.Dependencies.Common.Test.annotations))
implementation(uk.gov.hmrc.Dependencies.Common.Test.junit)
runtimeOnly(uk.gov.hmrc.Dependencies.Common.Test.jupiter)
}
}
}
val jvmMain by getting {
dependencies {
with(Dependencies.JVM.Main) {
implementation(kotlin(uk.gov.hmrc.Dependencies.JVM.Main.stdlib))
}
}
}
val jvmTest by getting {
dependencies {
with(Dependencies.JVM.Test) {
implementation(kotlin(uk.gov.hmrc.Dependencies.JVM.Test.test))
implementation(kotlin(uk.gov.hmrc.Dependencies.JVM.Test.junit))
implementation(uk.gov.hmrc.Dependencies.JVM.Test.jupiter)
}
}
}
val iosMain by getting {
dependencies {
with(Dependencies.IOS.Main) {
implementation(kotlin(uk.gov.hmrc.Dependencies.IOS.Main.stdlib))
}
}
}
val iosTest by getting {}
val iosArm32Main by sourceSets.getting
val iosArm64Main by sourceSets.getting
val iosSimulatorArm64Main by sourceSets.getting
configure(listOf(iosArm32Main, iosArm64Main, iosSimulatorArm64Main)) {
dependsOn(iosMain)
}
val iosArm32Test by sourceSets.getting
val iosArm64Test by sourceSets.getting
val iosSimulatorArm64Test by sourceSets.getting
configure(listOf(iosArm32Test, iosArm64Test, iosSimulatorArm64Test)) {
dependsOn(iosTest)
}
}
}
// Configure Swift Package Manager
multiplatformSwiftPackage {
swiftToolsVersion("5.3")
targetPlatforms {
iOS { v("13") }
}
outputDirectory(File(projectDir, "build/XCFrameworks/release"))
}
// Configure GitHub Packages publishing
publishing {
publications {
create<MavenPublication>("mavenJava") {
groupId = "$group.$artifactId"
artifactId = artifactId
version = version
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/hmrc/help-to-save-kalculator")
credentials {
username = System.getenv("GITHUB_USER_NAME")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
configurations {
compileClasspath
}
detekt {
input = files("src/commonMain/kotlin")
config = files("detekt-config.yml")
reports {
html {
enabled = true
destination = file("build/reports/detekt/index.html")
}
}
}
tasks.koverVerify {
rule {
name = "Coverage rate"
bound {
minValue = 95
valueType = kotlinx.kover.api.VerificationValueType.COVERED_LINES_PERCENTAGE
}
}
}
tasks.named<Test>("jvmTest") {
useJUnitPlatform()
testLogging {
showExceptions = true
showStandardStreams = true
events = setOf(org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED, org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED)
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
tasks.named<Jar>("jvmJar") {
archiveFileName.set("${Config.artifactId}-$version.jar")
}
tasks.getByName<org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest>("iosTest") {
deviceId = "iPhone 14"
}
fun getDate(): String {
val date = Date()
val format = "yyyyMMddHHmm"
return SimpleDateFormat(format).format(date).toString()
}
object Config {
const val artifactId = "help-to-save-kalculator"
const val frameworkName = "HelpToSaveKalculator"
}