@@ -8,34 +8,23 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
8
8
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target
9
9
10
10
plugins {
11
- kotlin( " multiplatform" )
11
+ alias(libs.plugins.kotlin. multiplatform)
12
12
`maven- publish`
13
13
signing
14
- id( " com. android.library" )
15
- kotlin( " plugin. serialization" )
16
- id( " com.diffplug .spotless" ) version " 6.21.0 "
17
- id( " com.moowork .node" ) version " 1.3.1 "
18
- id( " org.jetbrains .dokka" ) version " 1.9.0 "
14
+ alias(libs.plugins. android.library)
15
+ alias(libs.plugins.kotlin. serialization)
16
+ alias(libs.plugins .spotless)
17
+ alias(libs.plugins .node)
18
+ alias(libs.plugins .dokka)
19
19
}
20
20
21
21
repositories {
22
22
google()
23
23
mavenCentral()
24
24
}
25
25
26
- buildscript {
27
- repositories {
28
- google()
29
- mavenCentral()
30
- }
31
- dependencies {
32
- classpath(" com.android.tools.build:gradle:" ) // resolved in settings.gradle.kts
33
- classpath(" org.jetbrains.kotlin:kotlin-gradle-plugin:" ) // resolved in settings.gradle.kts
34
- }
35
- }
36
-
37
26
// --- spotify-web-api-kotlin info ---
38
- val libraryVersion: String = System .getenv(" SPOTIFY_API_PUBLISH_VERSION" ) ? : " 0.0.0.SNAPSHOT"
27
+ val libraryVersion = System .getenv(" SPOTIFY_API_PUBLISH_VERSION" ) ? : " 0.0.0.SNAPSHOT"
39
28
40
29
// Publishing credentials (environment variable)
41
30
val nexusUsername: String? = System .getenv(" NEXUS_USERNAME" )
@@ -44,20 +33,21 @@ val nexusPassword: String? = System.getenv("NEXUS_PASSWORD")
44
33
group = " com.adamratzman"
45
34
version = libraryVersion
46
35
47
-
48
36
android {
49
37
namespace = " com.adamratzman.spotify"
50
- compileSdk = 31
38
+ compileSdk = 35
39
+
51
40
compileOptions {
52
- sourceCompatibility = JavaVersion .VERSION_17
53
- targetCompatibility = JavaVersion .VERSION_17
41
+ sourceCompatibility = JavaVersion .VERSION_21
42
+ targetCompatibility = JavaVersion .VERSION_21
54
43
}
44
+
55
45
packaging {
56
46
resources.excludes.add(" META-INF/*.md" ) // needed to prevent android compilation errors
57
47
}
48
+
58
49
defaultConfig {
59
50
minSdk = 23
60
- setCompileSdkVersion(31 )
61
51
testInstrumentationRunner = " android.support.test.runner.AndroidJUnitRunner"
62
52
}
63
53
@@ -66,15 +56,19 @@ android {
66
56
isMinifyEnabled = false
67
57
}
68
58
}
59
+
69
60
testOptions {
70
- this .unitTests.isReturnDefaultValues = true
61
+ unitTests.isReturnDefaultValues = true
62
+ }
63
+
64
+ sourceSets {
65
+ getByName(" main" ).setRoot(" src/androidMain" )
66
+ getByName(" test" ).setRoot(" src/androidUnitTest" )
71
67
}
72
- sourceSets[" main" ].setRoot(" src/androidMain" )
73
- sourceSets[" test" ].setRoot(" src/androidUnitTest" )
74
68
}
75
69
76
70
// invoked in kotlin closure, needs to be registered before
77
- val dokkaJar: TaskProvider < Jar > by tasks.registering(Jar ::class ) {
71
+ val dokkaJar by tasks.registering(Jar ::class ) {
78
72
group = JavaBasePlugin .DOCUMENTATION_GROUP
79
73
description = " spotify-web-api-kotlin generated documentation"
80
74
from(tasks.dokkaHtml)
@@ -83,25 +77,27 @@ val dokkaJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
83
77
84
78
kotlin {
85
79
@OptIn(ExperimentalKotlinGradlePluginApi ::class )
86
- compilerOptions {
80
+ compilerOptions {
87
81
freeCompilerArgs.add(" -Xexpect-actual-classes" )
88
82
}
83
+
89
84
explicitApiWarning()
90
- jvmToolchain(17 )
85
+ jvmToolchain(21 )
91
86
92
87
androidTarget {
93
- compilations.all { kotlinOptions.jvmTarget = " 17" }
88
+ compilations.all {
89
+ kotlinOptions.jvmTarget = " 21"
90
+ }
94
91
95
92
mavenPublication { setupPom(artifactId) }
96
93
97
94
publishLibraryVariants(" debug" , " release" )
98
-
99
95
publishLibraryVariantsGroupedByFlavor = true
100
96
}
101
97
102
98
jvm {
103
99
compilations.all {
104
- kotlinOptions.jvmTarget = " 1.8 "
100
+ kotlinOptions.jvmTarget = " 21 "
105
101
}
106
102
testRuns[" test" ].executionTask.configure {
107
103
useJUnit()
@@ -157,45 +153,24 @@ kotlin {
157
153
mavenPublication { setupPom(artifactId) }
158
154
}
159
155
160
- // !! unable to include currently due to korlibs not being available !!
161
- /*
162
- tvos {
163
- binaries { framework { baseName = "spotify" } }
164
-
165
- mavenPublication { setupPom(artifactId) }
166
- }
167
-
168
- watchos {
169
- binaries { framework { baseName = "spotify" } }
170
-
171
- mavenPublication { setupPom(artifactId) }
172
- }*/
173
-
156
+ // Apply default hierarchy template for source sets
174
157
applyDefaultHierarchyTemplate()
175
158
176
159
sourceSets {
177
- val kotlinxDatetimeVersion: String by project
178
- val kotlinxSerializationVersion: String by project
179
- val kotlinxCoroutinesVersion: String by project
180
- val ktorVersion: String by project
181
-
182
- val sparkVersion: String by project
183
- val korlibsVersion: String by project
184
-
185
160
commonMain {
186
161
dependencies {
187
- implementation(" org.jetbrains. kotlinx:kotlinx- serialization- json: $kotlinxSerializationVersion " )
188
- implementation(" io .ktor:ktor- client- core: $ktorVersion " )
189
- implementation(" com.soywiz. korlibs.krypto:krypto: $korlibsVersion " )
190
- implementation(" com.soywiz. korlibs.korim:korim: $korlibsVersion " )
191
- implementation(" org.jetbrains. kotlinx:kotlinx- datetime: $kotlinxDatetimeVersion " )
192
- implementation(" org.jetbrains. kotlinx:kotlinx- coroutines- core: $kotlinxCoroutinesVersion " )
162
+ implementation(libs. kotlinx. serialization. json)
163
+ implementation(libs .ktor. client. core)
164
+ implementation(libs. korlibs.krypto)
165
+ implementation(libs. korlibs.korim)
166
+ implementation(libs. kotlinx. datetime)
167
+ implementation(libs. kotlinx. coroutines. core)
193
168
}
194
169
}
195
170
196
171
commonTest {
197
172
dependencies {
198
- implementation(" org.jetbrains. kotlinx:kotlinx- coroutines- test: $kotlinxCoroutinesVersion " )
173
+ implementation(libs. kotlinx. coroutines. test)
199
174
implementation(kotlin(" test-common" ))
200
175
implementation(kotlin(" test-annotations-common" ))
201
176
}
@@ -205,14 +180,14 @@ kotlin {
205
180
dependsOn(commonMain.get())
206
181
207
182
dependencies {
208
- implementation(" net.sourceforge.streamsupport: android-retrofuture:1.7.3 " )
183
+ implementation(libs. android.retrofuture )
209
184
}
210
185
}
211
186
212
187
val commonJvmLikeTest by creating {
213
188
dependencies {
214
189
implementation(kotlin(" test-junit" ))
215
- implementation(" com.sparkjava: spark- core: $sparkVersion " )
190
+ implementation(libs. spark. core)
216
191
runtimeOnly(kotlin(" reflect" ))
217
192
}
218
193
}
@@ -224,20 +199,16 @@ kotlin {
224
199
jvmMain {
225
200
dependsOn(commonJvmLikeMain)
226
201
227
- repositories {
228
- mavenCentral()
229
- }
230
-
231
202
dependencies {
232
- implementation(" io .ktor:ktor- client- cio: $ktorVersion " )
203
+ implementation(libs .ktor. client. cio)
233
204
}
234
205
}
235
206
236
207
jvmTest.get().dependsOn(commonJvmLikeTest)
237
208
238
209
jsMain {
239
210
dependencies {
240
- implementation(" io .ktor:ktor- client-js: $ktorVersion " )
211
+ implementation(libs .ktor. client.js )
241
212
implementation(kotlin(" stdlib-js" ))
242
213
}
243
214
}
@@ -253,19 +224,11 @@ kotlin {
253
224
androidMain {
254
225
dependsOn(commonJvmLikeMain)
255
226
256
- repositories {
257
- mavenCentral()
258
- }
259
-
260
227
dependencies {
261
- val androidSpotifyAuthVersion: String by project
262
- val androidCryptoVersion: String by project
263
- val androidxCompatVersion: String by project
264
-
265
- api(" com.spotify.android:auth:$androidSpotifyAuthVersion " )
266
- implementation(" io.ktor:ktor-client-okhttp:$ktorVersion " )
267
- implementation(" androidx.security:security-crypto:$androidCryptoVersion " )
268
- implementation(" androidx.appcompat:appcompat:$androidxCompatVersion " )
228
+ api(libs.android.spotify.auth)
229
+ implementation(libs.ktor.client.okhttp)
230
+ implementation(libs.android.crypto)
231
+ implementation(libs.androidx.appcompat)
269
232
}
270
233
}
271
234
@@ -274,35 +237,38 @@ kotlin {
274
237
}
275
238
276
239
// desktop targets
277
- // as kotlin/native, they require special ktor versions
278
240
val desktopMain by creating {
279
241
dependsOn(commonMain.get())
280
242
281
243
dependencies {
282
- implementation(" io .ktor:ktor- client- curl: $ktorVersion " )
244
+ implementation(libs .ktor. client. curl)
283
245
}
284
246
}
285
247
286
248
linuxMain.get().dependsOn(desktopMain)
287
249
mingwMain.get().dependsOn(desktopMain)
288
250
macosMain.get().dependsOn(desktopMain)
289
251
290
- val desktopTest by creating { dependsOn(commonNonJvmTargetsTest) }
252
+ val desktopTest by creating {
253
+ dependsOn(commonNonJvmTargetsTest)
254
+ }
255
+
291
256
linuxTest.get().dependsOn(desktopTest)
292
257
mingwTest.get().dependsOn(desktopTest)
293
258
macosTest.get().dependsOn(desktopTest)
294
259
295
260
// darwin targets
296
-
297
261
val nativeDarwinMain by creating {
298
262
dependsOn(commonMain.get())
299
263
300
264
dependencies {
301
- implementation(" io .ktor:ktor- client- ios: $ktorVersion " )
265
+ implementation(libs .ktor. client. ios)
302
266
}
303
267
}
304
268
305
- val nativeDarwinTest by creating { dependsOn(commonNonJvmTargetsTest) }
269
+ val nativeDarwinTest by creating {
270
+ dependsOn(commonNonJvmTargetsTest)
271
+ }
306
272
307
273
iosMain.get().dependsOn(nativeDarwinMain)
308
274
iosTest.get().dependsOn(nativeDarwinTest)
@@ -343,11 +309,10 @@ tasks {
343
309
}
344
310
}
345
311
346
-
347
- val publishAllPublicationsToNexusRepositoryWithTests by registering(Task ::class ) {
348
- dependsOn.add(check)
349
- dependsOn.add(" publishAllPublicationsToNexusRepository" )
350
- dependsOn.add(dokkaHtml)
312
+ register<Task >(" publishAllPublicationsToNexusRepositoryWithTests" ) {
313
+ dependsOn(check)
314
+ dependsOn(" publishAllPublicationsToNexusRepository" )
315
+ dependsOn(dokkaHtml)
351
316
}
352
317
353
318
withType<Test > {
@@ -356,27 +321,30 @@ tasks {
356
321
}
357
322
}
358
323
359
- val packForXcode by creating( Sync :: class ) {
324
+ register< Sync >( " packForXcode " ) {
360
325
group = " build"
361
326
val mode = System .getenv(" CONFIGURATION" ) ? : " DEBUG"
362
327
val sdkName = System .getenv(" SDK_NAME" ) ? : " iphonesimulator"
363
328
val targetName = " ios" + if (sdkName.startsWith(" iphoneos" )) " Arm64" else " X64"
364
329
val framework = kotlin.targets.getByName<KotlinNativeTarget >(targetName).binaries.getFramework(mode)
365
330
inputs.property(" mode" , mode)
366
- dependsOn(framework.linkTask )
331
+ dependsOn(framework.linkTaskProvider )
367
332
val targetDir = File (layout.buildDirectory.asFile.get(), " xcode-frameworks" )
368
333
from({ framework.outputDirectory })
369
334
into(targetDir)
370
335
}
371
- getByName(" build" ).dependsOn(packForXcode)
336
+
337
+ named(" build" ) {
338
+ dependsOn(" packForXcode" )
339
+ }
372
340
}
373
341
342
+ // Configure signing tasks to run before publishing
374
343
val signingTasks = tasks.withType<Sign >()
375
344
tasks.withType<AbstractPublishToMaven >().configureEach {
376
345
dependsOn(signingTasks)
377
346
}
378
347
379
-
380
348
fun MavenPublication.setupPom (publicationName : String ) {
381
349
artifactId = artifactId.replace(" -web" , " " )
382
350
artifact(dokkaJar.get()) // add javadocs to publication
@@ -400,6 +368,7 @@ fun MavenPublication.setupPom(publicationName: String) {
400
368
distribution.set(" repo" )
401
369
}
402
370
}
371
+
403
372
developers {
404
373
developer {
405
374
id.set(" adamratzman" )
@@ -410,9 +379,7 @@ fun MavenPublication.setupPom(publicationName: String) {
410
379
}
411
380
}
412
381
413
-
414
382
// --- Publishing ---
415
-
416
383
fun PublishingExtension.registerPublishing () {
417
384
publications {
418
385
val kotlinMultiplatform by getting(MavenPublication ::class ) {
@@ -445,10 +412,7 @@ val signingPassword = project.findProperty("SIGNING_PASSWORD") as? String
445
412
446
413
signing {
447
414
if (signingKey != null && signingPassword != null ) {
448
- useInMemoryPgpKeys(
449
- project.findProperty(" SIGNING_KEY" ) as ? String ,
450
- project.findProperty(" SIGNING_PASSWORD" ) as ? String
451
- )
415
+ useInMemoryPgpKeys(signingKey, signingPassword)
452
416
sign(publishing.publications)
453
417
}
454
418
}
0 commit comments