Skip to content

Commit bbb5695

Browse files
authored
Migrate to Sonatype Central Portal (#138)
1 parent b1cdc87 commit bbb5695

File tree

7 files changed

+112
-218
lines changed

7 files changed

+112
-218
lines changed

.github/workflows/publish-new-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ jobs:
2828
bump: ${{ inputs.bump }}
2929
file-path: ./buildSrc/src/main/kotlin/io/getstream/feeds/android/Configuration.kt
3030
excluded-modules: "stream-feeds-android-sample"
31+
use-official-plugin: false
3132
secrets:
3233
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
3334
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
3435
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
3536
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
3637
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
37-
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
38-
STREAM_PUBLIC_BOT_TOKEN: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}
38+
STREAM_PUBLIC_BOT_TOKEN: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}

build.gradle.kts

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
2+
import com.vanniktech.maven.publish.MavenPublishBaseExtension
3+
import io.getstream.feeds.android.Configuration
14
import java.io.FileNotFoundException
25
import java.util.Calendar
36

4-
apply(plugin = "io.github.gradle-nexus.publish-plugin")
5-
apply(plugin = "org.jetbrains.dokka")
6-
77
apply(from = "${rootDir}/gradle/scripts/sonar.gradle")
88

99
// Top-level build file where you can add configuration options common to all sub-projects/modules.
@@ -18,8 +18,7 @@ plugins {
1818
alias(libs.plugins.arturbosch.detekt) apply true
1919
alias(libs.plugins.spotless) apply true
2020
id("com.google.gms.google-services") version "4.4.3" apply false
21-
alias(libs.plugins.dokka) apply false
22-
alias(libs.plugins.nexus) apply false
21+
alias(libs.plugins.maven.publish)
2322
alias(libs.plugins.sonarqube)
2423
alias(libs.plugins.kover)
2524
}
@@ -64,8 +63,10 @@ subprojects {
6463
// Update detekt.yml
6564

6665
if (detektFile.exists()) {
67-
val pattern = Regex("""licenseTemplateFile:\s*['"]\.\./license/generated/license-\d{4}\.txt['"]""")
68-
val replacement = """licenseTemplateFile: '../license/generated/license-$currentYear.txt'"""
66+
val pattern =
67+
Regex("""licenseTemplateFile:\s*['"]\.\./license/generated/license-\d{4}\.txt['"]""")
68+
val replacement =
69+
"""licenseTemplateFile: '../license/generated/license-$currentYear.txt'"""
6970
val detektContent = detektFile.readText().replace(pattern, replacement)
7071
detektFile.writeText(detektContent)
7172

@@ -80,4 +81,85 @@ subprojects {
8081
}
8182
}
8283

83-
apply(from = "${rootDir}/scripts/publish-root.gradle")
84+
private val isSnapshot = System.getenv("SNAPSHOT")?.toBoolean() == true
85+
version = if (isSnapshot) Configuration.snapshotVersionName else Configuration.versionName
86+
87+
88+
subprojects {
89+
plugins.withId("com.vanniktech.maven.publish") {
90+
extensions.configure<MavenPublishBaseExtension> {
91+
publishToMavenCentral(automaticRelease = true)
92+
93+
configure(
94+
AndroidSingleVariantLibrary(
95+
variant = "release",
96+
sourcesJar = true,
97+
publishJavadocJar = true,
98+
)
99+
)
100+
101+
pom {
102+
name.set("stream-feeds-android-client")
103+
description.set("Stream Feeds official Android SDK")
104+
url.set("https://github.com/getstream/stream-feeds-android")
105+
106+
licenses {
107+
license {
108+
name.set("Stream License")
109+
url.set("https://github.com/GetStream/stream-feeds-android/blob/main/LICENSE")
110+
}
111+
}
112+
113+
developers {
114+
developer {
115+
id = "aleksandar-apostolov"
116+
name = "Aleksandar Apostolov"
117+
118+
}
119+
developer {
120+
id = "VelikovPetar"
121+
name = "Petar Velikov"
122+
123+
}
124+
developer {
125+
id = "andremion"
126+
name = "André Mion"
127+
128+
}
129+
developer {
130+
id = "rahul-lohra"
131+
name = "Rahul Kumar Lohra"
132+
133+
}
134+
developer {
135+
id = "gpunto"
136+
name = "Gianmarco David"
137+
138+
}
139+
}
140+
141+
scm {
142+
connection.set("scm:git:github.com/getstream/stream-feeds-android.git")
143+
developerConnection.set("scm:git:ssh://github.com/getstream/stream-feeds-android.git")
144+
url.set("https://github.com/getstream/stream-feeds-android/tree/main")
145+
}
146+
}
147+
}
148+
}
149+
}
150+
151+
tasks.register("printAllArtifacts") {
152+
group = "publishing"
153+
description = "Prints all artifacts that will be published"
154+
155+
doLast {
156+
subprojects.forEach { subproject ->
157+
subproject.plugins.withId("com.vanniktech.maven.publish") {
158+
subproject.extensions.findByType(PublishingExtension::class.java)
159+
?.publications
160+
?.filterIsInstance<MavenPublication>()
161+
?.forEach { println("${it.groupId}:${it.artifactId}:${it.version}") }
162+
}
163+
}
164+
}
165+
}

gradle/libs.versions.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ sonarqube = "6.0.1.5171"
3838
spotless = "7.2.1"
3939
streamConventions = "0.1.1"
4040
turbine = "1.2.1"
41-
kotlinDokka = "1.9.20"
42-
nexusPlugin = "1.3.0"
41+
mavenPublish = "0.34.0"
4342

4443
[libraries]
4544
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -108,5 +107,4 @@ sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" }
108107
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
109108
stream-android-library = { id = "io.getstream.android.library", version.ref = "streamConventions" }
110109
stream-android-application = { id = "io.getstream.android.application", version.ref = "streamConventions" }
111-
dokka = { id = "org.jetbrains.dokka", version.ref = "kotlinDokka" }
112-
nexus = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPlugin" }
110+
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }

