-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi kmp module integration samples
which fails because Wire doesn't support adding resources to kmp modules
- Loading branch information
Showing
8 changed files
with
194 additions
and
13 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
samples/multi-platform-multi-module/dinosaurs-native/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...i-platform-multi-module/dinosaurs-native/src/main/proto/squareup/dinosaurs/dinosaur.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
35 changes: 35 additions & 0 deletions
35
samples/multi-platform-multi-module/geology-native/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...s/multi-platform-multi-module/geology-native/src/main/proto/squareup/geology/period.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
30
samples/multi-platform-multi-module/location-js/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../multi-platform-multi-module/location-js/src/main/proto/squareup/location/continent.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
16 changes: 16 additions & 0 deletions
16
...les/multi-platform-multi-module/location-js/src/main/proto/squareup/location/planet.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters