Skip to content

Commit 2c70910

Browse files
committed
Publish using KMP
1 parent 03be52c commit 2c70910

48 files changed

Lines changed: 176 additions & 182 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish NvpLib
2+
on:
3+
push:
4+
tags:
5+
- 'nvplib-*'
6+
jobs:
7+
publish:
8+
name: Release build and publish
9+
runs-on: macOS-latest
10+
steps:
11+
- name: Check out code
12+
uses: actions/checkout@v4
13+
- name: Set up JDK 21
14+
uses: actions/setup-java@v4
15+
with:
16+
distribution: 'zulu'
17+
java-version: 21
18+
- name: Publish to MavenCentral
19+
run: ./gradlew nvplib:core:publishToMavenCentral nvplib:nfc:publishToMavenCentral --no-configuration-cache
20+
env:
21+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
22+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
23+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
24+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
25+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}

build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ sonar {
4343
property("sonar.organization", "lcacheux")
4444
}
4545
}
46+
47+
val nvplibVersion: String? by extra {
48+
providers.exec {
49+
commandLine("git", "describe", "--tags", "--match", "nvplib-*")
50+
}.standardOutput.asText.get().trim().removePrefix("nvplib-")
51+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ kotlin.code.style=official
2121
# resources declared in the library itself and none from the library's dependencies,
2222
# thereby reducing the size of the R class for that library
2323
android.nonTransitiveRClass=true
24+
ksp.useKSP2=false

gradle/libs.versions.toml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
[versions]
22
java = "21"
3+
nvplibJava = "8"
34
android-minSdk = "24"
45
android-compileSdk = "36"
56
agp = "8.13.2"
6-
compose-plugin="1.9.0"
7-
hilt = "2.57.1"
8-
kotlin = "2.1.21"
7+
compose-plugin="1.9.3"
8+
hilt = "2.57.2"
9+
kotlin = "2.2.20"
910
coroutines = "1.10.2"
10-
room = "2.8.2"
11-
sqlite = "2.6.1"
12-
androidx-datastore = "1.1.7"
13-
bytonio = "0.0.1"
11+
room = "2.8.4"
12+
sqlite = "2.6.2"
13+
androidx-datastore = "1.2.0"
14+
bytonio = "0.0.3"
1415

1516
[plugins]
16-
ksp = { id = "com.google.devtools.ksp", version = "2.1.21-2.0.1" }
17+
ksp = { id = "com.google.devtools.ksp", version = "2.2.20-2.0.4" }
1718
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
1819
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
1920
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
@@ -23,20 +24,21 @@ hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
2324
room = { id = "androidx.room", version.ref = "room" }
2425
jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
2526
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
26-
dokka = { id = "org.jetbrains.dokka", version = "2.0.0" }
27+
dokka = { id = "org.jetbrains.dokka", version = "2.1.0" }
2728
sonarqube = { id = "org.sonarqube", version = "6.3.1.5724" }
29+
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.35.0" }
2830

2931
[libraries]
30-
colorpicker-compose = { module = "com.github.skydoves:colorpicker-compose", version = "1.1.2" }
32+
colorpicker-compose = { module = "com.github.skydoves:colorpicker-compose", version = "1.1.3" }
3133
filekit-compose = { module = "io.github.vinceglb:filekit-compose", version = "0.8.8" }
3234
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
3335
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
3436
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }
3537
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
36-
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.11.0" }
38+
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.12.1" }
3739
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version = "androidx-datastore" }
3840
androidx-datastore-core = { module = "androidx.datastore:datastore-core", version.ref = "androidx-datastore" }
39-
androidx-lifecycle-viewmodel-compose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version = "2.9.3" }
41+
androidx-lifecycle-viewmodel-compose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version = "2.9.6" }
4042

4143
# Room
4244
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
@@ -60,4 +62,4 @@ androidx-test-runner = { group = "androidx.test", name = "runner", version="1.7.
6062
mockito-android = { group = "org.mockito", name = "mockito-android", version = "5.20.0" }
6163
mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version = "6.1.0" }
6264
turbine = { group = "app.cash.turbine", name = "turbine", version = "1.2.1" }
63-
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version = "1.9.3" }
65+
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version = "1.10.0" }

nvplib/core/build.gradle.kts

Lines changed: 78 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,57 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
2+
13
plugins {
2-
id("java-library")
3-
id("maven-publish")
4-
alias(libs.plugins.kotlin.jvm)
4+
alias(libs.plugins.kotlin.multiplatform)
55
alias(libs.plugins.dokka)
66
alias(libs.plugins.ksp)
7-
signing
7+
alias(libs.plugins.mavenPublish)
88
}
99

10+
val nvplibVersion: String? by project
11+
group = "net.cacheux.nvplib"
12+
version = nvplibVersion ?: "unknown"
13+
1014
kotlin {
11-
jvmToolchain(libs.versions.java.get().toInt())
12-
}
15+
jvmToolchain(libs.versions.nvplibJava.get().toInt())
16+
17+
jvm()
18+
19+
val xcfName = "bytonioKit"
20+
21+
iosX64 {
22+
binaries.framework {
23+
baseName = xcfName
24+
}
25+
}
1326