scripts/publish-module.gradle

Lines changed: 0 additions & 111 deletions
This file was deleted.

scripts/publish-root.gradle

Lines changed: 0 additions & 67 deletions
This file was deleted.

stream-feeds-android-client/build.gradle.kts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import io.getstream.feeds.android.Configuration
2-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
32
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
43

54
plugins {
@@ -9,16 +8,9 @@ plugins {
98
alias(libs.plugins.arturbosch.detekt)
109
alias(libs.plugins.sonarqube)
1110
alias(libs.plugins.kover)
11+
alias(libs.plugins.maven.publish)
1212
}
1313

14-
rootProject.extra.apply {
15-
set("PUBLISH_GROUP_ID", Configuration.artifactGroup)
16-
set("PUBLISH_ARTIFACT_ID", "stream-feeds-android-client")
17-
set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName"))
18-
}
19-
20-
apply(from = "$rootDir/scripts/publish-module.gradle")
21-
2214
android {
2315
namespace = "io.getstream.feeds.android.client"
2416
compileSdk = libs.versions.compileSdk.get().toInt()
@@ -49,10 +41,6 @@ android {
4941
consumerProguardFiles("consumer-rules.pro")
5042
}
5143
}
52-
53-
publishing {
54-
singleVariant("release") { }
55-
}
5644
}
5745

5846
tasks.withType<KotlinCompile>().configureEach {
@@ -98,3 +86,11 @@ dependencies {
9886
testImplementation(libs.mockk)
9987
testImplementation(libs.turbine)
10088
}
89+
90+
mavenPublishing {
91+
coordinates(
92+
groupId = Configuration.artifactGroup,
93+
artifactId = "stream-feeds-android-client",
94+
version = rootProject.version.toString()
95+
)
96+
}

0 commit comments

Comments
 (0)