Skip to content

Commit

Permalink
WireSchemaTests as MPP module
Browse files Browse the repository at this point in the history
  • Loading branch information
oldergod committed Jul 7, 2023
1 parent 5b80838 commit 963206a
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 20 deletions.
1 change: 1 addition & 0 deletions wire-bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies {
api(projects.wireSchema)
api(projects.wireSchema.group + ":wire-schema-jvm:" + projects.wireSchema.version)
api(projects.wireSchemaTests)
api(projects.wireSchemaTests.group + ":wire-schema-jvm:" + projects.wireSchemaTests.version)
api(projects.wireSwiftGenerator)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.squareup.wire.kotlin.grpcserver

import com.squareup.kotlinpoet.FileSpec
import com.squareup.wire.WireCompiler
import java.io.File
import okio.buffer
import okio.source
Expand All @@ -25,7 +24,7 @@ import org.assertj.core.api.Assertions
object GoldenTestUtils {
fun assertFileEquals(expectedFileName: String, spec: FileSpec) {
val finalSpec = spec.toBuilder()
.addFileComment(WireCompiler.CODE_GENERATED_BY_WIRE)
.addFileComment("Code generated by Wire protocol buffer compiler, do not edit.")
.build()

val expected = File("src/test/golden/$expectedFileName").source().buffer().readUtf8()
Expand Down
1 change: 0 additions & 1 deletion wire-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import com.vanniktech.maven.publish.JavadocJar.Dokka
import com.vanniktech.maven.publish.KotlinMultiplatform
import com.vanniktech.maven.publish.MavenPublishBaseExtension

// apply(plugin = "org.jetbrains.kotlin.multiplatform")
plugins {
kotlin("multiplatform")
id("com.github.gmazzo.buildconfig")
Expand Down
122 changes: 106 additions & 16 deletions wire-schema-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import com.vanniktech.maven.publish.JavadocJar.Dokka
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension

// TODO(Benoit) this module can be multiplatform.

plugins {
kotlin("jvm")
kotlin("multiplatform")
id("org.jetbrains.dokka")
id("com.vanniktech.maven.publish.base").apply(false)
}
Expand All @@ -15,20 +13,112 @@ if (project.rootProject.name == "wire") {
apply(plugin = "binary-compatibility-validator")
}

dependencies {
api(libs.junit)
api(projects.wireCompiler)
api(projects.wireSchema)
implementation(projects.wireKotlinGenerator)
implementation(projects.wireJavaGenerator)
implementation(projects.wireSwiftGenerator)
implementation(libs.okio.core)
implementation(libs.okio.fakefilesystem)
testImplementation(libs.assertj)
testImplementation(libs.kotlin.test.junit)
testImplementation(projects.wireTestUtils)
}
kotlin {
jvm {
withJava()
}
if (System.getProperty("kjs", "true").toBoolean()) {
js(IR) {
configure(listOf(compilations.getByName("main"), compilations.getByName("test"))) {
tasks.getByName(compileKotlinTaskName) {
kotlinOptions {
moduleKind = "umd"
sourceMap = true
metaInfo = true
}
}
}
nodejs()
browser()
}
}
if (System.getProperty("knative", "true").toBoolean()) {
iosX64()
iosArm64()
iosSimulatorArm64()
// Required to generate tests tasks: https://youtrack.jetbrains.com/issue/KT-26547
linuxX64()
macosX64()
macosArm64()
mingwX64()
tvosX64()
tvosArm64()
tvosSimulatorArm64()
}
sourceSets {
val commonMain by getting {
dependencies {
api(libs.okio.core)
api(projects.wireSchema)
implementation(libs.okio.fakefilesystem)
}
}
val commonTest by getting {
dependencies {
implementation(libs.kotlin.test.common)
implementation(libs.kotlin.test.annotations)
}
}
val jvmTest by getting {
dependencies {
implementation(libs.assertj)
implementation(libs.kotlin.test.junit)
implementation(projects.wireTestUtils)
}
}
if (System.getProperty("kjs", "true").toBoolean()) {
val jsTest by getting {
dependencies {
implementation(libs.kotlin.test.js)
}
}
}
if (System.getProperty("knative", "true").toBoolean()) {
val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by creating {
dependsOn(commonTest)
}
val darwinMain by creating {
dependsOn(commonMain)
}

val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val linuxX64Main by getting
val macosX64Main by getting
val macosArm64Main by getting
val mingwX64Main by getting
val tvosX64Main by getting
val tvosArm64Main by getting
val tvosSimulatorArm64Main by getting
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val linuxX64Test by getting
val macosX64Test by getting
val macosArm64Test by getting
val mingwX64Test by getting
val tvosX64Test by getting
val tvosArm64Test by getting
val tvosSimulatorArm64Test by getting

for (it in listOf(iosX64Main, iosArm64Main, iosSimulatorArm64Main, linuxX64Main, macosX64Main, macosArm64Main, mingwX64Main, tvosX64Main, tvosArm64Main, tvosSimulatorArm64Main)) {
it.dependsOn(nativeMain)
}

for (it in listOf(iosX64Test, iosArm64Test, iosSimulatorArm64Test, linuxX64Test, macosX64Test, macosArm64Test, mingwX64Test, tvosX64Test, tvosArm64Test, tvosSimulatorArm64Test)) {
it.dependsOn(nativeTest)
}

for (it in listOf(iosX64Main, iosArm64Main, macosX64Main, macosArm64Main, tvosX64Main, tvosArm64Main)) {
it.dependsOn(darwinMain)
}
}
}
}

if (project.rootProject.name == "wire") {
configure<MavenPublishBaseExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.squareup.wire.schema.Location
import com.squareup.wire.schema.SchemaException
import okio.Path.Companion.toPath
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import kotlin.test.Test
import kotlin.test.assertFailsWith

class SchemaBuilderTest {
Expand Down
59 changes: 59 additions & 0 deletions wire-schema/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,28 @@ kotlin {
browser()
}
}
if (System.getProperty("knative", "true").toBoolean()) {
iosX64()
iosArm64()
iosSimulatorArm64()
// Required to generate tests tasks: https://youtrack.jetbrains.com/issue/KT-26547
linuxX64()
macosX64()
macosArm64()
mingwX64()
tvosX64()
tvosArm64()
tvosSimulatorArm64()
}

sourceSets {
val commonMain by getting {
dependencies {
api(projects.wireRuntime)
}
}
val commonTest by getting {
}
val jvmMain by getting {
dependencies {
api(libs.okio.core)
Expand Down Expand Up @@ -66,6 +81,50 @@ kotlin {
}
}
}
if (System.getProperty("knative", "true").toBoolean()) {
val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by creating {
dependsOn(commonTest)
}
val darwinMain by creating {
dependsOn(commonMain)
}

val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val linuxX64Main by getting
val macosX64Main by getting
val macosArm64Main by getting
val mingwX64Main by getting
val tvosX64Main by getting
val tvosArm64Main by getting
val tvosSimulatorArm64Main by getting
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val linuxX64Test by getting
val macosX64Test by getting
val macosArm64Test by getting
val mingwX64Test by getting
val tvosX64Test by getting
val tvosArm64Test by getting
val tvosSimulatorArm64Test by getting

for (it in listOf(iosX64Main, iosArm64Main, iosSimulatorArm64Main, linuxX64Main, macosX64Main, macosArm64Main, mingwX64Main, tvosX64Main, tvosArm64Main, tvosSimulatorArm64Main)) {
it.dependsOn(nativeMain)
}

for (it in listOf(iosX64Test, iosArm64Test, iosSimulatorArm64Test, linuxX64Test, macosX64Test, macosArm64Test, mingwX64Test, tvosX64Test, tvosArm64Test, tvosSimulatorArm64Test)) {
it.dependsOn(nativeTest)
}

for (it in listOf(iosX64Main, iosArm64Main, macosX64Main, macosArm64Main, tvosX64Main, tvosArm64Main)) {
it.dependsOn(darwinMain)
}
}
}
}

Expand Down

0 comments on commit 963206a

Please sign in to comment.