Skip to content

Commit

Permalink
Merge pull request #16 from collectiveidea/prep-for-rename-to-twirp-kmp
Browse files Browse the repository at this point in the history
Prep for rename from twirp-kmm to twirp-kmp
  • Loading branch information
darronschall authored Nov 22, 2024
2 parents 5b78c63 + fc1c632 commit 2fcbd8f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
java-version: 21

- name: Build (Generator)
run: ./gradlew twirp-kmm-generator:build
run: ./gradlew twirp-kmp-generator:build

- name: Test (Runtime)
run: ./gradlew twirp-kmm-runtime:testReleaseUnitTest
run: ./gradlew twirp-kmp-runtime:testReleaseUnitTest

- name: Archive Runtime Test Report
if: success() || failure() # Allow canceling per https://stackoverflow.com/a/73015952
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

* **BREAKING** Rename project from twirp-kmm to twirp-kmp. See [#16](https://github.com/collectiveidea/twirp-kmm/pull/16)
* Generator - Ensure generator .jar artifact is built for Java 8. See [#15](https://github.com/collectiveidea/twirp-kmm/pull/15).

## [0.4.0] - 2024-09-03
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

# PBandK Service Generator and Runtime for Twirp KMM

This project is a [service generator plugin](https://github.com/streem/pbandk#service-code-generation) for [PBandK](https://github.com/streem/pbandk) that generates Kotlin client integration for [Twirp](https://github.com/twitchtv/twirp) services. The generated client code leverages [PBandK](https://github.com/streem/pbandk) for protobuf messages, [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) for [JSON handling of Twirp service errors](https://twitchtv.github.io/twirp/docs/errors.html), and [Ktor](https://github.com/ktorio/ktor) for HTTP. All of these choices enable the generated client code to be leveraged in [Kotlin Multiplatform Mobile](https://kotlinlang.org/lp/mobile/) projects, sharing the network integration layer with both iOS and Android native apps.
This project is a [service generator plugin](https://github.com/streem/pbandk#service-code-generation) for [PBandK](https://github.com/streem/pbandk) that generates Kotlin client integration for [Twirp](https://github.com/twitchtv/twirp) services. The generated client code leverages [PBandK](https://github.com/streem/pbandk) for protobuf messages, [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) for [JSON handling of Twirp service errors](https://twitchtv.github.io/twirp/docs/errors.html), and [Ktor](https://github.com/ktorio/ktor) for HTTP. All of these choices enable the generated client code to be leveraged in [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatform.html) projects, sharing the network integration layer with compatible platform targets.

There are two parts to this project - the [generator](./generator) itself, and the supporting [runtime](./runtime) for leveraging the generated service code.

## Generator

In general, follow [PBandK Usage](https://github.com/streem/pbandk#usage) instructions, but supply the `twirp-kmm-generator` as the `kotlin_service_gen` option as described in [PBandK's Service Code Generation documentation](https://github.com/streem/pbandk#service-code-generation).
In general, follow [PBandK Usage](https://github.com/streem/pbandk#usage) instructions, but supply the `twirp-kmp-generator` as the `kotlin_service_gen` option as described in [PBandK's Service Code Generation documentation](https://github.com/streem/pbandk#service-code-generation).

### Usage

Expand All @@ -17,15 +17,15 @@ Download the latest release, currently `0.4.0`, and pass it to `protoc` via `pba
```bash
# Download the library to ~
cd ~/
curl -OL https://github.com/collectiveidea/twirp-kmm/releases/download/0.4.0/twirp-kmm-generator-0.4.0.jar
curl -OL https://github.com/collectiveidea/twirp-kmp/releases/download/0.4.0/twirp-kmp-generator-0.4.0.jar
```


Pass the jar and generator class name as the `kotlin_service_gen` option to `pbandk_out`:

```bash
cd ~/exampleProject
protoc --pbandk_out=kotlin_service_gen='~/twirp-kmm-generator-0.4.0.jar|com.collectiveidea.twirp.Generator',kotlin_package=com.example.api:src/main/kotlin src/main/proto/example.proto
protoc --pbandk_out=kotlin_service_gen='~/twirp-kmp-generator-0.4.0.jar|com.collectiveidea.twirp.Generator',kotlin_package=com.example.api:src/main/kotlin src/main/proto/example.proto
```

### Build
Expand All @@ -36,12 +36,12 @@ To build the library locally, run:
./gradlew build
```

This creates the versioned `.jar` file, e.g. `generator/build/libs/twirp-kmm-generator-0.4.0-SNAPSHOT.jar`
This creates the versioned `.jar` file, e.g. `generator/build/libs/twirp-kmp-generator-0.4.0-SNAPSHOT.jar`

Then, the built version can be used, instead of the latest release, by supplying the path to the built `.jar`, e.g.:

```bash
protoc --pbandk_out=kotlin_service_gen='/Users/darron/Development/twirp-kmm/generator/build/libs/twirp-kmm-generator-0.4.0-SNAPSHOT.jar|com.collectiveidea.twirp.Generator',kotlin_package=com.example.api:shared/src/commonMain/kotlin shared/src/commonMain/proto/example.proto
protoc --pbandk_out=kotlin_service_gen='/Users/darron/Development/twirp-kmp/generator/build/libs/twirp-kmp-generator-0.4.0-SNAPSHOT.jar|com.collectiveidea.twirp.Generator',kotlin_package=com.example.api:shared/src/commonMain/kotlin shared/src/commonMain/proto/example.proto
```

## Runtime
Expand All @@ -51,7 +51,7 @@ The runtime provides an [`installTwirp`](./runtime/src/commonMain/kotlin/com/col
First, add the runtime as a dependency:

```
implementation "com.collectiveidea.twirp:twirp-kmm-runtime:0.4.0"
implementation "com.collectiveidea.twirp:twirp-kmp-runtime:0.4.0"
```

Then, configure the HttpClient and pass the client into the generated service constructor:
Expand Down
6 changes: 3 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
```

8. Create GitHub Release
1. Visit the [New Releases](https://github.com/collectiveidea/twirp-kmm/releases/new) page.
1. Visit the [New Releases](https://github.com/collectiveidea/twirp-kmp/releases/new) page.
2. Supply release version and changelog
3. Upload `generator/build/libs/twirp-kmm-generator-X.Y.Z.jar` artifact.
3. Upload `generator/build/libs/twirp-kmp-generator-X.Y.Z.jar` artifact.

9. Publish (runtime)

```
$ ./gradlew publish
```

10. Visit [Sonatype Nexus](https://s01.oss.sonatype.org) and promote the artifact.
10. Visit [Sonatype Nexus](https://s01.oss.sonatype.org) and promote the artifact.
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/MavenPublicationExtensions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.api.publish.maven.MavenPublication

fun MavenPublication.configureTwirpKmmPOM(pomDescription: String) {
fun MavenPublication.configureTwirpKmpPOM(pomDescription: String) {
val pomName = artifactId

pom {
Expand All @@ -14,16 +14,16 @@ fun MavenPublication.configureTwirpKmmPOM(pomDescription: String) {
}
}

url.set("https://github.com/collectiveidea/twirp-kmm")
url.set("https://github.com/collectiveidea/twirp-kmp")

issueManagement {
system.set("Github")
url.set("https://github.com/collectiveidea/twirp-kmm/issues")
url.set("https://github.com/collectiveidea/twirp-kmp/issues")
}

scm {
connection.set("https://github.com/collectiveidea/twirp-kmm.git")
url.set("https://github.com/collectiveidea/twirp-kmm")
connection.set("https://github.com/collectiveidea/twirp-kmp.git")
url.set("https://github.com/collectiveidea/twirp-kmp")
}

developers {
Expand Down
2 changes: 1 addition & 1 deletion generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ publishing {
publications.withType<MavenPublication> {
artifact(javadocJar.get())

configureTwirpKmmPOM(project.description!!)
configureTwirpKmpPOM(project.description!!)
}
}
6 changes: 3 additions & 3 deletions runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ kotlin {
iosSimulatorArm64(),
).forEach {
it.binaries.framework {
baseName = "twirp-kmm-runtime"
baseName = "twirp-kmp-runtime"
}
}

Expand Down Expand Up @@ -89,7 +89,7 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}

namespace = "com.collectiveidea"
namespace = "com.collectiveidea.twirp"
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
Expand All @@ -104,7 +104,7 @@ publishing {
publications.withType<MavenPublication> {
artifact(javadocJar.get())

configureTwirpKmmPOM(project.description!!)
configureTwirpKmpPOM(project.description!!)
}
}

Expand Down
8 changes: 4 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pluginManagement {
}
}

rootProject.name = "twirp-kmm"
rootProject.name = "twirp-kmp"

include("generator")
project(":generator").name = "twirp-kmm-generator"
include(":generator")
project(":generator").name = "twirp-kmp-generator"

include(":runtime")
project(":runtime").name = "twirp-kmm-runtime"
project(":runtime").name = "twirp-kmp-runtime"

0 comments on commit 2fcbd8f

Please sign in to comment.