Skip to content

Commit 5605206

Browse files
committed
begin adding android target
1 parent 8b19f15 commit 5605206

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

+613
-412
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repositories {
1515
jcenter()
1616
}
1717
18-
compile group: 'com.adamratzman', name: 'spotify-api-kotlin', version: '3.1.0-rc.1'
18+
compile group: 'com.adamratzman', name: 'com.adamratzman.spotify-api-kotlin', version: '3.1.0-rc.1'
1919
```
2020

2121
To use the latest snapshot instead, you must add the Jitpack repository as well
@@ -28,15 +28,15 @@ repositories {
2828
Then, you can use the following:
2929
```
3030
dependencies {
31-
compile 'com.github.adamint:spotify-web-api-kotlin:dev-SNAPSHOT'
31+
compile 'com.github.adamint:com.adamratzman.spotify-web-api-kotlin:dev-SNAPSHOT'
3232
}
3333
```
3434

3535
### Maven
3636
```
3737
<dependency>
3838
<groupId>com.adamratzman</groupId>
39-
<artifactId>spotify-api-kotlin</artifactId>
39+
<artifactId>com.adamratzman.spotify-api-kotlin</artifactId>
4040
<version>SPOTIFY_API_VERSION</version>
4141
</dependency>
4242
```
@@ -53,7 +53,7 @@ JCenter Maven Repository:
5353
This library will work out of the box on Android.
5454

5555
## Documentation
56-
The `spotify-web-api-kotlin` JavaDocs are hosted at https://adamint.github.io/spotify-web-api-kotlin/docs/spotify-web-api-kotlin/
56+
The `com.adamratzman.spotify-web-api-kotlin` JavaDocs are hosted at https://adamint.github.io/com.adamratzman.spotify-web-api-kotlin/docs/com.adamratzman.spotify-web-api-kotlin/
5757

5858
## Samples
5959
Samples for all APIs are located in the `samples` directory
@@ -67,7 +67,7 @@ If you have a question, you can:
6767

6868
## Creating a new api instance
6969
To decide which api you need (SpotifyAppApi, SpotifyClientApi, SpotifyImplicitGrantApi), please refer to
70-
https://developer.spotify.com/documentation/general/guides/authorization-guide/. In general:
70+
https://developer.com.adamratzman.spotify.com/documentation/general/guides/authorization-guide/. In general:
7171
- If you don't need client resources, use SpotifyAppApi
7272
- If you're using the api in a backend application, use SpotifyClientApi
7373
- If you're using the api in a frontend application, use SpotifyImplicitGrantApi
@@ -217,7 +217,7 @@ println(api.browse.getFeaturedPlaylists().complete().message)
217217
// let's find out Bénabar's Spotify ID, find his top tracks, and print them out
218218

219219
val benabarId = api.search.searchArtist("Bénabar").complete()[0].id
220-
// this works; a redundant way would be: api.artists.getArtist("spotify:artist:6xoAWsIOZxJVPpo7Qvqaqv").complete().id
220+
// this works; a redundant way would be: api.artists.getArtist("com.adamratzman.spotify:artist:6xoAWsIOZxJVPpo7Qvqaqv").complete().id
221221

222222
println(api.artists.getArtistTopTracks(benabarId).complete().joinToString { it.name })
223223
```

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: 97 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,79 @@ import java.net.URI
55
plugins {
66
`maven-publish`
77
signing
8-
`java-library`
98
id("io.codearte.nexus-staging") version "0.21.2"
109
kotlin("multiplatform") version "1.3.72"
1110
kotlin("plugin.serialization") version "1.3.72"
1211
id("com.diffplug.gradle.spotless") version "4.4.0"
1312
id("com.moowork.node") version "1.3.1"
1413
id("org.jetbrains.dokka") version "0.10.1"
14+
id("com.android.library")
15+
id("kotlin-android-extensions")
16+
}
17+
18+
repositories {
19+
jcenter()
20+
google()
21+
maven("https://kotlin.bintray.com/kotlinx")
22+
}
23+
24+
buildscript {
25+
repositories {
26+
google()
27+
}
28+
dependencies {
29+
classpath("com.android.tools.build:gradle:3.5.4")
30+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
31+
}
1532
}
1633

1734
group = "com.adamratzman"
1835
version = "3.1.03"
1936

