Skip to content

Commit

Permalink
Multi kmp module integration samples
Browse files Browse the repository at this point in the history
which fails because Wire doesn't support adding resources to kmp modules
  • Loading branch information
oldergod committed Jul 1, 2024
1 parent 10d2133 commit dc84267
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
kotlin("multiplatform")
id("com.squareup.wire")
}

kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}

nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
}
}
}
sourceSets {
val commonMain by getting
val nativeMain by getting
val nativeTest by getting
}
}

dependencies {
protoPath(project(":samples:multi-platform-multi-module:geology-native"))
}

wire {
sourcePath {
srcDir("src/main/proto")
}

sourcePath {
srcProject(":samples:multi-platform-multi-module:location-js")
include("squareup/location/continent.proto")
}

kotlin {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto2";

package squareup.dinosaurs;

option java_package = "com.squareup.dinosaurs";

import "squareup/geology/period.proto";
import "squareup/location/continent.proto";

message Dinosaur {
/** Common name of this dinosaur, like "Stegosaurus". */
optional string name = 1;

/** URLs with images of this dinosaur. */
repeated string picture_urls = 2;

optional double length_meters = 3;
optional double mass_kilograms = 4;
optional squareup.geology.Period period = 5;
optional squareup.location.Continent continent = 6;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
plugins {
kotlin("multiplatform")
id("com.squareup.wire")
}

kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}

nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
}
}
}
sourceSets {
val commonMain by getting
val nativeMain by getting
val nativeTest by getting
}
}

wire {
protoLibrary = true

kotlin {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto2";

package squareup.geology;

option java_package = "com.squareup.geology";

enum Period {
/** 145.5 million years ago — 66.0 million years ago. */
CRETACEOUS = 1;

/** 201.3 million years ago — 145.0 million years ago. */
JURASSIC = 2;

/** 252.17 million years ago — 201.3 million years ago. */
TRIASSIC = 3;
}
30 changes: 30 additions & 0 deletions samples/multi-platform-multi-module/location-js/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
kotlin("js")
id("com.squareup.wire")
}

repositories {
mavenCentral()
}

kotlin {
js(IR) {
binaries.executable()
browser {
commonWebpackConfig {
cssSupport {
enabled.set(true)
}
}
}
nodejs {
}
}
}

wire {
protoLibrary = true

kotlin {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto2";

package squareup.location;

option java_package = "com.squareup.location";

enum Continent {
AFRICA = 0;
AMERICA = 1;
ANTARCTICA = 2;
ASIA = 3;
AUSTRALIA = 4;
EUROPE = 5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto2";

package squareup.location;

option java_package = "com.squareup.location";

enum Planet {
MERCURY = 0;
VENUS = 1;
EARTH = 2;
MARS = 3;
JUPITER = 4;
SATURN = 5;
URANUS = 6;
NEPTUNE = 7;
}
36 changes: 22 additions & 14 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,25 @@ if (startParameter.projectProperties.get("swift") != "false") {
include(":wire-tests-swift:manifest:module_three")
include(":wire-tests-proto3-swift")
}
include(":samples:android-app-java-sample")
include(":samples:android-app-kotlin-sample")
include(":samples:android-app-kotlin-minsdk-sample")
include(":samples:android-app-variants-sample")
include(":samples:android-lib-java-sample")
include(":samples:android-lib-kotlin-sample")
include(":samples:js")
include(":samples:multi-target")
include(":samples:native")
include(":samples:simple-sample")
include(":samples:wire-codegen-sample")
include(":samples:wire-grpc-sample:client")
include(":samples:wire-grpc-sample:protos")
include(":samples:wire-grpc-sample:server")

// include(":samples:simple-sample")
// include(":samples:android-app-java-sample")
// include(":samples:android-app-kotlin-sample")
// include(":samples:android-app-variants-sample")
// include(":samples:android-lib-java-sample")
// include(":samples:android-lib-kotlin-sample")
// include(":samples:js")
include(":samples:multi-platform-multi-module:dinosaurs-native")
include(":samples:multi-platform-multi-module:geology-native")
include(":samples:multi-platform-multi-module:location-js")
// include(":samples:native")
// include(":samples:wire-codegen-sample")
// include(":samples:wire-grpc-sample:client")
// include(":samples:wire-grpc-sample:protos")
// include(":samples:wire-grpc-sample:server")
// include(":samples:wire-grpc-sample:server-plain")
include(":wire-benchmarks")
include(":wire-golden-files")
include(":wire-gradle-plugin-playground")
include(":wire-grpc-tests")
include(":wire-protoc-compatibility-tests")

0 comments on commit dc84267

Please sign in to comment.