Skip to content

Commit 7b87a01

Browse files
committed
allow publishing of android target
1 parent 5605206 commit 7b87a01

File tree

1 file changed

+48
-86
lines changed

1 file changed

+48
-86
lines changed

build.gradle.kts

Lines changed: 48 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
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`
@@ -32,7 +31,7 @@ buildscript {
3231
}
3332

3433
group = "com.adamratzman"
35-
version = "3.1.03"
34+
version = "3.2.0"
3635

3736
/*java {
3837
withSourcesJar()
@@ -73,13 +72,36 @@ android {
7372
}
7473
}
7574

75+
val dokkaJar by tasks.registering(Jar::class) {
76+
group = JavaBasePlugin.DOCUMENTATION_GROUP
77+
description = "Docs"
78+
classifier = "javadoc"
79+
from(tasks.dokka)
80+
}
81+
7682
kotlin {
77-
android() {
83+
android {
84+
mavenPublication {
85+
artifactId = "spotify-api-kotlin-android"
86+
setupPom(artifactId)
87+
}
88+
89+
publishLibraryVariants("release")
90+
}
7891

92+
jvm {
93+
mavenPublication {
94+
artifactId = "spotify-api-kotlin"
95+
setupPom(artifactId)
96+
}
7997
}
8098

81-
jvm()
8299
js {
100+
mavenPublication {
101+
artifactId = "spotify-api-kotlin-js"
102+
setupPom(artifactId)
103+
}
104+
83105
browser {
84106
dceTask {
85107
keep("ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io")
@@ -201,101 +223,42 @@ kotlin {
201223

202224
publishing {
203225
publications {
204-
val js by getting(MavenPublication::class) {
205-
artifactId = "com.adamratzman.spotify-api-kotlin-js"
206-
setupPom("com.adamratzman.spotify-api-kotlin-js")
207-
}
208-
209226
val kotlinMultiplatform by getting(MavenPublication::class) {
210-
artifactId = "com.adamratzman.spotify-api-kotlin-core"
211-
setupPom("com.adamratzman.spotify-api-kotlin-core")
227+
artifactId = "spotify-api-kotlin-core"
228+
setupPom(artifactId)
212229
}
213230

214-
val jvm by getting(MavenPublication::class) {
215-
artifactId = "com.adamratzman.spotify-api-kotlin"
216-
// artifact(tasks.getByName("javadocJar"))
217-
versionMapping {
218-
usage("java-api") {
219-
fromResolutionOf("runtimeClasspath")
220-
}
221-
usage("java-runtime") {
222-
fromResolutionResult()
223-
}
224-
}
225-
226-
setupPom("com.adamratzman.spotify-api-kotlin")
231+
val metadata by getting(MavenPublication::class) {
232+
artifactId = "spotify-api-kotlin-metadata"
233+
setupPom(artifactId)
227234
}
228235
}
236+
229237
repositories {
230-
if (System.getenv("publishLocation") == "nexus") {
231-
maven {
232-
name = "nexus"
233-
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
234-
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
235-
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
236-
237-
credentials {
238-
val nexusUsername: String? by project.extra
239-
val nexusPassword: String? by project.extra
240-
username = nexusUsername
241-
password = nexusPassword
242-
}
243-
}
244-
} else {
245-
if (project.extra.has("spaceUser") && project.extra.has("spacePassword")) {
246-
maven {
247-
credentials {
248-
username = project.extra["spaceUser"]?.toString()
249-
password = project.extra["spacePassword"]?.toString()
250-
}
251-
252-
url = URI.create("https://maven.jetbrains.space/adam/ratzman")
253-
}
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
254249
}
255250
}
256251
}
257252
}
258253

259254
signing {
260-
if (System.getenv("publishLocation") == "nexus") {
261-
sign(publishing.publications)
262-
}
263-
}
264-
265-
// get signing confs interactively if needed
266-
gradle.taskGraph.whenReady {
267-
val alreadyConfigured = with(project.extra) {
268-
(has("signing.keyId") && has("signing.secretKeyRingFile") && has("signing.password"))
269-
|| (has("signing.notNeeded") && get("signing.notNeeded") == "true")
270-
}
271-
if (!alreadyConfigured && allTasks.any { it is Sign }) {
272-
// Use Java's console to read from the console (no good for
273-
// a CI environment)
274-
val console = System.console()
275-
requireNotNull(console) { "Could not get signing config: please provide yours in the gradle.properties file." }
276-
console.printf(
277-
"\n\nWe have to sign some things in this build." +
278-
"\n\nPlease enter your signing details.\n\n"
279-
)
280-
281-
val id = console.readLine("PGP Key Id: ")
282-
val file = console.readLine("PGP Secret Key Ring File (absolute path): ")
283-
val password = console.readPassword("PGP Private Key Password: ")
284-
285-
allprojects {
286-
project.extra["signing.keyId"] = id
287-
project.extra["signing.secretKeyRingFile"] = file
288-
project.extra["signing.password"] = password
289-
}
290-
291-
console.printf("\nThanks.\n\n")
292-
}
255+
sign(publishing.publications)
293256
}
294257

295258
tasks {
296259
val dokka by getting(DokkaTask::class) {
297-
outputDirectory = "docs/docs"
298260
outputFormat = "html"
261+
outputDirectory = "$buildDir/javadoc"
299262

300263
multiplatform {
301264
val js by creating {
@@ -344,10 +307,6 @@ tasks {
344307
from(javadoc)
345308
}*/
346309

347-
artifacts {
348-
// archives(javadocJar)
349-
}
350-
351310
spotless {
352311
kotlin {
353312
target("**/*.kt")
@@ -374,7 +333,10 @@ tasks {
374333

375334
}
376335

336+
377337
fun MavenPublication.setupPom(publicationName: String) {
338+
artifact(dokkaJar.get())
339+
378340
pom {
379341
name.set(publicationName)
380342
description.set("A Kotlin wrapper for the Spotify Web API.")

0 commit comments

Comments
 (0)