Skip to content

Commit b81fe3d

Browse files
committed
Merge branch 'feature/central-portal'
2 parents 7672cdc + 249cdc4 commit b81fe3d

9 files changed

+62
-95
lines changed

.github/workflows/release-kotlin.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ jobs:
3737
uses: gradle/actions/setup-gradle@v3
3838
- name: Cache Konan
3939
uses: ./.github/actions/cache-konan
40-
- name: Publish to Sonatype
41-
run: ./gradlew publishAllPublicationsToSonatypeRepository
40+
- name: Publish to Maven Central
41+
run: ./gradlew publishToMavenCentral
4242
env:
43-
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
44-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
45-
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
46-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
47-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
43+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
44+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
45+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }}
46+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
47+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}

build.gradle.kts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
plugins {
2-
alias(libs.plugins.android.library) apply false
3-
alias(libs.plugins.kotlin.multiplatform) apply false
4-
}
5-
61
buildscript {
72
repositories {
83
gradlePluginPortal()

buildSrc/build.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ plugins {
22
`kotlin-dsl`
33
}
44

5-
repositories {
6-
gradlePluginPortal()
5+
dependencies {
6+
implementation(libs.kotlin.gradle.plugin)
7+
implementation(libs.android.library.gradle.plugin)
8+
implementation(libs.vanniktech.mavenPublish)
79
}

buildSrc/settings.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@file:Suppress("UnstableApiUsage")
2+
3+
dependencyResolutionManagement {
4+
repositories {
5+
mavenCentral()
6+
gradlePluginPortal()
7+
google()
8+
}
9+
versionCatalogs {
10+
create("libs") {
11+
from(files("../gradle/libs.versions.toml"))
12+
}
13+
}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id("com.android.library")
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
kotlin("multiplatform")
3+
}
Lines changed: 24 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,34 @@
1-
plugins {
2-
`maven-publish`
3-
signing
4-
}
5-
6-
ext["signing.keyId"] = null
7-
ext["signing.password"] = null
8-
ext["signing.secretKey"] = null
9-
ext["signing.secretKeyRingFile"] = null
10-
ext["ossrhUsername"] = null
11-
ext["ossrhPassword"] = null
12-
val localPropsFile = project.rootProject.file("local.properties")
13-
if (localPropsFile.exists()) {
14-
localPropsFile.reader()
15-
.use { java.util.Properties().apply { load(it) } }
16-
.onEach { (name, value) -> ext[name.toString()] = value }
17-
} else {
18-
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
19-
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
20-
ext["signing.secretKey"] = System.getenv("SIGNING_SECRET_KEY")
21-
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
22-
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
23-
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
24-
}
1+
@file:Suppress("UnstableApiUsage")
252

26-
fun getExtraString(name: String) = ext[name]?.toString()
3+
import com.vanniktech.maven.publish.SonatypeHost
274

28-
val signPublications = getExtraString("signing.keyId") != null
5+
plugins {
6+
id("com.vanniktech.maven.publish.base")
7+
}
298

30-
publishing {
31-
repositories {
32-
maven {
33-
name = "sonatype"
34-
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
35-
credentials {
36-
username = getExtraString("ossrhUsername")
37-
password = getExtraString("ossrhPassword")
9+
mavenPublishing {
10+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
11+
signAllPublications()
12+
configureBasedOnAppliedPlugins()
13+
pom {
14+
name = "KMP-ObservableViewModel"
15+
description = "Library to share Kotlin ViewModels with SwiftUI"
16+
url = "https://github.com/rickclephas/KMP-ObservableViewModel"
17+
licenses {
18+
license {
19+
name = "MIT"
20+
url = "https://opensource.org/licenses/MIT"
3821
}
3922
}
40-
}
41-
42-
publications.withType<MavenPublication> {
43-
artifact(tasks.register("${name}JavadocJar", Jar::class) {
44-
archiveClassifier.set("javadoc")
45-
archiveAppendix.set(this@withType.name)
46-
})
47-
if (signPublications) signing.sign(this)
48-
49-
pom {
50-
name.set("KMP-ObservableViewModel")
51-
description.set("Library to share Kotlin ViewModels with SwiftUI")
52-
url.set("https://github.com/rickclephas/KMP-ObservableViewModel")
53-
licenses {
54-
license {
55-
name.set("MIT")
56-
url.set("https://opensource.org/licenses/MIT")
57-
}
58-
}
59-
developers {
60-
developer {
61-
id.set("rickclephas")
62-
name.set("Rick Clephas")
63-
email.set("rclephas@gmail.com")
64-
}
65-
}
66-
scm {
67-
url.set("https://github.com/rickclephas/KMP-ObservableViewModel")
23+
developers {
24+
developer {
25+
id = "rickclephas"
26+
name = "Rick Clephas"
27+
email = "rclephas@gmail.com"
6828
}
6929
}
70-
}
71-
}
72-
73-
if (signPublications) {
74-
signing {
75-
getExtraString("signing.secretKey")?.let { secretKey ->
76-
useInMemoryPgpKeys(getExtraString("signing.keyId"), secretKey, getExtraString("signing.password"))
30+
scm {
31+
url = "https://github.com/rickclephas/KMP-ObservableViewModel"
7732
}
7833
}
7934
}

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ ksp = "2.1.21-2.0.1"
1212
nativecoroutines = "1.0.0-ALPHA-43"
1313

1414
[libraries]
15+
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
1516
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
1617
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
18+
android-library-gradle-plugin = { module = "com.android.library:com.android.library.gradle.plugin", version.ref = "android" }
1719
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version.ref = "androidx-lifecycle" }
20+
vanniktech-mavenPublish = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.32.0" }
1821

1922
# Sample libraries
2023
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose" }

kmp-observableviewmodel-core/build.gradle.kts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
22
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
33

44
plugins {
5-
alias(libs.plugins.android.library)
6-
alias(libs.plugins.kotlin.multiplatform)
7-
`kmp-observableviewmodel-publish`
5+
id("kmp-observableviewmodel-android-library")
6+
id("kmp-observableviewmodel-kotlin-multiplatform")
7+
id("kmp-observableviewmodel-publish")
88
alias(libs.plugins.atomicfu)
99
}
1010

@@ -53,9 +53,7 @@ kotlin {
5353
}
5454
}
5555
}
56-
androidTarget {
57-
publishLibraryVariants("release")
58-
}
56+
androidTarget()
5957
jvm()
6058
js {
6159
browser()
@@ -114,10 +112,4 @@ android {
114112
defaultConfig {
115113
minSdk = 19
116114
}
117-
publishing {
118-
singleVariant("release") {
119-
withSourcesJar()
120-
withJavadocJar()
121-
}
122-
}
123115
}

0 commit comments

Comments
 (0)