Skip to content

Commit cb0022d

Browse files
authored
Merge pull request #206 from adamint/dev
add android target
2 parents 5dcb937 + 232407a commit cb0022d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+910
-734
lines changed

README.md

Lines changed: 238 additions & 238 deletions
Large diffs are not rendered by default.

TESTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ each scope or use the following code snippet to print out the Spotify token stri
2323

2424
**How to generate an authorization URL**
2525
```kotlin
26-
import com.adamratzman.spotify.main.SpotifyScope
26+
import com.adamratzman.com.adamratzman.spotify.main.SpotifyScope
2727
val api = spotifyClientApi(
2828
"SPOTIFY_CLIENT_ID",
2929
"SPOTIFY_CLIENT_SECRET",

build.gradle.kts

Lines changed: 162 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,107 @@
11
import org.jetbrains.dokka.gradle.DokkaTask
22
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target
3-
import java.net.URI
43

54
plugins {
65
`maven-publish`
76
signing
8-
`java-library`
97
id("io.codearte.nexus-staging") version "0.21.2"
108
kotlin("multiplatform") version "1.3.72"
119
kotlin("plugin.serialization") version "1.3.72"
1210
id("com.diffplug.gradle.spotless") version "4.4.0"
1311
id("com.moowork.node") version "1.3.1"
1412
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+
}
1531
}
1632

1733
group = "com.adamratzman"
18-
version = "3.1.02"
34+
version = "3.2.0"
1935

20-
java {
36+
/*java {
2137
withSourcesJar()
2238
withJavadocJar()
2339
}
40+
*/
2441

2542
tasks.withType<Test> {
2643
this.testLogging {
2744
this.showStandardStreams = true
2845
}
2946
}
3047

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)
3580
}
3681

3782
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+
3999
js {
100+
mavenPublication {
101+
artifactId = "spotify-api-kotlin-js"
102+
setupPom(artifactId)
103+
}
104+
40105
browser {
41106
dceTask {
42107
keep("ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io")
@@ -88,7 +153,6 @@ kotlin {
88153
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
89154
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
90155
api("io.ktor:ktor-client-okhttp:$ktorVersion")
91-
api("commons-codec:commons-codec:1.14")
92156
implementation(kotlin("stdlib-jdk8"))
93157
}
94158
}
@@ -124,6 +188,32 @@ kotlin {
124188
}
125189
}
126190

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+
127217
all {
128218
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
129219
}
@@ -133,145 +223,71 @@ kotlin {
133223

134224
publishing {
135225
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+
}
147230

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-
email.set("[email protected]")
170-
}
171-
}
172-
}
231+
val metadata by getting(MavenPublication::class) {
232+
artifactId = "spotify-api-kotlin-metadata"
233+
setupPom(artifactId)
173234
}
174235
}
236+
175237
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
200249
}
201250
}
202251
}
203252
}
204253

205254
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\nWe have to sign some things in this build." +
225-
"\n\nPlease 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("\nThanks.\n\n")
239-
}
255+
sign(publishing.publications)
240256
}
241257

242258
tasks {
243259
val dokka by getting(DokkaTask::class) {
244-
outputDirectory = "docs/docs"
245260
outputFormat = "html"
261+
outputDirectory = "$buildDir/javadoc"
246262

247263
multiplatform {
248264
val js by creating {
249265
sourceLink {
250266
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/"
252268
lineSuffix = "#L"
253269
}
254270
}
255271
val jvm by creating {
256272
sourceLink {
257273
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/"
259275
lineSuffix = "#L"
260276
}
261277
}
262278

263279
register("common") {
264280
sourceLink {
265281
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/"
267283
lineSuffix = "#L"
268284
}
269285
}
270286

271287
register("global") {
272288
sourceLink {
273289
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/"
275291
lineSuffix = "#L"
276292
}
277293

@@ -285,15 +301,11 @@ tasks {
285301
}
286302
}
287303

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+
}*/
297309

298310
spotless {
299311
kotlin {
@@ -318,4 +330,36 @@ tasks {
318330
dependsOn.add(dokka)
319331
dependsOn.add("publishJvmPublicationToNexusRepository")
320332
}
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+
email.set("[email protected]")
362+
}
363+
}
364+
}
321365
}

gradle/wrapper/gradle-wrapper.jar

216 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)