From 691cf5380e02105c3b350eb6cfe33fbbe213b7df Mon Sep 17 00:00:00 2001 From: Ben Bader Date: Mon, 25 Nov 2024 09:02:43 -0700 Subject: [PATCH] Clean up thrifty-runtime project to fix gradle warnings (#12) * Clean up thrifty-runtime project to fix gradle warnings * Remove Java plugin from MPP --- .../com/bendb/thrifty/ThriftyMppPlugin.kt | 2 +- build.gradle | 17 ++++++----- thrifty-runtime/build.gradle | 30 ------------------- 3 files changed, 10 insertions(+), 39 deletions(-) diff --git a/build-src/src/main/kotlin/com/bendb/thrifty/ThriftyMppPlugin.kt b/build-src/src/main/kotlin/com/bendb/thrifty/ThriftyMppPlugin.kt index d2ac06fa..c5fd0929 100644 --- a/build-src/src/main/kotlin/com/bendb/thrifty/ThriftyMppPlugin.kt +++ b/build-src/src/main/kotlin/com/bendb/thrifty/ThriftyMppPlugin.kt @@ -26,8 +26,8 @@ import org.gradle.api.Project class ThriftyMppPlugin : Plugin { override fun apply(project: Project) { - project.plugins.apply() project.plugins.apply(Plugins.KOTLIN_MPP) + project.plugins.apply(Plugins.JACOCO) if (project.shouldSignAndDocumentBuild) { project.plugins.apply(Plugins.DOKKA) } diff --git a/build.gradle b/build.gradle index 5a295acd..cea17a6c 100644 --- a/build.gradle +++ b/build.gradle @@ -26,18 +26,19 @@ plugins { } tasks.register("codeCoverageReport", JacocoReport) { t -> - subprojects.each { - t.dependsOn it.tasks.withType(Test) - t.dependsOn it.tasks.findAll { it.name == "allTests" } // MPP why are you like this - t.sourceSets it.sourceSets.main + subprojects.each { sp -> + t.dependsOn sp.tasks.withType(Test) + t.dependsOn sp.tasks.findAll { it.name == "allTests" } // MPP why are you like this - def commonMain = it.file("src/commonMain/kotlin") - def jvmMain = it.file("src/jvmMain/kotlin") + def commonMain = sp.file("src/commonMain/kotlin") + def jvmMain = sp.file("src/jvmMain/kotlin") def isMpp = commonMain.exists() || jvmMain.exists() if (isMpp) { [commonMain, jvmMain].findAll(File::exists).each { d -> t.sourceDirectories.from(d) } - t.classDirectories.from(it.fileTree("build/classes/kotlin/jvm/main")) + t.classDirectories.from(sp.fileTree("build/classes/kotlin/jvm/main")) + } else { + t.sourceSets sp.sourceSets.main } } @@ -49,7 +50,7 @@ tasks.register("codeCoverageReport", JacocoReport) { t -> csv.required = false } - def filters = [ "**/AutoValue_*", "**/antlr/*", "com/bendb/thrifty/test/gen/*"] + def filters = ["**/antlr/*", "com/bendb/thrifty/test/gen/*"] t.classDirectories.setFrom(files(t.classDirectories.files.collect { fileTree(dir: it, exclude: filters) })) diff --git a/thrifty-runtime/build.gradle b/thrifty-runtime/build.gradle index 20dbfb6c..5549ec5b 100644 --- a/thrifty-runtime/build.gradle +++ b/thrifty-runtime/build.gradle @@ -88,9 +88,6 @@ kotlin { } } - jvmMain { - } - jvmTest { dependencies { implementation libs.kotlin.test.junit5 @@ -98,18 +95,6 @@ kotlin { implementation libs.junit } } - - iosMain { - dependsOn commonMain - } - - iosArm64Main { - dependsOn iosMain - } - - iosX64Main { - dependsOn iosMain - } } } @@ -117,21 +102,6 @@ jvmTest { useJUnitPlatform() } -//tasks.register("iosTest") { -// def device = project.findProperty("iosDevice")?.toString() ?: "iPhone 14 Pro Max" -// dependsOn 'linkDebugTestIosX64' -// group = JavaBasePlugin.VERIFICATION_GROUP -// description = "Runs tests for target 'ios' on an iOS simulator" -// -// doLast { -// def binary = kotlin.targets.iosX64.binaries.getTest('DEBUG').outputFile -// println("muh binary: ${binary.absolutePath}") -// exec { -// commandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath -// } -// } -//} - // What have I gotten myself in to configurations { jvmApiElements {