1
1
import org.jetbrains.dokka.gradle.DokkaTask
2
2
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target
3
- import java.net.URI
4
3
5
4
plugins {
6
5
`maven- publish`
7
6
signing
8
- `java- library`
9
7
id(" io.codearte.nexus-staging" ) version " 0.21.2"
10
8
kotlin(" multiplatform" ) version " 1.3.72"
11
9
kotlin(" plugin.serialization" ) version " 1.3.72"
12
10
id(" com.diffplug.gradle.spotless" ) version " 4.4.0"
13
11
id(" com.moowork.node" ) version " 1.3.1"
14
12
id(" org.jetbrains.dokka" ) version " 0.10.1"
13
+ id(" com.android.library" )
14
+ id(" kotlin-android-extensions" )
15
+ }
16
+
17
+ repositories {
18
+ jcenter()
19
+ google()
20
+ maven(" https://kotlin.bintray.com/kotlinx" )
21
+ }
22
+
23
+ buildscript {
24
+ repositories {
25
+ google()
26
+ }
27
+ dependencies {
28
+ classpath(" com.android.tools.build:gradle:3.5.4" )
29
+ classpath(" org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72" )
30
+ }
15
31
}
16
32
17
33
group = " com.adamratzman"
18
- version = " 3.1.02 "
34
+ version = " 3.2.0 "
19
35
20
- java {
36
+ /* java {
21
37
withSourcesJar()
22
38
withJavadocJar()
23
39
}
40
+ */
24
41
25
42
tasks.withType<Test > {
26
43
this .testLogging {
27
44
this .showStandardStreams = true
28
45
}
29
46
}
30
47
31
- repositories {
32
- mavenCentral()
33
- jcenter()
34
- maven(" https://kotlin.bintray.com/kotlinx" )
48
+ android {
49
+ compileSdkVersion(30 )
50
+ defaultConfig {
51
+ minSdkVersion(15 )
52
+ targetSdkVersion(30 )
53
+ versionCode = 1
54
+ versionName = " 1.0"
55
+ testInstrumentationRunner = " android.support.test.runner.AndroidJUnitRunner"
56
+ }
57
+ buildTypes {
58
+ getByName(" release" ) {
59
+ isMinifyEnabled = false
60
+ }
61
+ }
62
+ sourceSets {
63
+ getByName(" main" ) {
64
+ manifest.srcFile(" src/androidMain/AndroidManifest.xml" )
65
+ java.setSrcDirs(listOf (" src/androidMain/kotlin" ))
66
+ res.setSrcDirs(listOf (" src/androidMain/res" ))
67
+ }
68
+ getByName(" androidTest" ) {
69
+ java.setSrcDirs(listOf (" src/androidTest/kotlin" ))
70
+ res.setSrcDirs(listOf (" src/androidTest/res" ))
71
+ }
72
+ }
73
+ }
74
+
75
+ val dokkaJar by tasks.registering(Jar ::class ) {
76
+ group = JavaBasePlugin .DOCUMENTATION_GROUP
77
+ description = " Docs"
78
+ classifier = " javadoc"
79
+ from(tasks.dokka)
35
80
}
36
81
37
82
kotlin {
38
- jvm()
83
+ android {
84
+ mavenPublication {
85
+ artifactId = " spotify-api-kotlin-android"
86
+ setupPom(artifactId)
87
+ }
88
+
89
+ publishLibraryVariants(" release" )
90
+ }
91
+
92
+ jvm {
93
+ mavenPublication {
94
+ artifactId = " spotify-api-kotlin"
95
+ setupPom(artifactId)
96
+ }
97
+ }
98
+
39
99
js {
100
+ mavenPublication {
101
+ artifactId = " spotify-api-kotlin-js"
102
+ setupPom(artifactId)
103
+ }
104
+
40
105
browser {
41
106
dceTask {
42
107
keep(" ktor-ktor-io.\$\$ importsForInline\$\$ .ktor-ktor-io.io.ktor.utils.io" )
@@ -88,7 +153,6 @@ kotlin {
88
153
api(" org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion " )
89
154
api(" org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion " )
90
155
api(" io.ktor:ktor-client-okhttp:$ktorVersion " )
91
- api(" commons-codec:commons-codec:1.14" )
92
156
implementation(kotlin(" stdlib-jdk8" ))
93
157
}
94
158
}
@@ -124,6 +188,32 @@ kotlin {
124
188
}
125
189
}
126
190
191
+ val androidMain by getting {
192
+ repositories {
193
+ mavenCentral()
194
+ jcenter()
195
+ }
196
+
197
+ dependencies {
198
+ api(" net.sourceforge.streamsupport:android-retrofuture:1.7.2" )
199
+ api(" org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion " )
200
+ api(" org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion " )
201
+ api(" io.ktor:ktor-client-okhttp:$ktorVersion " )
202
+ implementation(kotlin(" stdlib-jdk8" ))
203
+ }
204
+ }
205
+
206
+ val androidTest by getting {
207
+ dependencies {
208
+ implementation(kotlin(" test" ))
209
+ implementation(kotlin(" test-junit" ))
210
+ implementation(" org.junit.jupiter:junit-jupiter:5.6.2" )
211
+ implementation(" org.spekframework.spek2:spek-dsl-jvm:$spekVersion " )
212
+ runtimeOnly(" org.spekframework.spek2:spek-runner-junit5:$spekVersion " )
213
+ runtimeOnly(kotlin(" reflect" ))
214
+ }
215
+ }
216
+
127
217
all {
128
218
languageSettings.useExperimentalAnnotation(" kotlin.Experimental" )
129
219
}
@@ -133,145 +223,71 @@ kotlin {
133
223
134
224
publishing {
135
225
publications {
136
- val jvm by getting(MavenPublication ::class ) {
137
- artifactId = " spotify-api-kotlin"
138
- artifact(tasks.getByName(" javadocJar" ))
139
- versionMapping {
140
- usage(" java-api" ) {
141
- fromResolutionOf(" runtimeClasspath" )
142
- }
143
- usage(" java-runtime" ) {
144
- fromResolutionResult()
145
- }
146
- }
226
+ val kotlinMultiplatform by getting(MavenPublication ::class ) {
227
+ artifactId = " spotify-api-kotlin-core"
228
+ setupPom(artifactId)
229
+ }
147
230
148
- pom {
149
- name.set(" spotify-api-kotlin" )
150
- description.set(" A Kotlin wrapper for the Spotify Web API." )
151
- url.set(" https://github.com/adamint/spotify-web-api-kotlin" )
152
- inceptionYear.set(" 2018" )
153
- scm {
154
- url.set(" https://github.com/adamint/spotify-web-api-kotlin" )
155
- connection.set(" scm:https://github.com/adamint/spotify-web-api-kotlin.git" )
156
- developerConnection.set(" scm:git://github.com/adamint/spotify-web-api-kotlin.git" )
157
- }
158
- licenses {
159
- license {
160
- name.set(" The Apache Software License, Version 2.0" )
161
- url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
162
- distribution.set(" repo" )
163
- }
164
- }
165
- developers {
166
- developer {
167
- id.set(" adamratzman" )
168
- name.set(" Adam Ratzman" )
169
-
170
- }
171
- }
172
- }
231
+ val metadata by getting(MavenPublication ::class ) {
232
+ artifactId = " spotify-api-kotlin-metadata"
233
+ setupPom(artifactId)
173
234
}
174
235
}
236
+
175
237
repositories {
176
- if (System .getenv(" publishLocation" ) == " nexus" ) {
177
- maven {
178
- name = " nexus"
179
- val releasesRepoUrl = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
180
- val snapshotsRepoUrl = " https://oss.sonatype.org/content/repositories/snapshots/"
181
- url = uri(if (version.toString().endsWith(" SNAPSHOT" )) snapshotsRepoUrl else releasesRepoUrl)
182
-
183
- credentials {
184
- val nexusUsername: String? by project.extra
185
- val nexusPassword: String? by project.extra
186
- username = nexusUsername
187
- password = nexusPassword
188
- }
189
- }
190
- } else {
191
- if (project.extra.has(" spaceUser" ) && project.extra.has(" spacePassword" )) {
192
- maven {
193
- credentials {
194
- username = project.extra[" spaceUser" ]?.toString()
195
- password = project.extra[" spacePassword" ]?.toString()
196
- }
197
-
198
- url = URI .create(" https://maven.jetbrains.space/adam/ratzman" )
199
- }
238
+ maven {
239
+ name = " nexus"
240
+ val releasesRepoUrl = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
241
+ val snapshotsRepoUrl = " https://oss.sonatype.org/content/repositories/snapshots/"
242
+ url = uri(if (version.toString().endsWith(" SNAPSHOT" )) snapshotsRepoUrl else releasesRepoUrl)
243
+
244
+ credentials {
245
+ val nexusUsername: String? by project.extra
246
+ val nexusPassword: String? by project.extra
247
+ username = nexusUsername
248
+ password = nexusPassword
200
249
}
201
250
}
202
251
}
203
252
}
204
253
205
254
signing {
206
- if (System .getenv(" publishLocation" ) == " nexus" ) {
207
- sign(publishing.publications[" jvm" ])
208
- sign(publishing.publications[" js" ])
209
- }
210
- }
211
-
212
- // get signing confs interactively if needed
213
- gradle.taskGraph.whenReady {
214
- val alreadyConfigured = with (project.extra) {
215
- (has(" signing.keyId" ) && has(" signing.secretKeyRingFile" ) && has(" signing.password" ))
216
- || (has(" signing.notNeeded" ) && get(" signing.notNeeded" ) == " true" )
217
- }
218
- if (! alreadyConfigured && allTasks.any { it is Sign }) {
219
- // Use Java's console to read from the console (no good for
220
- // a CI environment)
221
- val console = System .console()
222
- requireNotNull(console) { " Could not get signing config: please provide yours in the gradle.properties file." }
223
- console.printf(
224
- " \n\n We have to sign some things in this build." +
225
- " \n\n Please enter your signing details.\n\n "
226
- )
227
-
228
- val id = console.readLine(" PGP Key Id: " )
229
- val file = console.readLine(" PGP Secret Key Ring File (absolute path): " )
230
- val password = console.readPassword(" PGP Private Key Password: " )
231
-
232
- allprojects {
233
- project.extra[" signing.keyId" ] = id
234
- project.extra[" signing.secretKeyRingFile" ] = file
235
- project.extra[" signing.password" ] = password
236
- }
237
-
238
- console.printf(" \n Thanks.\n\n " )
239
- }
255
+ sign(publishing.publications)
240
256
}
241
257
242
258
tasks {
243
259
val dokka by getting(DokkaTask ::class ) {
244
- outputDirectory = " docs/docs"
245
260
outputFormat = " html"
261
+ outputDirectory = " $buildDir /javadoc"
246
262
247
263
multiplatform {
248
264
val js by creating {
249
265
sourceLink {
250
266
path = " /src"
251
- url = " https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
267
+ url = " https://github.com/adamint/com.adamratzman. spotify-web-api-kotlin/tree/master/"
252
268
lineSuffix = " #L"
253
269
}
254
270
}
255
271
val jvm by creating {
256
272
sourceLink {
257
273
path = " /src"
258
- url = " https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
274
+ url = " https://github.com/adamint/com.adamratzman. spotify-web-api-kotlin/tree/master/"
259
275
lineSuffix = " #L"
260
276
}
261
277
}
262
278
263
279
register(" common" ) {
264
280
sourceLink {
265
281
path = " /src"
266
- url = " https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
282
+ url = " https://github.com/adamint/com.adamratzman. spotify-web-api-kotlin/tree/master/"
267
283
lineSuffix = " #L"
268
284
}
269
285
}
270
286
271
287
register(" global" ) {
272
288
sourceLink {
273
289
path = " /src"
274
- url = " https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
290
+ url = " https://github.com/adamint/com.adamratzman. spotify-web-api-kotlin/tree/master/"
275
291
lineSuffix = " #L"
276
292
}
277
293
@@ -285,15 +301,11 @@ tasks {
285
301
}
286
302
}
287
303
288
- val javadocJar by getting(Jar ::class ) {
289
- dependsOn.add(javadoc)
290
- archiveClassifier.set(" javadoc" )
291
- from(javadoc)
292
- }
293
-
294
- artifacts {
295
- archives(javadocJar)
296
- }
304
+ /* val javadocJar by getting(Jar::class) {
305
+ dependsOn.add(javadoc)
306
+ archiveClassifier.set("javadoc")
307
+ from(javadoc)
308
+ }*/
297
309
298
310
spotless {
299
311
kotlin {
@@ -318,4 +330,36 @@ tasks {
318
330
dependsOn.add(dokka)
319
331
dependsOn.add(" publishJvmPublicationToNexusRepository" )
320
332
}
333
+
334
+ }
335
+
336
+
337
+ fun MavenPublication.setupPom (publicationName : String ) {
338
+ artifact(dokkaJar.get())
339
+
340
+ pom {
341
+ name.set(publicationName)
342
+ description.set(" A Kotlin wrapper for the Spotify Web API." )
343
+ url.set(" https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin" )
344
+ inceptionYear.set(" 2018" )
345
+ scm {
346
+ url.set(" https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin" )
347
+ connection.set(" scm:https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin.git" )
348
+ developerConnection.set(" scm:git://github.com/adamint/com.adamratzman.spotify-web-api-kotlin.git" )
349
+ }
350
+ licenses {
351
+ license {
352
+ name.set(" The Apache Software License, Version 2.0" )
353
+ url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
354
+ distribution.set(" repo" )
355
+ }
356
+ }
357
+ developers {
358
+ developer {
359
+ id.set(" adamratzman" )
360
+ name.set(" Adam Ratzman" )
361
+
362
+ }
363
+ }
364
+ }
321
365
}
0 commit comments