This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle.kts
232 lines (211 loc) · 7.51 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
* Copyright 2023 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework.BitcodeEmbeddingMode.BITCODE
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
plugins {
kotlin("multiplatform") version "1.7.10"
kotlin("native.cocoapods") version "1.7.10"
kotlin("plugin.serialization") version "1.7.10"
id("io.gitlab.arturbosch.detekt") version "1.20.0"
id("maven-publish")
id("io.codearte.nexus-staging") version "0.22.0"
id("signing")
}
detekt {
toolVersion = "1.20.0"
config = files("detekt.yml")
buildUponDefaultConfig = true
source = files("src/commonMain/kotlin")
}
repositories {
google()
mavenCentral()
}
kotlin {
jvm()
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
version = "1.0.0-beta.1"
summary = "Nimbus Core Library"
homepage = "Link to the Shared Module homepage"
framework {
baseName = "NimbusCore"
isStatic = false
transitiveExport = false
embedBitcode(BITCODE)
}
// Maps custom Xcode configuration to NativeBuildType
xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG
xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE
}
sourceSets {
val serializationVersion = "1.4.0"
val coroutinesVersion = "1.6.4"
val ktorVersion = "2.1.1"
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("io.ktor:ktor-client-core:$ktorVersion")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-common"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
implementation("io.ktor:ktor-client-mock:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
}
}
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
dependencies {
implementation("io.ktor:ktor-client-darwin:$ktorVersion")
}
}
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions{
kotlin.sourceSets.all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
}
}
tasks.register<Copy>("copyiOSTestResources") {
from("src/commonTest/resources")
into("build/bin/iosX64/debugTest/resources")
}
tasks.findByName("iosX64Test")!!.dependsOn("copyiOSTestResources")
// TODO Extract the code below to another file
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}
// ------------------------- Publication configuration --------------------- //
val releaseVersion = !version.toString().endsWith("-SNAPSHOT")
val sonatypeUsername = System.getenv("ORG_GRADLE_PROJECT_mavenCentralUsername") ?: ""
val sonatypePassword = System.getenv("ORG_GRADLE_PROJECT_mavenCentralPassword") ?: ""
val versionName = System.getenv("VERSION_NAME") ?: project.property("VERSION_NAME").toString()
val signinKeyId = System.getenv("ORG_GRADLE_PROJECT_SIGNINGKEYID") ?: ""
val signinPassword = System.getenv("ORG_GRADLE_PROJECT_SIGNINGPASSWORD") ?: ""
//POM Configuration
val pomGroup = project.property("POM_GROUP").toString()
val pomName = project.property("POM_NAME").toString()
val pomDescription = project.property("POM_DESCRIPTION").toString()
val pomYear = project.property("POM_INCEPTION_YEAR").toString()
val pomLicenseDist = project.property("POM_LICENCE_DIST").toString()
val pomLicenseName = project.property("POM_LICENCE_NAME").toString()
val pomLicenseUrl = project.property("POM_LICENCE_URL").toString()
val pomIssuesUrl = project.property("POM_ISSUES_URL").toString()
val pomIssuesSystem = project.property("POM_ISSUES_SYSTEM").toString()
val pomDevId = project.property("POM_DEVELOPER_ID").toString()
val pomDevName = project.property("POM_DEVELOPER_NAME").toString()
val pomDevUrl = project.property("POM_DEVELOPER_URL").toString()
val pomUrl = project.property("POM_URL").toString()
val pomScmConnection = project.property("POM_SCM_CONNECTION").toString()
val pomScmDevConnection = project.property("POM_SCM_DEV_CONNECTION").toString()
val pomScmUrl = project.property("POM_SCM_URL").toString()
/*
Needed to generate the nexus staging metadata, this uses the gpg file selected
on ~/.gradle/gradle.properties to sign the artifact before send to maven central
*/
extra["signing.keyId"] = signinKeyId
extra["signing.password"] = signinPassword
group = pomGroup
version = versionName
publishing {
repositories {
maven {
name="oss"
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = if (releaseVersion) releasesRepoUrl else snapshotsRepoUrl
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
publications {
withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(javadocJar.get())
pom {
name.set(pomName)
description.set(pomDescription)
url.set(pomUrl)
inceptionYear.set(pomYear)
licenses {
license {
distribution.set(pomLicenseDist)
name.set(pomLicenseName)
url.set(pomLicenseUrl)
}
}
issueManagement {
system.set(pomIssuesSystem)
url.set(pomIssuesUrl)
}
scm {
developerConnection.set(pomScmDevConnection)
connection.set(pomScmConnection)
url.set(pomScmUrl)
}
developers {
developer {
id.set(pomDevId)
name.set(pomDevName)
email.set(pomDevUrl)
}
}
}
}
}
}
signing {
setRequired {
// signing is required if this is a release version and the artifacts are to be published
// do not use hasTask() as this require realization of the tasks that maybe are not necessary
releaseVersion && gradle.taskGraph.allTasks.any { it is PublishToMavenRepository }
}
@Suppress("UnstableApiUsage")
sign(publishing.publications)
}
nexusStaging {
username = sonatypeUsername
password = sonatypePassword
packageGroup = "br.com.zup"
}
// ------------------------- End of Publication configuration --------------------- //