From d4132612aa0362d1eeb4ccd40c7b35a89db38def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fa=C3=A7=20Eldenk?= Date: Sat, 10 Aug 2024 02:22:55 -0500 Subject: [PATCH] fix tests --- app/build.gradle.kts | 5 +++++ build.gradle.kts | 9 ++++----- examples/sample-grpc-server/build.gradle.kts | 5 +++++ examples/sample-protoc-plugin/build.gradle.kts | 5 +++++ generated-code-tests/build.gradle.kts | 10 +++++++--- runtime-common/build.gradle.kts | 5 +++++ 6 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 804268f..085af82 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -32,6 +32,11 @@ java { } } +tasks.withType(Test::class.java) { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} + application { // Define the main class for the application. mainClass.set("dogacel.kotlinx.protobuf.gen.AppKt") diff --git a/build.gradle.kts b/build.gradle.kts index 4885535..cfb4dcf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,16 +20,15 @@ nexusPublishing { } } +tasks.withType(Test::class.java) { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} // Common settings for subprojects subprojects { apply(plugin = "org.jlleitschuh.gradle.ktlint") // Version should be inherited from parent - tasks.withType(Test::class.java) { - // Use JUnit Platform for unit tests. - useJUnitPlatform() - } - tasks.withType(KotlinCompilationTask::class.java).configureEach { compilerOptions.freeCompilerArgs.add("-opt-in=kotlinx.serialization.ExperimentalSerializationApi") } diff --git a/examples/sample-grpc-server/build.gradle.kts b/examples/sample-grpc-server/build.gradle.kts index 3c2b66b..2ac9f2a 100644 --- a/examples/sample-grpc-server/build.gradle.kts +++ b/examples/sample-grpc-server/build.gradle.kts @@ -35,6 +35,11 @@ dependencies { runtimeOnly(libs.bundles.logging) } +tasks.withType(Test::class.java) { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} + tasks.named("generateProto") { dependsOn(project(":app").tasks.jar) } diff --git a/examples/sample-protoc-plugin/build.gradle.kts b/examples/sample-protoc-plugin/build.gradle.kts index eda3684..6a2d0ca 100644 --- a/examples/sample-protoc-plugin/build.gradle.kts +++ b/examples/sample-protoc-plugin/build.gradle.kts @@ -18,6 +18,11 @@ dependencies { implementation(libs.bundles.kotlinx) } +tasks.withType(Test::class.java) { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} + tasks.named("generateProto") { dependsOn(project(":app").tasks.jar) } diff --git a/generated-code-tests/build.gradle.kts b/generated-code-tests/build.gradle.kts index 0824442..251d808 100644 --- a/generated-code-tests/build.gradle.kts +++ b/generated-code-tests/build.gradle.kts @@ -21,6 +21,11 @@ dependencies { testImplementation(libs.bundles.junit) } +tasks.withType(Test::class.java) { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} + tasks.named("generateProto") { dependsOn(project(":app").tasks.jar) dependsOn("cleanSources") @@ -28,13 +33,13 @@ tasks.named("generateProto") { tasks.register("copySources", type = Sync::class) { dependsOn("generateProto") - from("$buildDir/generated/source/proto/main/kotlinx-protobuf-gen") + from(layout.buildDirectory.dir("generated/source/proto/main/kotlinx-protobuf-gen")) into("src/main/kotlin") } tasks.register("cleanGeneratedFiles", type = Delete::class) { dependsOn("copySources") - delete("$buildDir/generated/source/proto/main/kotlinx-protobuf-gen") + delete(layout.buildDirectory.dir("generated/source/proto/main/kotlinx-protobuf-gen")) } tasks.register("cleanSources") { @@ -90,7 +95,6 @@ protobuf { } // Lint - tasks.named("runKtlintCheckOverMainSourceSet") { dependsOn("cleanGeneratedFiles") } diff --git a/runtime-common/build.gradle.kts b/runtime-common/build.gradle.kts index 547d69d..2659e6f 100644 --- a/runtime-common/build.gradle.kts +++ b/runtime-common/build.gradle.kts @@ -28,6 +28,11 @@ java { } } +tasks.withType(Test::class.java) { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} + tasks.jar { from(sourceSets.main.get().output)