14-
java {
15-
withSourcesJar()
27+
iosArm64 {
28+
binaries.framework {
29+
baseName = xcfName
30+
}
31+
}
32+
33+
iosSimulatorArm64 {
34+
binaries.framework {
35+
baseName = xcfName
36+
}
37+
}
38+
39+
sourceSets {
40+
commonMain {
41+
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
42+
dependencies {
43+
api(libs.bytonio.core)
44+
}
45+
}
46+
47+
jvmTest {
48+
dependencies {
49+
implementation(libs.junit)
50+
implementation(project(":nvplib:testing"))
51+
implementation(project(":utils"))
52+
}
53+
}
54+
}
1655
}
1756

1857
ksp {
@@ -21,79 +60,47 @@ ksp {
2160
}
2261

2362
dependencies {
24-
api(libs.bytonio.core)
25-
ksp(libs.bytonio.processor)
26-
27-
testImplementation(libs.junit)
28-
testImplementation(project(":nvplib:testing"))
29-
testImplementation(project(":utils"))
63+
add("kspCommonMainMetadata", libs.bytonio.processor)
3064
}
3165

32-
tasks.register<Jar>("dokkaHtmlJar") {
33-
dependsOn(tasks.dokkaHtml)
34-
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
35-
archiveClassifier.set("html-docs")
36-
}
66+
mavenPublishing {
67+
publishToMavenCentral()
3768

38-
tasks.register<Jar>("dokkaJavadocJar") {
39-
dependsOn(tasks.dokkaJavadoc)
40-
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
41-
archiveClassifier.set("javadoc")
42-
}
69+
signAllPublications()
4370

44-
publishing {
45-
repositories {
46-
maven {
47-
url = uri(layout.buildDirectory.dir("release"))
48-
}
49-
}
71+
coordinates(group.toString(), "nvplib-core", version.toString())
5072

51-
publications {
52-
create<MavenPublication>("mavenCore") {
53-
groupId = "net.cacheux.nvplib"
54-
artifactId = "nvplib-core"
55-
version = "0.1.2"
56-
afterEvaluate {
57-
from(components["java"])
58-
artifact(tasks["dokkaHtmlJar"])
59-
artifact(tasks["dokkaJavadocJar"])
73+
pom {
74+
name = "NVP Lib Core"
75+
description = "Core library to read data from Novopen insulin pens"
76+
url = "https://github.com/lcacheux/nov-open-reader"
77+
licenses {
78+
license {
79+
name = "The Apache License, Version 2.0"
80+
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
6081
}
61-
62-
pom {
63-
name = "NVP Lib Core"
64-
description = "Core library to read data from Novopen insulin pens"
65-
url = "https://github.com/lcacheux/nov-open-reader"
66-
licenses {
67-
license {
68-
name = "The Apache License, Version 2.0"
69-
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
70-
}
71-
}
72-
developers {
73-
developer {
74-
id = "lcacheux"
75-
name = "Leo Cacheux"
76-
email = "leo@cacheux.net"
77-
}
78-
}
79-
scm {
80-
connection = "scm:git:https://github.com/lcacheux/nov-open-reader.git"
81-
developerConnection = "scm:git:ssh://github.com/lcacheux/nov-open-reader.git"
82-
url = "https://github.com/lcacheux/nov-open-reader"
83-
}
82+
}
83+
developers {
84+
developer {
85+
id = "lcacheux"
86+
name = "Leo Cacheux"
87+
email = "leo@cacheux.net"
8488
}
8589
}
90+
scm {
91+
connection = "scm:git:https://github.com/lcacheux/nov-open-reader.git"
92+
developerConnection = "scm:git:ssh://github.com/lcacheux/nov-open-reader.git"
93+
url = "https://github.com/lcacheux/nov-open-reader"
94+
}
8695
}
8796
}
8897

89-
val signingIfAvailable: (Publication) -> Unit by project
90-
signingIfAvailable(publishing.publications.getByName("mavenCore"))
91-
92-
tasks.create<Zip>("bundleZip") {
93-
dependsOn("publish")
94-
from(layout.buildDirectory.dir("release").get()) {
95-
exclude("**/*.asc.*")
98+
afterEvaluate {
99+
tasks.withType(KotlinCompilationTask::class).configureEach {
100+
if (name != "kspCommonMainKotlinMetadata") {
101+
dependsOn("kspCommonMainKotlinMetadata")
102+
}
96103
}
97-
archiveFileName = "nvplib-core.zip"
98-
destinationDirectory = layout.buildDirectory.dir("bundle").get()
104+
tasks.findByName("sourcesJar")?.dependsOn("kspCommonMainKotlinMetadata")
99105
}
106+
File renamed without changes.

nvplib/core/src/main/kotlin/net/cacheux/nvplib/DataReader.kt renamed to nvplib/core/src/commonMain/kotlin/net/cacheux/nvplib/DataReader.kt

File renamed without changes.

nvplib/core/src/main/kotlin/net/cacheux/nvplib/NvpController.kt renamed to nvplib/core/src/commonMain/kotlin/net/cacheux/nvplib/NvpController.kt

File renamed without changes.

nvplib/core/src/main/kotlin/net/cacheux/nvplib/PayloadFunctions.kt renamed to nvplib/core/src/commonMain/kotlin/net/cacheux/nvplib/PayloadFunctions.kt

File renamed without changes.

nvplib/core/src/main/kotlin/net/cacheux/nvplib/PhdManager.kt renamed to nvplib/core/src/commonMain/kotlin/net/cacheux/nvplib/PhdManager.kt

File renamed without changes.

0 commit comments

Comments
 (0)