20-
java {
37+
/*java {
2138
withSourcesJar()
2239
withJavadocJar()
2340
}
41+
*/
2442

2543
tasks.withType<Test> {
2644
this.testLogging {
2745
this.showStandardStreams = true
2846
}
2947
}
3048

31-
repositories {
32-
mavenCentral()
33-
jcenter()
34-
maven("https://kotlin.bintray.com/kotlinx")
49+
android {
50+
compileSdkVersion(30)
51+
defaultConfig {
52+
minSdkVersion(15)
53+
targetSdkVersion(30)
54+
versionCode = 1
55+
versionName = "1.0"
56+
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
57+
}
58+
buildTypes {
59+
getByName("release") {
60+
isMinifyEnabled = false
61+
}
62+
}
63+
sourceSets {
64+
getByName("main") {
65+
manifest.srcFile("src/androidMain/AndroidManifest.xml")
66+
java.setSrcDirs(listOf("src/androidMain/kotlin"))
67+
res.setSrcDirs(listOf("src/androidMain/res"))
68+
}
69+
getByName("androidTest") {
70+
java.setSrcDirs(listOf("src/androidTest/kotlin"))
71+
res.setSrcDirs(listOf("src/androidTest/res"))
72+
}
73+
}
3574
}
3675

3776
kotlin {
77+
android() {
78+
79+
}
80+
3881
jvm()
3982
js {
4083
browser {
@@ -88,7 +131,6 @@ kotlin {
88131
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
89132
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
90133
api("io.ktor:ktor-client-okhttp:$ktorVersion")
91-
api("commons-codec:commons-codec:1.14")
92134
implementation(kotlin("stdlib-jdk8"))
93135
}
94136
}
@@ -124,6 +166,32 @@ kotlin {
124166
}
125167
}
126168

169+
val androidMain by getting {
170+
repositories {
171+
mavenCentral()
172+
jcenter()
173+
}
174+
175+
dependencies {
176+
api("net.sourceforge.streamsupport:android-retrofuture:1.7.2")
177+
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
178+
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
179+
api("io.ktor:ktor-client-okhttp:$ktorVersion")
180+
implementation(kotlin("stdlib-jdk8"))
181+
}
182+
}
183+
184+
val androidTest by getting {
185+
dependencies {
186+
implementation(kotlin("test"))
187+
implementation(kotlin("test-junit"))
188+
implementation("org.junit.jupiter:junit-jupiter:5.6.2")
189+
implementation("org.spekframework.spek2:spek-dsl-jvm:$spekVersion")
190+
runtimeOnly("org.spekframework.spek2:spek-runner-junit5:$spekVersion")
191+
runtimeOnly(kotlin("reflect"))
192+
}
193+
}
194+
127195
all {
128196
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
129197
}
@@ -134,18 +202,18 @@ kotlin {
134202
publishing {
135203
publications {
136204
val js by getting(MavenPublication::class) {
137-
artifactId = "spotify-api-kotlin-js"
138-
setupPom("spotify-api-kotlin-js")
205+
artifactId = "com.adamratzman.spotify-api-kotlin-js"
206+
setupPom("com.adamratzman.spotify-api-kotlin-js")
139207
}
140208

141209
val kotlinMultiplatform by getting(MavenPublication::class) {
142-
artifactId = "spotify-api-kotlin-core"
143-
setupPom("spotify-api-kotlin-core")
210+
artifactId = "com.adamratzman.spotify-api-kotlin-core"
211+
setupPom("com.adamratzman.spotify-api-kotlin-core")
144212
}
145213

146214
val jvm by getting(MavenPublication::class) {
147-
artifactId = "spotify-api-kotlin"
148-
artifact(tasks.getByName("javadocJar"))
215+
artifactId = "com.adamratzman.spotify-api-kotlin"
216+
// artifact(tasks.getByName("javadocJar"))
149217
versionMapping {
150218
usage("java-api") {
151219
fromResolutionOf("runtimeClasspath")
@@ -155,7 +223,7 @@ publishing {
155223
}
156224
}
157225

158-
setupPom("spotify-api-kotlin")
226+
setupPom("com.adamratzman.spotify-api-kotlin")
159227
}
160228
}
161229
repositories {
@@ -233,30 +301,30 @@ tasks {
233301
val js by creating {
234302
sourceLink {
235303
path = "/src"
236-
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
304+
url = "https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin/tree/master/"
237305
lineSuffix = "#L"
238306
}
239307
}
240308
val jvm by creating {
241309
sourceLink {
242310
path = "/src"
243-
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
311+
url = "https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin/tree/master/"
244312
lineSuffix = "#L"
245313
}
246314
}
247315

248316
register("common") {
249317
sourceLink {
250318
path = "/src"
251-
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
319+
url = "https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin/tree/master/"
252320
lineSuffix = "#L"
253321
}
254322
}
255323

256324
register("global") {
257325
sourceLink {
258326
path = "/src"
259-
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
327+
url = "https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin/tree/master/"
260328
lineSuffix = "#L"
261329
}
262330

@@ -270,14 +338,14 @@ tasks {
270338
}
271339
}
272340

273-
val javadocJar by getting(Jar::class) {
274-
dependsOn.add(javadoc)
275-
archiveClassifier.set("javadoc")
276-
from(javadoc)
277-
}
341+
/* val javadocJar by getting(Jar::class) {
342+
dependsOn.add(javadoc)
343+
archiveClassifier.set("javadoc")
344+
from(javadoc)
345+
}*/
278346

279347
artifacts {
280-
archives(javadocJar)
348+
// archives(javadocJar)
281349
}
282350

283351
spotless {
@@ -303,18 +371,19 @@ tasks {
303371
dependsOn.add(dokka)
304372
dependsOn.add("publishJvmPublicationToNexusRepository")
305373
}
374+
306375
}
307376

308377
fun MavenPublication.setupPom(publicationName: String) {
309378
pom {
310379
name.set(publicationName)
311380
description.set("A Kotlin wrapper for the Spotify Web API.")
312-
url.set("https://github.com/adamint/spotify-web-api-kotlin")
381+
url.set("https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin")
313382
inceptionYear.set("2018")
314383
scm {
315-
url.set("https://github.com/adamint/spotify-web-api-kotlin")
316-
connection.set("scm:https://github.com/adamint/spotify-web-api-kotlin.git")
317-
developerConnection.set("scm:git://github.com/adamint/spotify-web-api-kotlin.git")
384+
url.set("https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin")
385+
connection.set("scm:https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin.git")
386+
developerConnection.set("scm:git://github.com/adamint/com.adamratzman.spotify-web-api-kotlin.git")
318387
}
319388
licenses {
320389
license {

gradle/wrapper/gradle-wrapper.jar

216 Bytes
Binary file not shown.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri May 08 04:56:22 EDT 2020
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
31
distributionBase=GRADLE_USER_HOME
42
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
64
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

gradlew

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ esac
8282

8383
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
8484

85+
8586
# Determine the Java command to use to start the JVM.
8687
if [ -n "$JAVA_HOME" ] ; then
8788
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -129,6 +130,7 @@ fi
129130
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130131
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131132
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133+
132134
JAVACMD=`cygpath --unix "$JAVACMD"`
133135

134136
# We build the pattern for arguments to be converted via cygpath

gradlew.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*
8484

8585
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
8686

87+
8788
@rem Execute Gradle
8889
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
8990

samples/jvm/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
}
1212

1313
dependencies {
14-
compile 'com.github.adamint.spotify-web-api-kotlin:spotify-api-kotlin:dev-SNAPSHOT'
14+
compile 'com.github.adamint.com.adamratzman.spotify-web-api-kotlin:com.adamratzman.spotify-api-kotlin:dev-SNAPSHOT'
1515
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
1616
}
1717

samples/jvm/src/main/kotlin/appApi/AlbumApiSample.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ fun main() {
1111
).build()
1212

1313
// get album "Kids in Love" by the Mowgli's release date
14-
println(api.albums.getAlbum("spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s").complete()!!.releaseDate)
14+
println(api.albums.getAlbum("com.adamratzman.spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s").complete()!!.releaseDate)
1515

1616
// get album "Kids in Love" and a non-existant album
17-
println(api.albums.getAlbums("spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s", "nonexistantalbum"))
17+
println(api.albums.getAlbums("com.adamratzman.spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s", "nonexistantalbum"))
1818

1919
// get album "Kids in Love"'s tracks
20-
println(api.albums.getAlbumTracks("spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s").complete().filterNotNull().map { it.name })
20+
println(api.albums.getAlbumTracks("com.adamratzman.spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s").complete().filterNotNull().map { it.name })
2121
}

samples/jvm/src/main/kotlin/appApi/ArtistApiSample.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ fun main() {
1111
).build()
1212

1313
// get artist Cody G's total follower count
14-
println(api.artists.getArtist("spotify:artist:26HkLAAIMh5qOFet57d1rg").complete()!!.followers.total)
14+
println(api.artists.getArtist("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg").complete()!!.followers.total)
1515

1616
// get artist Cody G and a non-existant artist
17-
println(api.artists.getArtists("spotify:artist:26HkLAAIMh5qOFet57d1rg", "nonexistantartist"))
17+
println(api.artists.getArtists("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg", "nonexistantartist"))
1818

1919
// get all of artist Cody G's albums
20-
println(api.artists.getArtistAlbums("spotify:artist:26HkLAAIMh5qOFet57d1rg").getAllItems().complete().filterNotNull().map { it.name })
20+
println(api.artists.getArtistAlbums("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg").getAllItems().complete().filterNotNull().map { it.name })
2121

2222
// get Cody G's top tracks, in descending order, in France
23-
println(api.artists.getArtistTopTracks("spotify:artist:26HkLAAIMh5qOFet57d1rg").complete().map { it.name })
23+
println(api.artists.getArtistTopTracks("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg").complete().map { it.name })
2424

2525
// get Cody G's related artists
26-
println(api.artists.getRelatedArtists("spotify:artist:26HkLAAIMh5qOFet57d1rg").complete().map { it.name })
26+
println(api.artists.getRelatedArtists("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg").complete().map { it.name })
2727
}

0 commit comments

Comments
 (0)