Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KMP multi-module integration test #2593

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions samples/android-multi-module/dinosaurs/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("com.squareup.wire")
}

buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath(libs.pluginz.android)
classpath("com.squareup.wire:wire-gradle-plugin")
}
}

android {
namespace = "com.squareup.wire.android.app.multi.dinosaurs"
}

dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraintLayout)
implementation(libs.androidMaterial)
testImplementation(libs.junit)
}

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

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

kotlin {
out = "src/main/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;
}
34 changes: 34 additions & 0 deletions samples/android-multi-module/geology/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("com.squareup.wire")
}

buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath(libs.pluginz.android)
classpath("com.squareup.wire:wire-gradle-plugin")
}
}

android {
namespace = "com.squareup.wire.android.app.multi.geology"
}

dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraintLayout)
implementation(libs.androidMaterial)
testImplementation(libs.junit)
}

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;
}
55 changes: 55 additions & 0 deletions samples/android-multi-module/location/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("com.squareup.wire")
id("maven-publish")
}

buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath(libs.pluginz.android)
classpath("com.squareup.wire:wire-gradle-plugin")
}
}

android {
namespace = "com.squareup.wire.android.app.multi.location"

publishing {
singleVariant("debug") {
withSourcesJar()
}
}
}

publishing {
publications {
create("debug", MavenPublication::class.java) {
groupId = "com.my-company"
artifactId = "my-library"
version = "1.0"

afterEvaluate {
from(components.getByName("debug"))
}
}
}
}

dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraintLayout)
implementation(libs.androidMaterial)
testImplementation(libs.junit)
}

wire {
protoLibrary = true

kotlin {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2024 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package london

fun main() {
println("hello")
}
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;
}
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;
}
Loading
Loading