From 2ee610360eb0e19b729d1d8b1560e82c67d22841 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Mon, 23 Oct 2023 10:54:40 +0200 Subject: [PATCH] Fix formatting and compile issues --- android-library-no-tests/build.gradle.kts | 6 ++++++ .../com/osacky/flank/gradle/FladlePluginDelegate.kt | 10 ++++++++-- .../java/com/osacky/flank/gradle/FulladlePlugin.kt | 5 ++++- .../main/java/com/osacky/flank/gradle/YamlWriter.kt | 7 +++++-- .../java/com/osacky/flank/gradle/YamlWriterTest.kt | 5 +++-- .../integration/FlankGradlePluginIntegrationTest.kt | 3 ++- .../integration/FulladlePluginIntegrationTest.kt | 3 ++- .../osacky/flank/gradle/integration/SanityRoboTest.kt | 4 ++-- .../gradle/integration/SanityWithAutoConfigureTest.kt | 6 +++--- .../osacky/flank/gradle/integration/VariantTests.kt | 2 +- sample-android-library/build.gradle.kts | 6 ++++++ sample-kotlin/build.gradle.kts | 8 +++++++- sample/build.gradle | 6 ++++++ 13 files changed, 55 insertions(+), 16 deletions(-) diff --git a/android-library-no-tests/build.gradle.kts b/android-library-no-tests/build.gradle.kts index 144e5d1a..bed1b75d 100644 --- a/android-library-no-tests/build.gradle.kts +++ b/android-library-no-tests/build.gradle.kts @@ -16,6 +16,12 @@ android { } } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } +} + fulladleModuleConfig { debugApk.set(rootProject.file("dummy_app.apk").path) } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladlePluginDelegate.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladlePluginDelegate.kt index aa7d3c43..92c82703 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladlePluginDelegate.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladlePluginDelegate.kt @@ -121,9 +121,15 @@ class FladlePluginDelegate { classpath = project.fladleConfig args = if (project.hasProperty("dumpShards")) { - listOf("firebase", "test", "android", "run", "-c", writeConfigProps.get().fladleConfigFile.get().asFile.absolutePath, "--dump-shards") + listOf( + "firebase", "test", "android", "run", "-c", + writeConfigProps.get().fladleConfigFile.get().asFile.absolutePath, "--dump-shards", + ) } else { - listOf("firebase", "test", "android", "run", "-c", writeConfigProps.get().fladleConfigFile.get().asFile.absolutePath) + listOf( + "firebase", "test", "android", "run", "-c", + writeConfigProps.get().fladleConfigFile.get().asFile.absolutePath, + ) } if (config.serviceAccountCredentials.isPresent) { environment(mapOf("GOOGLE_APPLICATION_CREDENTIALS" to config.serviceAccountCredentials.get())) diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FulladlePlugin.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FulladlePlugin.kt index 89f886df..cabee4b8 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FulladlePlugin.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FulladlePlugin.kt @@ -110,7 +110,10 @@ fun configureModule( // library modules do not produce an app apk and we'll use the one specified in fulladleModuleConfig block // we need library modules to specify the app apk to test against, even if it's a dummy one check(fulladleModuleExtension.debugApk.isPresent && fulladleModuleExtension.debugApk.orNull != null) { - "Library module ${project.path} did not specify a debug apk. Library modules do not generate a debug apk and one needs to be specified in the fulladleModuleConfig block\nThis is a required parameter in FTL which remains unused for library modules under test, and you can use a dummy apk here" + "Library module ${project.path} did not specify a debug apk. Library modules do not" + + "generate a debug apk and one needs to be specified in the fulladleModuleConfig block\n" + + "This is a required parameter in FTL which remains unused for library modules under test," + + "and you can use a dummy apk here" } flankGradleExtension.debugApk.set(rootProject.provider { fulladleModuleExtension.debugApk.get() }) } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlWriter.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlWriter.kt index e5ac020f..2262148f 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlWriter.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlWriter.kt @@ -11,12 +11,15 @@ internal class YamlWriter { if (base.projectId.orNull == null) { check(base.serviceAccountCredentials.isPresent) { - "ServiceAccountCredentials in fladle extension not set. https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials" + "ServiceAccountCredentials in fladle extension not set." + + "https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials" } } check(base.debugApk.isPresent) { "debugApk must be specified" } if (!config.sanityRobo.get()) { - val result = config.instrumentationApk.isPresent.toInt() + config.roboScript.hasValue.toInt() + config.roboDirectives.isPresentAndNotEmpty.toInt() + val result = + config.instrumentationApk.isPresent.toInt() + config.roboScript.hasValue.toInt() + + config.roboDirectives.isPresentAndNotEmpty.toInt() check(result == 1) { val prefix = diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt index f8e4937f..044b5d33 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt @@ -138,7 +138,8 @@ class YamlWriterTest { fail() } catch (expected: IllegalStateException) { assertEquals( - "ServiceAccountCredentials in fladle extension not set. https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials", + "ServiceAccountCredentials in fladle extension not set." + + "https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials", expected.message, ) } @@ -178,7 +179,7 @@ class YamlWriterTest { legacy-junit-result: false full-junit-result: false output-style: single - """.trimIndent() + '\n', // Dunno why this needs to be here to make the tests pass. + """.trimIndent() + '\n', ) } diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FlankGradlePluginIntegrationTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FlankGradlePluginIntegrationTest.kt index 4b5a48ba..66f8cd8f 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FlankGradlePluginIntegrationTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FlankGradlePluginIntegrationTest.kt @@ -112,7 +112,8 @@ class FlankGradlePluginIntegrationTest { assertThat( result.output, ).contains( - "ServiceAccountCredentials in fladle extension not set. https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials", + "ServiceAccountCredentials in fladle extension not set." + + "https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials", ) } diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FulladlePluginIntegrationTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FulladlePluginIntegrationTest.kt index dd3b4a0c..de3db3b5 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FulladlePluginIntegrationTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FulladlePluginIntegrationTest.kt @@ -714,7 +714,8 @@ class FulladlePluginIntegrationTest { assertThat(result.output).contains("Task :configureFulladle FAILED") assertThat(result.output).contains( - "Library module :android-library-project did not specify a debug apk. Library modules do not generate a debug apk and one needs to be specified in the fulladleModuleConfig block", + "Library module :android-library-project did not specify a debug apk. Library modules do not " + + "generate a debug apk and one needs to be specified in the fulladleModuleConfig block", ) assertThat(result.output).contains( "This is a required parameter in FTL which remains unused for library modules under test, and you can use a dummy apk here", diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/SanityRoboTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/SanityRoboTest.kt index 25cfa2f7..68e125e8 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/SanityRoboTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/SanityRoboTest.kt @@ -11,8 +11,8 @@ private fun baseConfigMessage(option: String) = "Incorrect [base] configuration. private fun additionalConfigMessage( option: String, name: String, -) = - "Incorrect [$name] configuration. [$option] can't be used together with sanityRobo. To configure sanityRobo, add clearPropertiesForSanityRobo() to the [$name] configuration" +) = "Incorrect [$name] configuration. [$option] can't be used together with sanityRobo." + + "To configure sanityRobo, add clearPropertiesForSanityRobo() to the [$name] configuration" class SanityRoboTest { @get:Rule diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/SanityWithAutoConfigureTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/SanityWithAutoConfigureTest.kt index 545dc4f2..3c0c27f5 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/SanityWithAutoConfigureTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/SanityWithAutoConfigureTest.kt @@ -6,7 +6,7 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder -private const val commonScriptPart = """ +private const val COMMON_SCRIPT_PART = """ plugins { id 'com.android.application' id 'com.osacky.fladle' @@ -44,7 +44,7 @@ class SanityWithAutoConfigureTest { fun `test auto configuration with sanityRobo set (inner config)`() { testProjectRoot.writeBuildDotGradle( """ - $commonScriptPart + $COMMON_SCRIPT_PART fladle { serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") @@ -197,7 +197,7 @@ class SanityWithAutoConfigureTest { fun `test auto configuration with sanityRobo set (base config)`() { testProjectRoot.writeBuildDotGradle( """ - $commonScriptPart + $COMMON_SCRIPT_PART fladle { sanityRobo = true diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/VariantTests.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/VariantTests.kt index e24ec9d7..833a0ecc 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/VariantTests.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/VariantTests.kt @@ -67,8 +67,8 @@ class VariantTests { assertThat(result.output).doesNotContain(":assembleVanillaRelease") assertThat(result.output).doesNotContain(":assembleChocolate") - // See #60 https://github.com/runningcode/fladle/issues/60 /** + * See #60 https://github.com/runningcode/fladle/issues/60 testProjectRoot.writeEmptyServiceCredential() val resultPrint = testProjectRoot.gradleRunner() .withArguments("printYmlVanilla") diff --git a/sample-android-library/build.gradle.kts b/sample-android-library/build.gradle.kts index 154100d3..751c6fca 100644 --- a/sample-android-library/build.gradle.kts +++ b/sample-android-library/build.gradle.kts @@ -30,6 +30,12 @@ android { } } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } +} + dependencies { implementation(libs.appcompat) implementation(libs.navigation.fragment.ktx) diff --git a/sample-kotlin/build.gradle.kts b/sample-kotlin/build.gradle.kts index 10359ff2..54f735bb 100644 --- a/sample-kotlin/build.gradle.kts +++ b/sample-kotlin/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } android { - namespace = "com.osacky.flank.gradle.sample" + namespace = "com.osacky.flank.gradle.sample.kotlin" compileSdk = 33 defaultConfig { applicationId = "com.osacky.flank.gradle.sample.kotlin" @@ -21,6 +21,12 @@ android { testOptions.execution = "ANDROIDX_TEST_ORCHESTRATOR" } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } +} + fladle { flankVersion.set("23.10.0") // Project Id is not needed if serviceAccountCredentials are set. diff --git a/sample/build.gradle b/sample/build.gradle index 978168d4..f20489b5 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -22,6 +22,12 @@ android { } } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } +} + fladle { async = true flankVersion = "23.+"