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 Aug 29, 2023
1 parent 1db7e4d commit 5b54e90
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 13 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;
}
29 changes: 16 additions & 13 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,22 @@ includeBuild("build-logic") {
}
}

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: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(":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")
Expand Down

0 comments on commit 5b54e90

Please sign in to comment.