diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..8e2a5955 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*.{kt,kts}] +indent_size = 2 \ No newline at end of file diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 54bf30fc..4a81caf6 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -7,10 +7,11 @@ jobs: steps: - uses: actions/checkout@v4 - uses: gradle/actions/wrapper-validation@v3 - - uses: actions/setup-java@v4 + - name: "Set up JDK 11" + uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '8' + java-version: '11' - uses: gradle/actions/setup-gradle@v3 name: Setup Gradle - name: Check Fladle diff --git a/android-library-no-tests/build.gradle.kts b/android-library-no-tests/build.gradle.kts index 9ef01243..bed1b75d 100644 --- a/android-library-no-tests/build.gradle.kts +++ b/android-library-no-tests/build.gradle.kts @@ -4,12 +4,22 @@ plugins { } android { - compileSdkVersion(29) + compileSdk = 33 + namespace = "com.osacky.flank.gradle.sample.library" defaultConfig { - minSdkVersion(23) - targetSdkVersion(29) + minSdk = 23 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } } fulladleModuleConfig { diff --git a/android-library-no-tests/src/main/AndroidManifest.xml b/android-library-no-tests/src/main/AndroidManifest.xml index 8487ce01..8072ee00 100644 --- a/android-library-no-tests/src/main/AndroidManifest.xml +++ b/android-library-no-tests/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ - + diff --git a/android-library-no-tests/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt b/android-library-no-tests/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt index c0132658..964eb395 100644 --- a/android-library-no-tests/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt +++ b/android-library-no-tests/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt @@ -4,7 +4,6 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } diff --git a/build.gradle b/build.gradle index 1296d1bc..20fdfeaf 100644 --- a/build.gradle +++ b/build.gradle @@ -13,24 +13,16 @@ plugins { alias(libs.plugins.kotlinter) } -kotlinter { - indentSize = 2 -} - allprojects { apply plugin: "org.jmailen.kotlinter" - - kotlinter { - indentSize = 2 - } } fladle { serviceAccountCredentials = project.layout.projectDirectory.file("sample/flank-gradle-5cf02dc90531.json") } -tasks.named('wrapper').configure { - gradleVersion = '7.6.3' +tasks.wrapper.configure { + gradleVersion = '8.4' } def isNonStable = { String version -> diff --git a/fladle-plugin/build.gradle.kts b/fladle-plugin/build.gradle.kts index 311ed2ca..14412bcb 100644 --- a/fladle-plugin/build.gradle.kts +++ b/fladle-plugin/build.gradle.kts @@ -36,10 +36,6 @@ dependencies { testImplementation(libs.truth) } -kotlinter { - indentSize = 2 -} - gradlePlugin { website.set("https://github.com/runningcode/fladle") vcsUrl.set("https://github.com/runningcode/fladle") @@ -136,17 +132,17 @@ tasks.withType(ValidatePlugins::class.java).configureEach { enableStricterValidation.set(true) } -// Ensure Java 8 Compatibility. See https://github.com/runningcode/fladle/issues/246 +// Ensure Java 11 Compatibility. See https://github.com/runningcode/fladle/issues/246 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java).configureEach { kotlinOptions { - jvmTarget = "1.8" - languageVersion = "1.4" - apiVersion = "1.4" + jvmTarget = "11" + languageVersion = "1.7" + apiVersion = "1.7" } } java { toolchain { - languageVersion.set(JavaLanguageVersion.of(8)) + languageVersion.set(JavaLanguageVersion.of(11)) } } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladleConfig.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladleConfig.kt index 30486811..869a9938 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladleConfig.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladleConfig.kt @@ -53,7 +53,7 @@ interface FladleConfig { @Deprecated( message = "testShards is deprecated. Use maxTestShards instead", - replaceWith = ReplaceWith("maxTestShards") + replaceWith = ReplaceWith("maxTestShards"), ) /** * The maximum number of shards. Value will be overwritten by [maxTestShards] if both used in configuration @@ -472,13 +472,14 @@ interface FladleConfig { val additionalGcloudOptions: Property @Internal - fun getPresentProperties() = this::class.memberProperties - .filter { - when (val prop = it.call(this)) { - is Property<*> -> prop.isPresent - is MapProperty<*, *> -> prop.isPresent && prop.get().isNotEmpty() - is ListProperty<*> -> prop.isPresent && prop.get().isNotEmpty() - else -> false + fun getPresentProperties() = + this::class.memberProperties + .filter { + when (val prop = it.call(this)) { + is Property<*> -> prop.isPresent + is MapProperty<*, *> -> prop.isPresent && prop.get().isNotEmpty() + is ListProperty<*> -> prop.isPresent && prop.get().isNotEmpty() + else -> false + } } - } } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladleConfigImpl.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladleConfigImpl.kt index 71437808..4105cad4 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladleConfigImpl.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FladleConfigImpl.kt @@ -68,7 +68,7 @@ data class FladleConfigImpl( override val additionalFlankOptions: Property, override val additionalGcloudOptions: Property, override val dependOnAssemble: Property, - override val async: Property + override val async: Property, ) : FladleConfig { /** * Prepare config to run sanity robo. 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 02bf0527..ea878e0f 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 @@ -14,7 +14,6 @@ import org.gradle.kotlin.dsl.create import org.gradle.util.GradleVersion class FladlePluginDelegate { - fun apply(target: Project) { checkMinimumGradleVersion() @@ -41,7 +40,10 @@ class FladlePluginDelegate { } } - private fun configureTasks(project: Project, base: FlankGradleExtension) { + private fun configureTasks( + project: Project, + base: FlankGradleExtension, + ) { if (GradleVersion.current() > GradleVersion.version("6.1")) { base.flankVersion.finalizeValueOnRead() base.flankCoordinates.finalizeValueOnRead() @@ -70,21 +72,26 @@ class FladlePluginDelegate { } } - private fun TaskContainer.createTasksForConfig(base: FlankGradleExtension, config: FladleConfig, project: Project, name: String) { - + private fun TaskContainer.createTasksForConfig( + base: FlankGradleExtension, + config: FladleConfig, + project: Project, + name: String, + ) { val configName = name.toLowerCase() // we want to use default dir only if user did not set own `localResultsDir` val useDefaultDir = config.localResultsDir.isPresent.not() - val validateFladle = register("validateFladleConfig$name") { - description = "Perform validation actions" - group = TASK_GROUP - doLast { - checkIfSanityAndValidateConfigs(config) - validateOptionsUsed(config = config, flank = base.flankVersion.get()) - checkForExclusionUsage(config) + val validateFladle = + register("validateFladleConfig$name") { + description = "Perform validation actions" + group = TASK_GROUP + doLast { + checkIfSanityAndValidateConfigs(config) + validateOptionsUsed(config = config, flank = base.flankVersion.get()) + checkForExclusionUsage(config) + } } - } val writeConfigProps = register("writeConfigProps$name", YamlConfigWriterTask::class.java, base, config, name) @@ -112,17 +119,25 @@ class FladlePluginDelegate { if (useDefaultDir) setUpWorkingDir(configName) description = "Runs instrumentation tests using flank on firebase test lab." classpath = project.fladleConfig - args = if (project.hasProperty("dumpShards")) { - 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) - } + args = + if (project.hasProperty("dumpShards")) { + 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, + ) + } if (config.serviceAccountCredentials.isPresent) { environment(mapOf("GOOGLE_APPLICATION_CREDENTIALS" to config.serviceAccountCredentials.get())) } dependsOn(writeConfigProps) if (config.dependOnAssemble.isPresent && config.dependOnAssemble.get()) { - val testedExtension = requireNotNull(project.extensions.findByType(TestedExtension::class.java)) { "Could not find TestedExtension in ${project.name}" } + val testedExtension = + requireNotNull(project.extensions.findByType(TestedExtension::class.java)) { "Could not find TestedExtension in ${project.name}" } testedExtension.testVariants.configureEach { if (testedVariant.isExpectedVariant(config)) { if (testedVariant.assembleProvider.isPresent) { @@ -154,10 +169,15 @@ class FladlePluginDelegate { } } - private fun automaticallyConfigureTestOrchestrator(project: Project, config: FladleConfig, androidExtension: AppExtension) { + private fun automaticallyConfigureTestOrchestrator( + project: Project, + config: FladleConfig, + androidExtension: AppExtension, + ) { project.afterEvaluate { - val useOrchestrator = androidExtension.testOptions.getExecutionEnum() == TestOptions.Execution.ANDROIDX_TEST_ORCHESTRATOR || - androidExtension.testOptions.getExecutionEnum() == TestOptions.Execution.ANDROID_TEST_ORCHESTRATOR + val useOrchestrator = + androidExtension.testOptions.getExecutionEnum() == TestOptions.Execution.ANDROIDX_TEST_ORCHESTRATOR || + androidExtension.testOptions.getExecutionEnum() == TestOptions.Execution.ANDROID_TEST_ORCHESTRATOR if (useOrchestrator) { log("Automatically detected the use of Android Test Orchestrator") } @@ -165,8 +185,12 @@ class FladlePluginDelegate { } } - private fun findDebugAndInstrumentationApk(project: Project, config: FladleConfig) { - val baseExtension = requireNotNull(project.extensions.findByType(AppExtension::class.java)) { "Could not find AppExtension in ${project.name}" } + private fun findDebugAndInstrumentationApk( + project: Project, + config: FladleConfig, + ) { + val baseExtension = + requireNotNull(project.extensions.findByType(AppExtension::class.java)) { "Could not find AppExtension in ${project.name}" } automaticallyConfigureTestOrchestrator(project, config, baseExtension) baseExtension.testVariants.configureEach { val appVariant = testedVariant @@ -195,9 +219,10 @@ class FladlePluginDelegate { get() = configurations.getByName(FLADLE_CONFIG) companion object { - val GRADLE_MIN_VERSION: GradleVersion = GradleVersion.version("5.5") + val GRADLE_MIN_VERSION: GradleVersion = GradleVersion.version("6.5") const val TASK_GROUP = "fladle" const val FLADLE_CONFIG = "fladle" + fun Project.log(message: String) { logger.info("Fladle: $message") } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankExecutionTask.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankExecutionTask.kt index 03fe141d..168c5712 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankExecutionTask.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankExecutionTask.kt @@ -5,18 +5,26 @@ import org.gradle.api.tasks.Nested import org.gradle.work.DisableCachingByDefault import javax.inject.Inject -@DisableCachingByDefault(because = "Flank executions are dependent on resources such as network connection and server and therefore cannot be cached.") -open class FlankExecutionTask @Inject constructor(projectLayout: ProjectLayout, @get:Nested val config: FladleConfig) : FlankJavaExec(projectLayout) { - - init { - doFirst { - checkFilesExist(config) +@DisableCachingByDefault( + because = "Flank executions are dependent on resources such as network connection and server and therefore cannot be cached.", +) +open class FlankExecutionTask + @Inject + constructor( + projectLayout: ProjectLayout, + @get:Nested val config: FladleConfig, + ) : FlankJavaExec(projectLayout) { + init { + doFirst { + checkFilesExist(config) + } } - } - private fun checkFilesExist(base: FladleConfig) { - if (base.serviceAccountCredentials.isPresent) { - check(base.serviceAccountCredentials.get().asFile.exists()) { "serviceAccountCredential file doesn't exist ${base.serviceAccountCredentials.get()}" } + private fun checkFilesExist(base: FladleConfig) { + if (base.serviceAccountCredentials.isPresent) { + check(base.serviceAccountCredentials.get().asFile.exists()) { + "serviceAccountCredential file doesn't exist ${base.serviceAccountCredentials.get()}" + } + } } } -} diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankGradleExtension.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankGradleExtension.kt index 540dce79..8c333688 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankGradleExtension.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankGradleExtension.kt @@ -14,208 +14,214 @@ import org.gradle.kotlin.dsl.mapProperty import org.gradle.kotlin.dsl.property import javax.inject.Inject -open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : FladleConfig { +open class FlankGradleExtension + @Inject + constructor(objects: ObjectFactory) : FladleConfig { + companion object { + const val FLANK_VERSION = "23.10.1" + } - companion object { - const val FLANK_VERSION = "23.10.1" - } - - @get:Input - val flankCoordinates: Property = objects.property(String::class.java).convention("com.github.flank:flank") + @get:Input + val flankCoordinates: Property = objects.property(String::class.java).convention("com.github.flank:flank") - override val sanityRobo: Property = objects.property().convention(false) + override val sanityRobo: Property = objects.property().convention(false) - @get:Input - val flankVersion: Property = objects.property(String::class.java).convention(FLANK_VERSION) - // Project id is automatically discovered by default. Use this to override the project id. - override val projectId: Property = objects.property() - override val serviceAccountCredentials: RegularFileProperty = objects.fileProperty() - override val useOrchestrator: Property = objects.property().convention(false) - override val autoGoogleLogin: Property = objects.property().convention(false) - override val devices: ListProperty> = objects.listProperty>().convention(listOf(mapOf("model" to "NexusLowRes", "version" to "28"))) + @get:Input + val flankVersion: Property = objects.property(String::class.java).convention(FLANK_VERSION) - // https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run - override val testTargets: ListProperty = objects.listProperty() + // Project id is automatically discovered by default. Use this to override the project id. + override val projectId: Property = objects.property() + override val serviceAccountCredentials: RegularFileProperty = objects.fileProperty() + override val useOrchestrator: Property = objects.property().convention(false) + override val autoGoogleLogin: Property = objects.property().convention(false) + override val devices: ListProperty> = + objects.listProperty>().convention( + listOf(mapOf("model" to "NexusLowRes", "version" to "28")), + ) - override val testShards: Property = objects.property() - override val shardTime: Property = objects.property() - override val repeatTests: Property = objects.property() + // https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run + override val testTargets: ListProperty = objects.listProperty() - // Shard Android tests by time using historical run data. The amount of shards used is set by `testShards`. - override val smartFlankGcsPath: Property = objects.property() + override val testShards: Property = objects.property() + override val shardTime: Property = objects.property() + override val repeatTests: Property = objects.property() - override val resultsHistoryName: Property = objects.property() + // Shard Android tests by time using historical run data. The amount of shards used is set by `testShards`. + override val smartFlankGcsPath: Property = objects.property() - override val flakyTestAttempts: Property = objects.property().convention(0) + override val resultsHistoryName: Property = objects.property() - override val variant: Property = objects.property() + override val flakyTestAttempts: Property = objects.property().convention(0) - override val abi: Property = objects.property() + override val variant: Property = objects.property() - /** - * debugApk and instrumentationApk are [Property] and not [RegularFileProperty] because we support wildcard characters. - */ - override val debugApk: Property = objects.property() + override val abi: Property = objects.property() - override val instrumentationApk: Property = objects.property() + /** + * debugApk and instrumentationApk are [Property] and not [RegularFileProperty] because we support wildcard characters. + */ + override val debugApk: Property = objects.property() - override val directoriesToPull: ListProperty = objects.listProperty() + override val instrumentationApk: Property = objects.property() - override val filesToDownload: ListProperty = objects.listProperty() + override val directoriesToPull: ListProperty = objects.listProperty() - override val environmentVariables: MapProperty = objects.mapProperty() + override val filesToDownload: ListProperty = objects.listProperty() - override val recordVideo: Property = objects.property().convention(true) + override val environmentVariables: MapProperty = objects.mapProperty() - override val performanceMetrics: Property = objects.property().convention(true) + override val recordVideo: Property = objects.property().convention(true) - override val resultsBucket: Property = objects.property() + override val performanceMetrics: Property = objects.property().convention(true) - override val keepFilePath: Property = objects.property().convention(false) + override val resultsBucket: Property = objects.property() - override val resultsDir: Property = objects.property() + override val keepFilePath: Property = objects.property().convention(false) - override val additionalTestApks: ListProperty = objects.listProperty() + override val resultsDir: Property = objects.property() - override val runTimeout: Property = objects.property() + override val additionalTestApks: ListProperty = objects.listProperty() - override val ignoreFailedTests: Property = objects.property().convention(false) + override val runTimeout: Property = objects.property() - override val disableSharding: Property = objects.property().convention(false) + override val ignoreFailedTests: Property = objects.property().convention(false) - override val smartFlankDisableUpload: Property = objects.property().convention(false) + override val disableSharding: Property = objects.property().convention(false) - override val testRunnerClass: Property = objects.property() + override val smartFlankDisableUpload: Property = objects.property().convention(false) - override val localResultsDir: Property = objects.property() + override val testRunnerClass: Property = objects.property() - override val numUniformShards: Property = objects.property() + override val localResultsDir: Property = objects.property() - override val clientDetails: MapProperty = objects.mapProperty() + override val numUniformShards: Property = objects.property() - override val testTargetsAlwaysRun: ListProperty = objects.listProperty() + override val clientDetails: MapProperty = objects.mapProperty() - override val otherFiles: MapProperty = objects.mapProperty() + override val testTargetsAlwaysRun: ListProperty = objects.listProperty() - override val networkProfile: Property = objects.property() + override val otherFiles: MapProperty = objects.mapProperty() - override val roboScript: Property = objects.property() + override val networkProfile: Property = objects.property() - override val roboDirectives: ListProperty> = objects.listProperty() + override val roboScript: Property = objects.property() - override val testTimeout: Property = objects.property().convention("15m") + override val roboDirectives: ListProperty> = objects.listProperty() - override val outputStyle: Property = objects.property().convention("single") + override val testTimeout: Property = objects.property().convention("15m") - override val legacyJunitResult: Property = objects.property().convention(false) + override val outputStyle: Property = objects.property().convention("single") - override val fullJunitResult: Property = objects.property().convention(false) + override val legacyJunitResult: Property = objects.property().convention(false) - override val additionalApks: ListProperty = objects.listProperty() + override val fullJunitResult: Property = objects.property().convention(false) - override val defaultTestTime: Property = objects.property() + override val additionalApks: ListProperty = objects.listProperty() - override val useAverageTestTimeForNewTests: Property = objects.property() + override val defaultTestTime: Property = objects.property() - override val defaultClassTestTime: Property = objects.property() + override val useAverageTestTimeForNewTests: Property = objects.property() - override val disableResultsUpload: Property = objects.property() + override val defaultClassTestTime: Property = objects.property() - override val testTargetsForShard: ListProperty = objects.listProperty() + override val disableResultsUpload: Property = objects.property() - override val grantPermissions: Property = objects.property() + override val testTargetsForShard: ListProperty = objects.listProperty() - override val type: Property = objects.property() + override val grantPermissions: Property = objects.property() - override val scenarioLabels: ListProperty = objects.listProperty() + override val type: Property = objects.property() - override val scenarioNumbers: ListProperty = objects.listProperty() + override val scenarioLabels: ListProperty = objects.listProperty() - override val obbFiles: ListProperty = objects.listProperty() + override val scenarioNumbers: ListProperty = objects.listProperty() - override val obbNames: ListProperty = objects.listProperty() + override val obbFiles: ListProperty = objects.listProperty() - override val failFast: Property = objects.property() + override val obbNames: ListProperty = objects.listProperty() - override val maxTestShards: Property = objects.property() + override val failFast: Property = objects.property() - override val additionalFlankOptions: Property = objects.property() + override val maxTestShards: Property = objects.property() - override val additionalGcloudOptions: Property = objects.property() + override val additionalFlankOptions: Property = objects.property() - override val dependOnAssemble: Property = objects.property().convention(false) + override val additionalGcloudOptions: Property = objects.property() - override val async: Property = objects.property().convention(false) + override val dependOnAssemble: Property = objects.property().convention(false) - @Internal - val configs: NamedDomainObjectContainer = objects.domainObjectContainer(FladleConfigImpl::class.java) { - FladleConfigImpl( - name = it, - projectId = objects.property().convention(projectId), - serviceAccountCredentials = objects.fileProperty().convention(serviceAccountCredentials), - debugApk = objects.property().convention(debugApk), - instrumentationApk = objects.property().convention(instrumentationApk), - sanityRobo = objects.property().convention(sanityRobo), - useOrchestrator = objects.property().convention(useOrchestrator), - autoGoogleLogin = objects.property().convention(autoGoogleLogin), - devices = objects.listProperty>().convention(devices), - testTargets = objects.listProperty().convention(testTargets), - testShards = objects.property().convention(testShards), - shardTime = objects.property().convention(shardTime), - repeatTests = objects.property().convention(repeatTests), - smartFlankGcsPath = objects.property().convention(smartFlankGcsPath), - resultsHistoryName = objects.property().convention(resultsHistoryName), - flakyTestAttempts = objects.property().convention(flakyTestAttempts), - variant = objects.property().convention(variant), - abi = objects.property().convention(abi), - directoriesToPull = objects.listProperty().convention(directoriesToPull), - filesToDownload = objects.listProperty().convention(filesToDownload), - environmentVariables = objects.mapProperty().convention(environmentVariables), - recordVideo = objects.property().convention(recordVideo), - performanceMetrics = objects.property().convention(performanceMetrics), - resultsBucket = objects.property().convention(resultsBucket), - keepFilePath = objects.property().convention(keepFilePath), - resultsDir = objects.property().convention(resultsDir), - additionalTestApks = objects.listProperty().convention(additionalTestApks), - runTimeout = objects.property().convention(runTimeout), - ignoreFailedTests = objects.property().convention(ignoreFailedTests), - disableSharding = objects.property().convention(disableSharding), - smartFlankDisableUpload = objects.property().convention(smartFlankDisableUpload), - testRunnerClass = objects.property().convention(testRunnerClass), - localResultsDir = objects.property().convention(localResultsDir), - numUniformShards = objects.property().convention(numUniformShards), - clientDetails = objects.mapProperty().convention(clientDetails), - testTargetsAlwaysRun = objects.listProperty().convention(testTargetsAlwaysRun), - otherFiles = objects.mapProperty().convention(otherFiles), - networkProfile = objects.property().convention(networkProfile), - roboScript = objects.property().convention(roboScript), - roboDirectives = objects.listProperty>().convention(roboDirectives), - testTimeout = objects.property().convention(testTimeout), - outputStyle = objects.property().convention(outputStyle), - legacyJunitResult = objects.property().convention(legacyJunitResult), - fullJunitResult = objects.property().convention(fullJunitResult), - additionalApks = objects.listProperty().convention(additionalApks), - useAverageTestTimeForNewTests = objects.property().convention(useAverageTestTimeForNewTests), - defaultTestTime = objects.property().convention(defaultTestTime), - defaultClassTestTime = objects.property().convention(defaultClassTestTime), - disableResultsUpload = objects.property().convention(disableResultsUpload), - testTargetsForShard = objects.listProperty().convention(testTargetsForShard), - grantPermissions = objects.property().convention(grantPermissions), - type = objects.property().convention(type), - scenarioLabels = objects.listProperty().convention(scenarioLabels), - scenarioNumbers = objects.listProperty().convention(scenarioNumbers), - obbFiles = objects.listProperty().convention(obbFiles), - obbNames = objects.listProperty().convention(obbNames), - failFast = objects.property().convention(failFast), - maxTestShards = objects.property().convention(maxTestShards), - additionalFlankOptions = objects.property().convention(additionalFlankOptions), - additionalGcloudOptions = objects.property().convention(additionalGcloudOptions), - dependOnAssemble = objects.property().convention(dependOnAssemble), - async = objects.property().convention(async) - ) - } + override val async: Property = objects.property().convention(false) - fun configs(closure: Closure<*>) { - configs.configure(closure) + @Internal + val configs: NamedDomainObjectContainer = + objects.domainObjectContainer(FladleConfigImpl::class.java) { + FladleConfigImpl( + name = it, + projectId = objects.property().convention(projectId), + serviceAccountCredentials = objects.fileProperty().convention(serviceAccountCredentials), + debugApk = objects.property().convention(debugApk), + instrumentationApk = objects.property().convention(instrumentationApk), + sanityRobo = objects.property().convention(sanityRobo), + useOrchestrator = objects.property().convention(useOrchestrator), + autoGoogleLogin = objects.property().convention(autoGoogleLogin), + devices = objects.listProperty>().convention(devices), + testTargets = objects.listProperty().convention(testTargets), + testShards = objects.property().convention(testShards), + shardTime = objects.property().convention(shardTime), + repeatTests = objects.property().convention(repeatTests), + smartFlankGcsPath = objects.property().convention(smartFlankGcsPath), + resultsHistoryName = objects.property().convention(resultsHistoryName), + flakyTestAttempts = objects.property().convention(flakyTestAttempts), + variant = objects.property().convention(variant), + abi = objects.property().convention(abi), + directoriesToPull = objects.listProperty().convention(directoriesToPull), + filesToDownload = objects.listProperty().convention(filesToDownload), + environmentVariables = objects.mapProperty().convention(environmentVariables), + recordVideo = objects.property().convention(recordVideo), + performanceMetrics = objects.property().convention(performanceMetrics), + resultsBucket = objects.property().convention(resultsBucket), + keepFilePath = objects.property().convention(keepFilePath), + resultsDir = objects.property().convention(resultsDir), + additionalTestApks = objects.listProperty().convention(additionalTestApks), + runTimeout = objects.property().convention(runTimeout), + ignoreFailedTests = objects.property().convention(ignoreFailedTests), + disableSharding = objects.property().convention(disableSharding), + smartFlankDisableUpload = objects.property().convention(smartFlankDisableUpload), + testRunnerClass = objects.property().convention(testRunnerClass), + localResultsDir = objects.property().convention(localResultsDir), + numUniformShards = objects.property().convention(numUniformShards), + clientDetails = objects.mapProperty().convention(clientDetails), + testTargetsAlwaysRun = objects.listProperty().convention(testTargetsAlwaysRun), + otherFiles = objects.mapProperty().convention(otherFiles), + networkProfile = objects.property().convention(networkProfile), + roboScript = objects.property().convention(roboScript), + roboDirectives = objects.listProperty>().convention(roboDirectives), + testTimeout = objects.property().convention(testTimeout), + outputStyle = objects.property().convention(outputStyle), + legacyJunitResult = objects.property().convention(legacyJunitResult), + fullJunitResult = objects.property().convention(fullJunitResult), + additionalApks = objects.listProperty().convention(additionalApks), + useAverageTestTimeForNewTests = objects.property().convention(useAverageTestTimeForNewTests), + defaultTestTime = objects.property().convention(defaultTestTime), + defaultClassTestTime = objects.property().convention(defaultClassTestTime), + disableResultsUpload = objects.property().convention(disableResultsUpload), + testTargetsForShard = objects.listProperty().convention(testTargetsForShard), + grantPermissions = objects.property().convention(grantPermissions), + type = objects.property().convention(type), + scenarioLabels = objects.listProperty().convention(scenarioLabels), + scenarioNumbers = objects.listProperty().convention(scenarioNumbers), + obbFiles = objects.listProperty().convention(obbFiles), + obbNames = objects.listProperty().convention(obbNames), + failFast = objects.property().convention(failFast), + maxTestShards = objects.property().convention(maxTestShards), + additionalFlankOptions = objects.property().convention(additionalFlankOptions), + additionalGcloudOptions = objects.property().convention(additionalGcloudOptions), + dependOnAssemble = objects.property().convention(dependOnAssemble), + async = objects.property().convention(async), + ) + } + + fun configs(closure: Closure<*>) { + configs.configure(closure) + } } -} diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankGradlePlugin.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankGradlePlugin.kt index dfc8f437..3aa0b437 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankGradlePlugin.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankGradlePlugin.kt @@ -4,7 +4,6 @@ import org.gradle.api.Plugin import org.gradle.api.Project class FlankGradlePlugin : Plugin { - override fun apply(target: Project) { FladlePluginDelegate().apply(target) } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankJavaExec.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankJavaExec.kt index fc249c2a..f10ef850 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankJavaExec.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FlankJavaExec.kt @@ -5,13 +5,17 @@ import org.gradle.api.tasks.JavaExec import org.gradle.work.DisableCachingByDefault import javax.inject.Inject -@DisableCachingByDefault(because = "Flank executions are dependent on resources such as network connection and server and therefore cannot be cached.") -open class FlankJavaExec @Inject constructor(projectLayout: ProjectLayout) : JavaExec() { - init { - group = FladlePluginDelegate.TASK_GROUP - mainClass.set("ftl.Main") - workingDir(projectLayout.fladleDir) - } +@DisableCachingByDefault( + because = "Flank executions are dependent on resources such as network connection and server and therefore cannot be cached.", +) +open class FlankJavaExec + @Inject + constructor(projectLayout: ProjectLayout) : JavaExec() { + init { + group = FladlePluginDelegate.TASK_GROUP + mainClass.set("ftl.Main") + workingDir(projectLayout.fladleDir) + } - fun setUpWorkingDir(configName: String) = workingDir(project.layout.buildDirectory.dir("fladle/$configName")) -} + fun setUpWorkingDir(configName: String) = workingDir(project.layout.buildDirectory.dir("fladle/$configName")) + } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FulladleModuleExtension.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FulladleModuleExtension.kt index 1ab414ee..510f5f54 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/FulladleModuleExtension.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/FulladleModuleExtension.kt @@ -7,42 +7,43 @@ import org.gradle.kotlin.dsl.mapProperty import org.gradle.kotlin.dsl.property import javax.inject.Inject -open class FulladleModuleExtension @Inject constructor(objects: ObjectFactory) { - - /** - * When set to false, Fulladle will not automatically add this module to additionalTestApks. - * - * Default: true - */ - val enabled: Property = objects.property().convention(true) - - /** - * The maximum number of shards to be used for this specific test apk. - */ - val maxTestShards: Property = objects.property().convention(null as Int?) - - /** - * A key-value map of additional details to attach to the test matrix results file. - * Arbitrary key-value pairs may be attached to a test matrix to provide additional context about the tests being run. - * When consuming the test results, such as in Cloud Functions or a CI system, - * these details can add additional context such as a link to the corresponding pull request. - */ - val clientDetails: MapProperty = objects.mapProperty() - - /** - * The environment variables are mirrored as extra options to the am instrument -e KEY1 VALUE1 … command and - * passed to your test runner (typically AndroidJUnitRunner) - */ - val environmentVariables: MapProperty = objects.mapProperty() - - /** - * the app under test - */ - val debugApk: Property = objects.property().convention(null as String?) - - /** - * The variant that should be used for the specific module. If nothing is specified any variant - * can be a match. - */ - val variant: Property = objects.property().convention(null as String?) -} +open class FulladleModuleExtension + @Inject + constructor(objects: ObjectFactory) { + /** + * When set to false, Fulladle will not automatically add this module to additionalTestApks. + * + * Default: true + */ + val enabled: Property = objects.property().convention(true) + + /** + * The maximum number of shards to be used for this specific test apk. + */ + val maxTestShards: Property = objects.property().convention(null as Int?) + + /** + * A key-value map of additional details to attach to the test matrix results file. + * Arbitrary key-value pairs may be attached to a test matrix to provide additional context about the tests being run. + * When consuming the test results, such as in Cloud Functions or a CI system, + * these details can add additional context such as a link to the corresponding pull request. + */ + val clientDetails: MapProperty = objects.mapProperty() + + /** + * The environment variables are mirrored as extra options to the am instrument -e KEY1 VALUE1 … command and + * passed to your test runner (typically AndroidJUnitRunner) + */ + val environmentVariables: MapProperty = objects.mapProperty() + + /** + * the app under test + */ + val debugApk: Property = objects.property().convention(null as String?) + + /** + * The variant that should be used for the specific module. If nothing is specified any variant + * can be a match. + */ + val variant: Property = objects.property().convention(null as String?) + } 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 ee7a1e7e..568feebb 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 @@ -20,44 +20,49 @@ class FulladlePlugin : Plugin { extensions.create("fulladleModuleConfig", FulladleModuleExtension::class.java) } - val fulladleConfigureTask = root.tasks.register("configureFulladle") { - var modulesEnabled = false - /** - * we will first configure all app modules - * then configure all library modules - * we force this order of configuration because - * app modules are better candidates to become - * root level test/app APKs, since they produce - * app APKs - * if no app module had tests or was enabled - * we will choose a library module to become - * a root level module, in which case we will - * have to check if it has its debugApk set - */ - doLast { - // first configure all app modules - root.subprojects { - if (!hasAndroidTest) - return@subprojects - modulesEnabled = true - if (isAndroidAppModule) - configureModule(this, flankGradleExtension) - } - // then configure all library modules - root.subprojects { - if (!hasAndroidTest) - return@subprojects - modulesEnabled = true - if (isAndroidLibraryModule) - configureModule(this, flankGradleExtension) - } + val fulladleConfigureTask = + root.tasks.register("configureFulladle") { + var modulesEnabled = false + /** + * we will first configure all app modules + * then configure all library modules + * we force this order of configuration because + * app modules are better candidates to become + * root level test/app APKs, since they produce + * app APKs + * if no app module had tests or was enabled + * we will choose a library module to become + * a root level module, in which case we will + * have to check if it has its debugApk set + */ + doLast { + // first configure all app modules + root.subprojects { + if (!hasAndroidTest) { + return@subprojects + } + modulesEnabled = true + if (isAndroidAppModule) { + configureModule(this, flankGradleExtension) + } + } + // then configure all library modules + root.subprojects { + if (!hasAndroidTest) { + return@subprojects + } + modulesEnabled = true + if (isAndroidLibraryModule) { + configureModule(this, flankGradleExtension) + } + } - check(modulesEnabled) { - "All modules were disabled for testing in fulladleModuleConfig or the enabled modules had no tests.\n" + - "Either re-enable modules for testing or add modules with tests." + check(modulesEnabled) { + "All modules were disabled for testing in fulladleModuleConfig or the enabled modules had no tests.\n" + + "Either re-enable modules for testing or add modules with tests." + } } } - } root.tasks.withType(YamlConfigWriterTask::class.java).configureEach { dependsOn(fulladleConfigureTask) @@ -72,7 +77,10 @@ class FulladlePlugin : Plugin { } } -fun configureModule(project: Project, flankGradleExtension: FlankGradleExtension) = project.run { +fun configureModule( + project: Project, + flankGradleExtension: FlankGradleExtension, +) = project.run { val fulladleModuleExtension = extensions.findByType(FulladleModuleExtension::class.java) ?: return if (!hasAndroidTest) { return @@ -102,7 +110,10 @@ fun configureModule(project: Project, flankGradleExtension: FlankGradleExtension // 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() }) } @@ -139,11 +150,11 @@ fun configureModule(project: Project, flankGradleExtension: FlankGradleExtension yml.appendProperty(fulladleModuleExtension.maxTestShards, " max-test-shards") yml.appendMapProperty( fulladleModuleExtension.clientDetails, - " client-details" + " client-details", ) { appendLine(" ${it.key}: ${it.value}") } yml.appendMapProperty( fulladleModuleExtension.environmentVariables, - " environment-variables" + " environment-variables", ) { appendLine(" ${it.key}: ${it.value}") } flankGradleExtension.additionalTestApks.add(yml.toString()) } @@ -181,7 +192,10 @@ val Project.hasAndroidTest: Boolean return testsFound } -fun overrideRootLevelConfigs(flankGradleExtension: FlankGradleExtension, fulladleModuleExtension: FulladleModuleExtension) { +fun overrideRootLevelConfigs( + flankGradleExtension: FlankGradleExtension, + fulladleModuleExtension: FulladleModuleExtension, +) { // if the root module overrode any value in its fulladleModuleConfig block // then use those values instead val debugApk = fulladleModuleExtension.debugApk.orNull diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/ImportReportDelegate.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/ImportReportDelegate.kt index 9387eadd..f07314f2 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/ImportReportDelegate.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/ImportReportDelegate.kt @@ -15,31 +15,36 @@ import com.gradle.enterprise.gradleplugin.test.JUnitXmlDialect as GEJUnitXmlDial fun canImportReport(): Boolean = JUnitXmlHandler.canImport() -fun importReport(project: Project, flankTaskProvider: TaskProvider) { - val enableTestUploads = project.providers - .gradleProperty("com.osacky.fladle.enableTestUploads") - .getOrElse("true") - .toBoolean() +fun importReport( + project: Project, + flankTaskProvider: TaskProvider, +) { + val enableTestUploads = + project.providers + .gradleProperty("com.osacky.fladle.enableTestUploads") + .getOrElse("true") + .toBoolean() if (enableTestUploads) { - val resultsProvider: Provider = project.layout.buildDirectory - .dir("fladle") - .flatMap { fladleDir -> - val localResultsDirProvider: Provider = fladleDir - .dir(flankTaskProvider.flatMap { task -> task.config.localResultsDir }) + val resultsProvider: Provider = + project.layout.buildDirectory + .dir("fladle") + .flatMap { fladleDir -> + val localResultsDirProvider: Provider = + fladleDir + .dir(flankTaskProvider.flatMap { task -> task.config.localResultsDir }) - localResultsDirProvider.map { localResultsDir -> localResultsDir.file("JUnitReport.xml") } - } + localResultsDirProvider.map { localResultsDir -> localResultsDir.file("JUnitReport.xml") } + } JUnitXmlHandler.get()?.register( project.tasks, flankTaskProvider, - resultsProvider + resultsProvider, ) } } /** Abstraction over Develocity and GE impls of JUnitXml reporting. */ sealed class JUnitXmlHandler { - abstract fun register( tasks: TaskContainer, flankTask: TaskProvider, @@ -47,12 +52,13 @@ sealed class JUnitXmlHandler { ) companion object { - private fun canImport(name: String) = try { - Class.forName(name) - true - } catch (e: ClassNotFoundException) { - false - } + private fun canImport(name: String) = + try { + Class.forName(name) + true + } catch (e: ClassNotFoundException) { + false + } private val canImportDevelocity get() = canImport("com.gradle.develocity.agent.gradle.test.ImportJUnitXmlReports") @@ -60,13 +66,14 @@ sealed class JUnitXmlHandler { fun canImport() = canImportDevelocity || canImportGE - fun get() = if (canImportDevelocity) { - DevelocityJunitXmlHandler - } else if (canImportGE) { - GEJunitXmlHandler - } else { - null - } + fun get() = + if (canImportDevelocity) { + DevelocityJunitXmlHandler + } else if (canImportGE) { + GEJunitXmlHandler + } else { + null + } } object DevelocityJunitXmlHandler : JUnitXmlHandler() { diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/RunFlankTask.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/RunFlankTask.kt index 93d980c3..b47c0e74 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/RunFlankTask.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/RunFlankTask.kt @@ -4,11 +4,14 @@ import org.gradle.api.DefaultTask import org.gradle.work.DisableCachingByDefault import javax.inject.Inject -@DisableCachingByDefault(because = "Flank executions are dependent on resources such as network connection and server and therefore cannot be cached.") -open class RunFlankTask @Inject constructor() : DefaultTask() { - - init { - description = "Runs instrumentation tests using flank on firebase test lab." - group = FladlePluginDelegate.TASK_GROUP +@DisableCachingByDefault( + because = "Flank executions are dependent on resources such as network connection and server and therefore cannot be cached.", +) +open class RunFlankTask + @Inject + constructor() : DefaultTask() { + init { + description = "Runs instrumentation tests using flank on firebase test lab." + group = FladlePluginDelegate.TASK_GROUP + } } -} diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/SanityConfigValidation.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/SanityConfigValidation.kt index 48d8dfde..26d91f4a 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/SanityConfigValidation.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/SanityConfigValidation.kt @@ -4,23 +4,31 @@ import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property import java.lang.IllegalArgumentException -fun checkIfSanityAndValidateConfigs(config: FladleConfig) = when (config) { - is FlankGradleExtension -> config.checkAndValidateConfig { option, name -> - "Incorrect [$name] configuration. [$option] can't be used together with sanityRobo." +fun checkIfSanityAndValidateConfigs(config: FladleConfig) = + when (config) { + is FlankGradleExtension -> + config.checkAndValidateConfig { option, name -> + "Incorrect [$name] configuration. [$option] can't be used together with sanityRobo." + } + is FladleConfigImpl -> + config.checkAndValidateConfig(config.name) { option, name -> + "Incorrect [$name] configuration. [$option] can't be used together with sanityRobo. " + + "To configure sanityRobo, add clearPropertiesForSanityRobo() to the [$name] configuration" + } + else -> throw IllegalArgumentException("Unexpected configuration when validating parameters. Did not expect: $config.") } - is FladleConfigImpl -> config.checkAndValidateConfig(config.name) { option, name -> - "Incorrect [$name] configuration. [$option] can't be used together with sanityRobo. " + - "To configure sanityRobo, add clearPropertiesForSanityRobo() to the [$name] configuration" - } - else -> throw IllegalArgumentException("Unexpected configuration when validating parameters. Did not expect: $config.") -} -private fun FladleConfig.checkAndValidateConfig(name: String = "base", message: (String, String) -> String) { - if (sanityRobo.get()) when { - roboDirectives.hasValue -> throw IllegalStateException(message("roboDirectives", name)) - roboScript.hasValue -> throw IllegalStateException(message("roboScript", name)) - instrumentationApk.hasValue -> throw IllegalStateException(message("instrumentationApk", name)) - additionalTestApks.hasValue -> throw IllegalStateException(message("additionalTestApks", name)) +private fun FladleConfig.checkAndValidateConfig( + name: String = "base", + message: (String, String) -> String, +) { + if (sanityRobo.get()) { + when { + roboDirectives.hasValue -> throw IllegalStateException(message("roboDirectives", name)) + roboScript.hasValue -> throw IllegalStateException(message("roboScript", name)) + instrumentationApk.hasValue -> throw IllegalStateException(message("instrumentationApk", name)) + additionalTestApks.hasValue -> throw IllegalStateException(message("additionalTestApks", name)) + } } } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlConfigWriterTask.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlConfigWriterTask.kt index 35473050..12373cbb 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlConfigWriterTask.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlConfigWriterTask.kt @@ -16,48 +16,52 @@ import java.util.Locale import javax.inject.Inject @DisableCachingByDefault(because = "The task writes a small file from in memory properties and does not benefit from caching.") -open class YamlConfigWriterTask @Inject constructor( - @get:Nested val base: FlankGradleExtension, - @get:Nested val config: FladleConfig, - @get:Input val configName: String, - projectLayout: ProjectLayout, - objects: ObjectFactory -) : DefaultTask() { - - private val yamlWriter = YamlWriter() - - private val fladleDir = projectLayout.fladleDir.map { - if (configName == "") { - it - } else { - it.dir(configName.toLowerCase(Locale.ROOT)) - } - } +open class YamlConfigWriterTask + @Inject + constructor( + @get:Nested val base: FlankGradleExtension, + @get:Nested val config: FladleConfig, + @get:Input val configName: String, + projectLayout: ProjectLayout, + objects: ObjectFactory, + ) : DefaultTask() { + private val yamlWriter = YamlWriter() - @get:Input - val additionalTestApks: ListProperty = objects.listProperty(String::class.java) - .convention(config.additionalTestApks) + private val fladleDir = + projectLayout.fladleDir.map { + if (configName == "") { + it + } else { + it.dir(configName.toLowerCase(Locale.ROOT)) + } + } - @OutputFile - val fladleConfigFile: Provider = fladleDir.map { it.file("flank.yml") } + @get:Input + val additionalTestApks: ListProperty = + objects.listProperty(String::class.java) + .convention(config.additionalTestApks) - @Internal - override fun getDescription(): String { - return "Writes a flank.yml file based on the current FlankGradleExtension configuration." - } + @OutputFile + val fladleConfigFile: Provider = fladleDir.map { it.file("flank.yml") } - @Internal - override fun getGroup(): String { - return FladlePluginDelegate.TASK_GROUP - } + @Internal + override fun getDescription(): String { + return "Writes a flank.yml file based on the current FlankGradleExtension configuration." + } + + @Internal + override fun getGroup(): String { + return FladlePluginDelegate.TASK_GROUP + } - @TaskAction - fun writeFile() { - fladleDir.get().asFile.mkdirs() - val mergedConfig = object : FladleConfig by config { - override val additionalTestApks: ListProperty - get() = this@YamlConfigWriterTask.additionalTestApks + @TaskAction + fun writeFile() { + fladleDir.get().asFile.mkdirs() + val mergedConfig = + object : FladleConfig by config { + override val additionalTestApks: ListProperty + get() = this@YamlConfigWriterTask.additionalTestApks + } + fladleConfigFile.get().asFile.writeText(yamlWriter.createConfigProps(mergedConfig, base)) } - fladleConfigFile.get().asFile.writeText(yamlWriter.createConfigProps(mergedConfig, base)) } -} diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlExtensions.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlExtensions.kt index e02a6125..75d41a73 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlExtensions.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/YamlExtensions.kt @@ -4,14 +4,17 @@ import org.gradle.api.provider.ListProperty import org.gradle.api.provider.MapProperty import org.gradle.api.provider.Property -fun StringBuilder.appendProperty(prop: Property, name: String) { +fun StringBuilder.appendProperty( + prop: Property, + name: String, +) { if (prop.isPresent) appendLine(" $name: ${prop.get()}") } fun StringBuilder.appendMapProperty( prop: MapProperty, name: String, - custom: StringBuilder.(Map.Entry) -> Unit + custom: StringBuilder.(Map.Entry) -> Unit, ) { if (prop.isPresentAndNotEmpty) { appendLine(" $name:") @@ -22,7 +25,7 @@ fun StringBuilder.appendMapProperty( fun StringBuilder.appendListProperty( prop: ListProperty, name: String, - custom: StringBuilder.(T) -> Unit + custom: StringBuilder.(T) -> Unit, ) { if (prop.isPresentAndNotEmpty) { appendLine(" $name:") 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 962522c9..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 @@ -3,23 +3,31 @@ package com.osacky.flank.gradle import org.gradle.internal.impldep.com.google.common.annotations.VisibleForTesting internal class YamlWriter { - - internal fun createConfigProps(config: FladleConfig, base: FlankGradleExtension): String { + internal fun createConfigProps( + config: FladleConfig, + base: FlankGradleExtension, + ): String { fun Boolean.toInt() = if (this) 1 else 0 if (base.projectId.orNull == null) { - check(base.serviceAccountCredentials.isPresent) { "ServiceAccountCredentials in fladle extension not set. https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials" } + check(base.serviceAccountCredentials.isPresent) { + "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 = if (result > 1) { - "Only one of instrumentationApk file, roboScript file, and robo directives must be specified." - } else { - "Must specify either a instrumentationApk file or a roboScript file or a robo directive." - } + val prefix = + if (result > 1) { + "Only one of instrumentationApk file, roboScript file, and robo directives must be specified." + } else { + "Must specify either a instrumentationApk file or a roboScript file or a robo directive." + } """ $prefix instrumentationApk=${config.instrumentationApk.orNull} @@ -43,114 +51,118 @@ internal class YamlWriter { } } - internal fun writeFlankProperties(config: FladleConfig): String = buildString { - appendLine("flank:") + internal fun writeFlankProperties(config: FladleConfig): String = + buildString { + appendLine("flank:") - // Fladle will fail in configuration phase if both maxTestShards and testShards are present - appendProperty(config.maxTestShards, name = "max-test-shards") - appendProperty(config.testShards, name = "max-test-shards") + // Fladle will fail in configuration phase if both maxTestShards and testShards are present + appendProperty(config.maxTestShards, name = "max-test-shards") + appendProperty(config.testShards, name = "max-test-shards") - appendProperty(config.shardTime, name = "shard-time") - appendProperty(config.repeatTests, name = "num-test-runs") - appendProperty(config.smartFlankGcsPath, name = "smart-flank-gcs-path") - appendProperty(config.projectId, name = "project") - appendProperty(config.keepFilePath, name = "keep-file-path") - appendListProperty(config.filesToDownload, name = "files-to-download") { appendLine(" - $it") } - if (!config.sanityRobo.get()) { + appendProperty(config.shardTime, name = "shard-time") + appendProperty(config.repeatTests, name = "num-test-runs") + appendProperty(config.smartFlankGcsPath, name = "smart-flank-gcs-path") + appendProperty(config.projectId, name = "project") + appendProperty(config.keepFilePath, name = "keep-file-path") + appendListProperty(config.filesToDownload, name = "files-to-download") { appendLine(" - $it") } + if (!config.sanityRobo.get()) { + appendListProperty( + config.additionalTestApks, + name = "additional-app-test-apks", + ) { appendLine(" $it") } + } + appendProperty(config.runTimeout, name = "run-timeout") + appendProperty(config.ignoreFailedTests, name = "ignore-failed-tests") + appendProperty(config.disableSharding, name = "disable-sharding") + appendProperty(config.smartFlankDisableUpload, name = "smart-flank-disable-upload") + appendProperty(config.localResultsDir, name = "local-result-dir") appendListProperty( - config.additionalTestApks, - name = "additional-app-test-apks" - ) { appendLine(" $it") } - } - appendProperty(config.runTimeout, name = "run-timeout") - appendProperty(config.ignoreFailedTests, name = "ignore-failed-tests") - appendProperty(config.disableSharding, name = "disable-sharding") - appendProperty(config.smartFlankDisableUpload, name = "smart-flank-disable-upload") - appendProperty(config.localResultsDir, name = "local-result-dir") - appendListProperty( - config.testTargetsAlwaysRun, - name = "test-targets-always-run" - ) { appendLine(" - class $it") } - appendProperty(config.legacyJunitResult, name = "legacy-junit-result") - appendProperty(config.fullJunitResult, name = "full-junit-result") - appendProperty(config.outputStyle, name = "output-style") - appendProperty(config.defaultTestTime, name = "default-test-time") - appendProperty(config.defaultClassTestTime, name = "default-class-test-time") - appendProperty( - config.useAverageTestTimeForNewTests, - name = "use-average-test-time-for-new-tests" - ) - appendProperty(config.disableResultsUpload, name = "disable-results-upload") - appendListProperty(config.testTargetsForShard, name = "test-targets-for-shard") { - appendLine(" - $it") + config.testTargetsAlwaysRun, + name = "test-targets-always-run", + ) { appendLine(" - class $it") } + appendProperty(config.legacyJunitResult, name = "legacy-junit-result") + appendProperty(config.fullJunitResult, name = "full-junit-result") + appendProperty(config.outputStyle, name = "output-style") + appendProperty(config.defaultTestTime, name = "default-test-time") + appendProperty(config.defaultClassTestTime, name = "default-class-test-time") + appendProperty( + config.useAverageTestTimeForNewTests, + name = "use-average-test-time-for-new-tests", + ) + appendProperty(config.disableResultsUpload, name = "disable-results-upload") + appendListProperty(config.testTargetsForShard, name = "test-targets-for-shard") { + appendLine(" - $it") + } + appendAdditionalProperty(config.additionalFlankOptions) } - appendAdditionalProperty(config.additionalFlankOptions) - } - internal fun writeAdditionalProperties(config: FladleConfig): String = buildString { - appendProperty(config.useOrchestrator, name = "use-orchestrator") - appendProperty(config.autoGoogleLogin, name = "auto-google-login") - appendProperty(config.recordVideo, name = "record-video") - appendProperty(config.performanceMetrics, name = "performance-metrics") - appendProperty(config.testTimeout, name = "timeout") - if (config.async.isPresent && config.async.get()) { - appendProperty(config.async, name = "async") - } - appendProperty(config.resultsHistoryName, name = "results-history-name") - appendProperty(config.resultsBucket, name = "results-bucket") - appendMapProperty(config.environmentVariables, name = "environment-variables") { - appendLine(" ${it.key}: ${it.value}") - } - appendListProperty(config.testTargets, name = "test-targets") { appendLine(" - $it") } - appendListProperty(config.directoriesToPull, name = "directories-to-pull") { appendLine(" - $it") } - appendProperty(config.flakyTestAttempts, name = "num-flaky-test-attempts") - appendProperty(config.resultsDir, name = "results-dir") - appendProperty(config.testRunnerClass, name = "test-runner-class") - appendProperty(config.numUniformShards, name = "num-uniform-shards") - appendMapProperty(config.clientDetails, name = "client-details") { appendLine(" ${it.key}: ${it.value}") } - appendMapProperty(config.otherFiles, name = "other-files") { appendLine(" ${it.key}: ${it.value}") } - appendProperty(config.networkProfile, name = "network-profile") - if (!config.sanityRobo.get()) { - if (config.roboScript.hasValue) { - appendProperty(config.roboScript, name = "robo-script") - } else { - appendListProperty(config.roboDirectives, name = "robo-directives") { - val value = it.getOrElse(2) { "" } - .let { stringValue -> if (stringValue.isBlank()) "\"\"" else stringValue } - appendLine(" ${it[0]}:${it[1]}: $value") + internal fun writeAdditionalProperties(config: FladleConfig): String = + buildString { + appendProperty(config.useOrchestrator, name = "use-orchestrator") + appendProperty(config.autoGoogleLogin, name = "auto-google-login") + appendProperty(config.recordVideo, name = "record-video") + appendProperty(config.performanceMetrics, name = "performance-metrics") + appendProperty(config.testTimeout, name = "timeout") + if (config.async.isPresent && config.async.get()) { + appendProperty(config.async, name = "async") + } + appendProperty(config.resultsHistoryName, name = "results-history-name") + appendProperty(config.resultsBucket, name = "results-bucket") + appendMapProperty(config.environmentVariables, name = "environment-variables") { + appendLine(" ${it.key}: ${it.value}") + } + appendListProperty(config.testTargets, name = "test-targets") { appendLine(" - $it") } + appendListProperty(config.directoriesToPull, name = "directories-to-pull") { appendLine(" - $it") } + appendProperty(config.flakyTestAttempts, name = "num-flaky-test-attempts") + appendProperty(config.resultsDir, name = "results-dir") + appendProperty(config.testRunnerClass, name = "test-runner-class") + appendProperty(config.numUniformShards, name = "num-uniform-shards") + appendMapProperty(config.clientDetails, name = "client-details") { appendLine(" ${it.key}: ${it.value}") } + appendMapProperty(config.otherFiles, name = "other-files") { appendLine(" ${it.key}: ${it.value}") } + appendProperty(config.networkProfile, name = "network-profile") + if (!config.sanityRobo.get()) { + if (config.roboScript.hasValue) { + appendProperty(config.roboScript, name = "robo-script") + } else { + appendListProperty(config.roboDirectives, name = "robo-directives") { + val value = + it.getOrElse(2) { "" } + .let { stringValue -> if (stringValue.isBlank()) "\"\"" else stringValue } + appendLine(" ${it[0]}:${it[1]}: $value") + } } } + appendListProperty(config.additionalApks, name = "additional-apks") { appendLine(" - $it") } + appendProperty(config.grantPermissions, name = "grant-permissions") + appendProperty(config.type, name = "type") + appendListProperty(config.scenarioLabels, name = "scenario-labels") { appendLine(" - $it") } + appendListProperty(config.scenarioNumbers, name = "scenario-numbers") { appendLine(" - $it") } + appendListProperty(config.obbFiles, name = "obb-files") { appendLine(" - $it") } + appendListProperty(config.obbNames, name = "obb-names") { appendLine(" - $it") } + appendListProperty(config.testTargetsForShard, name = "test-targets-for-shard") { appendLine(" - $it") } + appendProperty(config.failFast, name = "fail-fast") + appendAdditionalProperty(config.additionalGcloudOptions) } - appendListProperty(config.additionalApks, name = "additional-apks") { appendLine(" - $it") } - appendProperty(config.grantPermissions, name = "grant-permissions") - appendProperty(config.type, name = "type") - appendListProperty(config.scenarioLabels, name = "scenario-labels") { appendLine(" - $it") } - appendListProperty(config.scenarioNumbers, name = "scenario-numbers") { appendLine(" - $it") } - appendListProperty(config.obbFiles, name = "obb-files") { appendLine(" - $it") } - appendListProperty(config.obbNames, name = "obb-names") { appendLine(" - $it") } - appendListProperty(config.testTargetsForShard, name = "test-targets-for-shard") { appendLine(" - $it") } - appendProperty(config.failFast, name = "fail-fast") - appendAdditionalProperty(config.additionalGcloudOptions) - } @VisibleForTesting - internal fun createDeviceString(devices: List>): String = buildString { - appendLine(" device:") - for (device in devices) { - if (device["model"] == null) throw RequiredDeviceKeyMissingException("model") - val model = device["model"] - if (device["version"] == null) throw RequiredDeviceKeyMissingException("version") - val version = device["version"] - val orientation = device["orientation"] - val locale = device["locale"] - appendLine(" - model: $model") - appendLine(" version: $version") - orientation?.let { - appendLine(" orientation: $it") - } - locale?.let { - appendLine(" locale: $it") + internal fun createDeviceString(devices: List>): String = + buildString { + appendLine(" device:") + for (device in devices) { + if (device["model"] == null) throw RequiredDeviceKeyMissingException("model") + val model = device["model"] + if (device["version"] == null) throw RequiredDeviceKeyMissingException("version") + val version = device["version"] + val orientation = device["orientation"] + val locale = device["locale"] + appendLine(" - model: $model") + appendLine(" version: $version") + orientation?.let { + appendLine(" orientation: $it") + } + locale?.let { + appendLine(" locale: $it") + } } } - } } diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/validation/ValidateExclusionUsage.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/validation/ValidateExclusionUsage.kt index 1db0b061..c60daf31 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/validation/ValidateExclusionUsage.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/validation/ValidateExclusionUsage.kt @@ -3,9 +3,10 @@ package com.osacky.flank.gradle.validation import com.osacky.flank.gradle.FladleConfig fun checkForExclusionUsage(config: FladleConfig) { - val usersProperties = config - .getPresentProperties() - .map { it.name } + val usersProperties = + config + .getPresentProperties() + .map { it.name } exclusions.forEach { if (usersProperties.contains(it.first) && usersProperties.contains(it.second)) { @@ -14,8 +15,9 @@ fun checkForExclusionUsage(config: FladleConfig) { } } -private val exclusions = listOf( - "testShards" to "maxTestShards", - "testShards" to "numUniformShards", - "maxTestShards" to "numUniformShards" -) +private val exclusions = + listOf( + "testShards" to "maxTestShards", + "testShards" to "numUniformShards", + "maxTestShards" to "numUniformShards", + ) diff --git a/fladle-plugin/src/main/java/com/osacky/flank/gradle/validation/ValidateOptions.kt b/fladle-plugin/src/main/java/com/osacky/flank/gradle/validation/ValidateOptions.kt index 5ba750d3..4de6a103 100644 --- a/fladle-plugin/src/main/java/com/osacky/flank/gradle/validation/ValidateOptions.kt +++ b/fladle-plugin/src/main/java/com/osacky/flank/gradle/validation/ValidateOptions.kt @@ -5,24 +5,32 @@ import com.osacky.flank.gradle.FlankGradleExtension.Companion.FLANK_VERSION import org.gradle.util.VersionNumber import kotlin.reflect.full.memberProperties -fun validateOptionsUsed(config: FladleConfig, flank: String) { +fun validateOptionsUsed( + config: FladleConfig, + flank: String, +) { // if using snapshot version default to the latest known version of flank for validation checks val configFlankVersion = if (flank.toLowerCase().endsWith("snapshot")) FLANK_VERSION.toVersion() else flank.toVersion() config.getPresentProperties() .mapNotNull { property -> properties[property.name]?.let { property to it } } .forEach { (property, version) -> - if (version > configFlankVersion) throw IllegalStateException("Option ${property.name} is available since flank $version, which is higher than used $configFlankVersion") + if (version > configFlankVersion) { + throw IllegalStateException( + "Option ${property.name} is available since flank $version, which is higher than used $configFlankVersion", + ) + } } } private fun String.toVersion() = VersionNumber.parse(this) -private val properties = FladleConfig::class.memberProperties - .asSequence() - .map { it to it.getter.annotations } - // we also need to exclude properties with default values to preserve backward compatibility - // to be fixed - .filter { it.second.any { annotation -> annotation is SinceFlank && !annotation.hasDefaultValue } } - .map { it.first.name to it.second.filterIsInstance().first().version.toVersion() } - .toMap() +private val properties = + FladleConfig::class.memberProperties + .asSequence() + .map { it to it.getter.annotations } + // we also need to exclude properties with default values to preserve backward compatibility + // to be fixed + .filter { it.second.any { annotation -> annotation is SinceFlank && !annotation.hasDefaultValue } } + .map { it.first.name to it.second.filterIsInstance().first().version.toVersion() } + .toMap() diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/MultipleConfigsTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/MultipleConfigsTest.kt index 2c2884cc..03eb0ee3 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/MultipleConfigsTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/MultipleConfigsTest.kt @@ -33,16 +33,17 @@ class MultipleConfigsTest { | } | } |} - """.trimMargin() + """.trimMargin(), ) testProjectRoot.newFile("flank-gradle-service.json").writeText("{}") - val result = GradleRunner.create() - .withPluginClasspath() - .withArguments("writeConfigPropsOrange", "--stacktrace") - .forwardOutput() - .withProjectDir(testProjectRoot.root) - .build() + val result = + GradleRunner.create() + .withPluginClasspath() + .withArguments("writeConfigPropsOrange", "--stacktrace") + .forwardOutput() + .withProjectDir(testProjectRoot.root) + .build() assertThat(result.output).contains("SUCCESS") @@ -71,15 +72,16 @@ class MultipleConfigsTest { | disable-sharding: false | smart-flank-disable-upload: false | local-result-dir: overrideDir - """.trimMargin() + """.trimMargin(), ) - val regularConfig = GradleRunner.create() - .withPluginClasspath() - .withArguments("writeConfigProps") - .forwardOutput() - .withProjectDir(testProjectRoot.root) - .build() + val regularConfig = + GradleRunner.create() + .withPluginClasspath() + .withArguments("writeConfigProps") + .forwardOutput() + .withProjectDir(testProjectRoot.root) + .build() assertThat(regularConfig.output).contains("SUCCESS") @@ -108,7 +110,7 @@ class MultipleConfigsTest { | disable-sharding: false | smart-flank-disable-upload: false | local-result-dir: defaultDir - """.trimMargin() + """.trimMargin(), ) } } 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 11780e4b..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 @@ -10,7 +10,6 @@ import org.junit.Before import org.junit.Test class YamlWriterTest { - private val yamlWriter = YamlWriter() private lateinit var project: Project @@ -22,9 +21,10 @@ class YamlWriterTest { @Test fun testWriteSingleDevice() { - val devices = listOf( - mapOf("model" to "NexusLowRes", "version" to "28") - ) + val devices = + listOf( + mapOf("model" to "NexusLowRes", "version" to "28"), + ) val deviceString = yamlWriter.createDeviceString(devices) val expected = """ @@ -38,10 +38,11 @@ class YamlWriterTest { @Test fun testWriteTwoDevices() { - val devices = listOf( - mapOf("model" to "NexusLowRes", "version" to "28"), - mapOf("model" to "Nexus5", "version" to "23") - ) + val devices = + listOf( + mapOf("model" to "NexusLowRes", "version" to "28"), + mapOf("model" to "Nexus5", "version" to "23"), + ) val deviceString = yamlWriter.createDeviceString(devices) val expected = """ @@ -57,10 +58,11 @@ class YamlWriterTest { @Test fun testWriteTwoCustomDevices() { - val devices = listOf( - mapOf("model" to "NexusLowRes", "version" to "23", "orientation" to "portrait"), - mapOf("model" to "Nexus5", "orientation" to "landscape", "version" to "28") - ) + val devices = + listOf( + mapOf("model" to "NexusLowRes", "version" to "23", "orientation" to "portrait"), + mapOf("model" to "Nexus5", "orientation" to "landscape", "version" to "28"), + ) val deviceString = yamlWriter.createDeviceString(devices) val expected = """ @@ -78,10 +80,11 @@ class YamlWriterTest { @Test fun testWriteTwoCustomDevicesWithLocale() { - val devices = listOf( - mapOf("model" to "NexusLowRes", "version" to "23", "orientation" to "portrait", "locale" to "en"), - mapOf("model" to "Nexus5", "orientation" to "landscape", "locale" to "es_ES", "version" to "28") - ) + val devices = + listOf( + mapOf("model" to "NexusLowRes", "version" to "23", "orientation" to "portrait", "locale" to "en"), + mapOf("model" to "Nexus5", "orientation" to "landscape", "locale" to "es_ES", "version" to "28"), + ) val deviceString = yamlWriter.createDeviceString(devices) val expected = """ @@ -101,9 +104,10 @@ class YamlWriterTest { @Test fun testThrowsExceptionWhenMissingModelKeyInDevice() { - val devices = listOf( - mapOf("version" to "23", "orientation" to "portrait", "locale" to "en") - ) + val devices = + listOf( + mapOf("version" to "23", "orientation" to "portrait", "locale" to "en"), + ) try { yamlWriter.createDeviceString(devices) fail() @@ -114,9 +118,10 @@ class YamlWriterTest { @Test fun testThrowsExceptionWhenMissingVersionKeyInDevice() { - val devices = listOf( - mapOf("model" to "NexusLowRes", "orientation" to "portrait", "locale" to "en") - ) + val devices = + listOf( + mapOf("model" to "NexusLowRes", "orientation" to "portrait", "locale" to "en"), + ) try { yamlWriter.createDeviceString(devices) fail() @@ -133,54 +138,57 @@ class YamlWriterTest { fail() } catch (expected: IllegalStateException) { assertEquals( - "ServiceAccountCredentials in fladle extension not set. https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials", - expected.message + "ServiceAccountCredentials in fladle extension not set." + + "https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials", + expected.message, ) } } @Test fun verifyMissingServiceDoesntThrowErrorIfProjectIdSet() { - val extension = emptyExtension { - projectId.set("set") - debugApk.set("path") - instrumentationApk.set("instrument") - } + val extension = + emptyExtension { + projectId.set("set") + debugApk.set("path") + instrumentationApk.set("instrument") + } val yaml = yamlWriter.createConfigProps(extension, extension) assertThat(yaml).isEqualTo( """ - gcloud: - app: path - test: instrument - device: - - model: NexusLowRes - version: 28 - - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - num-flaky-test-attempts: 0 - - flank: - project: set - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - 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. + gcloud: + app: path + test: instrument + device: + - model: NexusLowRes + version: 28 + + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + num-flaky-test-attempts: 0 + + flank: + project: set + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent() + '\n', ) } @Test fun verifyDebugApkThrowsError() { - val extension = emptyExtension { - serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) - } + val extension = + emptyExtension { + serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) + } try { yamlWriter.createConfigProps(extension, extension) fail() @@ -191,10 +199,11 @@ class YamlWriterTest { @Test fun verifyNoInstrumentationApkThrowsError() { - val extension = emptyExtension { - serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) - debugApk.set("path") - } + val extension = + emptyExtension { + serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) + debugApk.set("path") + } try { yamlWriter.createConfigProps(extension, extension) fail() @@ -205,19 +214,20 @@ class YamlWriterTest { instrumentationApk=null roboScript=null roboDirective=[] - """.trimIndent() + """.trimIndent(), ) } } @Test fun verifyInstrumentationApkAndRoboscriptThrowsError() { - val extension = emptyExtension { - serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) - debugApk.set("path") - instrumentationApk.set("build/test/*.apk") - roboScript.set("foo") - } + val extension = + emptyExtension { + serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) + debugApk.set("path") + instrumentationApk.set("build/test/*.apk") + roboScript.set("foo") + } try { yamlWriter.createConfigProps(extension, extension) fail() @@ -228,19 +238,20 @@ class YamlWriterTest { instrumentationApk=build/test/*.apk roboScript=foo roboDirective=[] - """.trimIndent() + """.trimIndent(), ) } } @Test fun verifyInstrumentationApkAndRobodirectivesThrowsError() { - val extension = emptyExtension { - serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) - debugApk.set("path") - instrumentationApk.set("build/test/*.apk") - roboDirectives.add(listOf("click", "resource_id")) - } + val extension = + emptyExtension { + serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) + debugApk.set("path") + instrumentationApk.set("build/test/*.apk") + roboDirectives.add(listOf("click", "resource_id")) + } try { yamlWriter.createConfigProps(extension, extension) fail() @@ -251,19 +262,20 @@ class YamlWriterTest { instrumentationApk=build/test/*.apk roboScript=null roboDirective=[[click, resource_id]] - """.trimIndent() + """.trimIndent(), ) } } @Test fun verifyRoboscriptAndRobodirectivesThrowsError() { - val extension = emptyExtension { - serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) - debugApk.set("path") - roboScript.set("foo") - roboDirectives.add(listOf("click", "resource_id")) - } + val extension = + emptyExtension { + serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) + debugApk.set("path") + roboScript.set("foo") + roboDirectives.add(listOf("click", "resource_id")) + } try { yamlWriter.createConfigProps(extension, extension) fail() @@ -274,20 +286,21 @@ class YamlWriterTest { instrumentationApk=null roboScript=foo roboDirective=[[click, resource_id]] - """.trimIndent() + """.trimIndent(), ) } } @Test fun verifyInstrumentationApkAndRoboscriptAndRobodirectivesThrowsError() { - val extension = emptyExtension { - serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) - debugApk.set("path") - instrumentationApk.set("build/test/*.apk") - roboScript.set("foo") - roboDirectives.add(listOf("click", "resource_id")) - } + val extension = + emptyExtension { + serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) + debugApk.set("path") + instrumentationApk.set("build/test/*.apk") + roboScript.set("foo") + roboDirectives.add(listOf("click", "resource_id")) + } try { yamlWriter.createConfigProps(extension, extension) fail() @@ -298,88 +311,91 @@ class YamlWriterTest { instrumentationApk=build/test/*.apk roboScript=foo roboDirective=[[click, resource_id]] - """.trimIndent() + """.trimIndent(), ) } } @Test fun verifyOnlyWithRoboscriptWorks() { - val extension = emptyExtension { - serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) - debugApk.set("path") - roboScript.set("foo") - } + val extension = + emptyExtension { + serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) + debugApk.set("path") + roboScript.set("foo") + } val configProps = yamlWriter.createConfigProps(extension, extension) assertThat(configProps).isEqualTo( """ - gcloud: - app: path - device: - - model: NexusLowRes - version: 28 + gcloud: + app: path + device: + - model: NexusLowRes + version: 28 - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - num-flaky-test-attempts: 0 - robo-script: foo - - flank: - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + '\n' + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + num-flaky-test-attempts: 0 + robo-script: foo + + flank: + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent() + '\n', ) } @Test fun verifyOnlyWithRobodirectivesWorks() { - val extension = emptyExtension { - serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) - debugApk.set("path") - roboDirectives.add(listOf("click", "resource_id")) - } + val extension = + emptyExtension { + serviceAccountCredentials.set(project.layout.projectDirectory.file("fake.json")) + debugApk.set("path") + roboDirectives.add(listOf("click", "resource_id")) + } val configProps = yamlWriter.createConfigProps(extension, extension) assertThat(configProps).isEqualTo( """ - gcloud: - app: path - device: - - model: NexusLowRes - version: 28 + gcloud: + app: path + device: + - model: NexusLowRes + version: 28 - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - num-flaky-test-attempts: 0 - robo-directives: - click:resource_id: "" - - flank: - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + '\n' + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + num-flaky-test-attempts: 0 + robo-directives: + click:resource_id: "" + + flank: + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent() + '\n', ) } @Test fun writeNoTestShards() { - val extension = emptyExtension { - } + val extension = + emptyExtension { + } assertEquals( "flank:\n" + @@ -390,15 +406,16 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeProjectIdOption() { - val extension = emptyExtension { - projectId.set("foo") - } + val extension = + emptyExtension { + projectId.set("foo") + } assertEquals( "flank:\n" + @@ -410,15 +427,16 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeTestShardOption() { - val extension = emptyExtension { - testShards.set(5) - } + val extension = + emptyExtension { + testShards.set(5) + } assertEquals( "flank:\n" + @@ -430,15 +448,16 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeShardTimeOption() { - val extension = emptyExtension { - shardTime.set(120) - } + val extension = + emptyExtension { + shardTime.set(120) + } assertEquals( "flank:\n" + @@ -450,7 +469,7 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @@ -467,15 +486,16 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeTestRepeats() { - val extension = emptyExtension { - repeatTests.set(5) - } + val extension = + emptyExtension { + repeatTests.set(5) + } assertEquals( "flank:\n" + @@ -487,16 +507,17 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeTestShardAndRepeatOption() { - val extension = emptyExtension { - testShards.set(5) - repeatTests.set(2) - } + val extension = + emptyExtension { + testShards.set(5) + repeatTests.set(2) + } assertEquals( "flank:\n" + @@ -509,15 +530,16 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeResultsHistoryName() { - val extension = emptyExtension { - resultsHistoryName.set("androidtest") - } + val extension = + emptyExtension { + resultsHistoryName.set("androidtest") + } assertEquals( " use-orchestrator: false\n" + @@ -527,15 +549,16 @@ class YamlWriterTest { " timeout: 15m\n" + " results-history-name: androidtest\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeResultsBucket() { - val extension = emptyExtension { - resultsBucket.set("fake-project.appspot.com") - } + val extension = + emptyExtension { + resultsBucket.set("fake-project.appspot.com") + } assertEquals( " use-orchestrator: false\n" + @@ -545,15 +568,16 @@ class YamlWriterTest { " timeout: 15m\n" + " results-bucket: fake-project.appspot.com\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeResultsDir() { - val extension = emptyExtension { - resultsDir.set("resultsGoHere") - } + val extension = + emptyExtension { + resultsDir.set("resultsGoHere") + } assertEquals( " use-orchestrator: false\n" + @@ -563,20 +587,21 @@ class YamlWriterTest { " timeout: 15m\n" + " num-flaky-test-attempts: 0\n" + " results-dir: resultsGoHere\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeTestTargetsAndResultsHistoryName() { - val extension = emptyExtension { - resultsHistoryName.set("androidtest") - testTargets.set( - project.provider { - listOf("class com.example.Foo") - } - ) - } + val extension = + emptyExtension { + resultsHistoryName.set("androidtest") + testTargets.set( + project.provider { + listOf("class com.example.Foo") + }, + ) + } assertEquals( " use-orchestrator: false\n" + @@ -588,7 +613,7 @@ class YamlWriterTest { " test-targets:\n" + " - class com.example.Foo\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @@ -603,19 +628,20 @@ class YamlWriterTest { " performance-metrics: true\n" + " timeout: 15m\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeSingleTestTargets() { - val extension = emptyExtension { - testTargets.set( - project.provider { - listOf("class com.example.Foo#testThing") - } - ) - } + val extension = + emptyExtension { + testTargets.set( + project.provider { + listOf("class com.example.Foo#testThing") + }, + ) + } assertEquals( " use-orchestrator: false\n" + @@ -626,19 +652,20 @@ class YamlWriterTest { " test-targets:\n" + " - class com.example.Foo#testThing\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeMultipleTestTargets() { - val extension = emptyExtension { - testTargets.set( - project.provider { - listOf("class com.example.Foo#testThing", "class com.example.Foo#testThing2") - } - ) - } + val extension = + emptyExtension { + testTargets.set( + project.provider { + listOf("class com.example.Foo#testThing", "class com.example.Foo#testThing2") + }, + ) + } assertEquals( " use-orchestrator: false\n" + @@ -650,15 +677,16 @@ class YamlWriterTest { " - class com.example.Foo#testThing\n" + " - class com.example.Foo#testThing2\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeSmartFlankGcsPath() { - val extension = emptyExtension { - smartFlankGcsPath.set("gs://test/fakepath.xml") - } + val extension = + emptyExtension { + smartFlankGcsPath.set("gs://test/fakepath.xml") + } assertEquals( "flank:\n" + @@ -670,19 +698,20 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeNoDirectoriesToPull() { - val extension = emptyExtension { - directoriesToPull.set( - project.provider { - emptyList() - } - ) - } + val extension = + emptyExtension { + directoriesToPull.set( + project.provider { + emptyList() + }, + ) + } assertEquals( " use-orchestrator: false\n" + @@ -691,19 +720,20 @@ class YamlWriterTest { " performance-metrics: true\n" + " timeout: 15m\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeSingleDirectoriesToPull() { - val extension = emptyExtension { - directoriesToPull.set( - project.provider { - listOf("/sdcard/screenshots") - } - ) - } + val extension = + emptyExtension { + directoriesToPull.set( + project.provider { + listOf("/sdcard/screenshots") + }, + ) + } assertEquals( " use-orchestrator: false\n" + @@ -714,19 +744,20 @@ class YamlWriterTest { " directories-to-pull:\n" + " - /sdcard/screenshots\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeMultipleDirectoriesToPull() { - val extension = emptyExtension { - directoriesToPull.set( - project.provider { - listOf("/sdcard/screenshots", "/sdcard/reports") - } - ) - } + val extension = + emptyExtension { + directoriesToPull.set( + project.provider { + listOf("/sdcard/screenshots", "/sdcard/reports") + }, + ) + } assertEquals( " use-orchestrator: false\n" + @@ -738,19 +769,20 @@ class YamlWriterTest { " - /sdcard/screenshots\n" + " - /sdcard/reports\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeNoFilesToDownload() { - val extension = emptyExtension { - filesToDownload.set( - project.provider { - emptyList() - } - ) - } + val extension = + emptyExtension { + filesToDownload.set( + project.provider { + emptyList() + }, + ) + } assertEquals( "flank:\n" + @@ -761,19 +793,20 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeSingleFilesToDownload() { - val extension = emptyExtension { - filesToDownload.set( - project.provider { - listOf(".*/screenshots/.*") - } - ) - } + val extension = + emptyExtension { + filesToDownload.set( + project.provider { + listOf(".*/screenshots/.*") + }, + ) + } assertEquals( "flank:\n" + @@ -786,19 +819,20 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeMultipleFilesToDownload() { - val extension = emptyExtension { - filesToDownload.set( - project.provider { - listOf(".*/screenshots/.*", ".*/reports/.*") - } - ) - } + val extension = + emptyExtension { + filesToDownload.set( + project.provider { + listOf(".*/screenshots/.*", ".*/reports/.*") + }, + ) + } assertEquals( "flank:\n" + @@ -812,21 +846,22 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeSingleEnvironmentVariables() { - val extension = emptyExtension { - environmentVariables.set( - project.provider { - mapOf( - "listener" to "com.osacky.flank.sample.Listener" - ) - } - ) - } + val extension = + emptyExtension { + environmentVariables.set( + project.provider { + mapOf( + "listener" to "com.osacky.flank.sample.Listener", + ) + }, + ) + } assertEquals( " use-orchestrator: false\n" + @@ -837,22 +872,23 @@ class YamlWriterTest { " environment-variables:\n" + " listener: com.osacky.flank.sample.Listener\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeMultipleEnvironmentVariables() { - val extension = emptyExtension { - environmentVariables.set( - project.provider { - mapOf( - "clearPackageData" to "true", - "listener" to "com.osacky.flank.sample.Listener" - ) - } - ) - } + val extension = + emptyExtension { + environmentVariables.set( + project.provider { + mapOf( + "clearPackageData" to "true", + "listener" to "com.osacky.flank.sample.Listener", + ) + }, + ) + } assertEquals( " use-orchestrator: false\n" + @@ -864,19 +900,20 @@ class YamlWriterTest { " clearPackageData: true\n" + " listener: com.osacky.flank.sample.Listener\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @Test fun writeDefaultProperties() { - val extension = emptyExtension { - useOrchestrator.set(true) - autoGoogleLogin.set(true) - recordVideo.set(false) - performanceMetrics.set(false) - testTimeout.set("45m") - } + val extension = + emptyExtension { + useOrchestrator.set(true) + autoGoogleLogin.set(true) + recordVideo.set(false) + performanceMetrics.set(false) + testTimeout.set("45m") + } assertEquals( " use-orchestrator: true\n" + @@ -885,7 +922,7 @@ class YamlWriterTest { " performance-metrics: false\n" + " timeout: 45m\n" + " num-flaky-test-attempts: 0\n", - yamlWriter.writeAdditionalProperties(extension) + yamlWriter.writeAdditionalProperties(extension), ) } @@ -902,15 +939,16 @@ class YamlWriterTest { " legacy-junit-result: false\n" + " full-junit-result: false\n" + " output-style: single\n", - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ) } @Test fun writeKeepFilePath() { - val extension = emptyExtension { - keepFilePath.set(true) - } + val extension = + emptyExtension { + keepFilePath.set(true) + } assertThat(yamlWriter.writeFlankProperties(extension)) .isEqualTo( @@ -921,49 +959,50 @@ class YamlWriterTest { " smart-flank-disable-upload: false\n" + " legacy-junit-result: false\n" + " full-junit-result: false\n" + - " output-style: single\n" + " output-style: single\n", ) } @Test fun writeAdditionalTestApks() { - val extension = emptyExtension { - debugApk.set("../orange/build/output/app.apk") - instrumentationApk.set("../orange/build/output/app-test.apk") - additionalTestApks.set( - project.provider { - listOf( - "- app: ../orange/build/output/app.apk", - " test: ../orange/build/output/app-test2.apk", - "- app: ../bob/build/output/app.apk", - " test: ../bob/build/output/app-test.apk", - "- test: ../bob/build/output/app-test2.apk", - "- test: ../bob/build/output/app-test3.apk" - ) - } - ) - } + val extension = + emptyExtension { + debugApk.set("../orange/build/output/app.apk") + instrumentationApk.set("../orange/build/output/app-test.apk") + additionalTestApks.set( + project.provider { + listOf( + "- app: ../orange/build/output/app.apk", + " test: ../orange/build/output/app-test2.apk", + "- app: ../bob/build/output/app.apk", + " test: ../bob/build/output/app-test.apk", + "- test: ../bob/build/output/app-test2.apk", + "- test: ../bob/build/output/app-test3.apk", + ) + }, + ) + } assertThat( - yamlWriter.writeFlankProperties(extension) + yamlWriter.writeFlankProperties(extension), ).isEqualTo( """ - flank: - keep-file-path: false - additional-app-test-apks: - - app: ../orange/build/output/app.apk - test: ../orange/build/output/app-test2.apk - - app: ../bob/build/output/app.apk - test: ../bob/build/output/app-test.apk - - test: ../bob/build/output/app-test2.apk - - test: ../bob/build/output/app-test3.apk - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + '\n' + flank: + keep-file-path: false + additional-app-test-apks: + - app: ../orange/build/output/app.apk + test: ../orange/build/output/app-test2.apk + - app: ../bob/build/output/app.apk + test: ../bob/build/output/app-test.apk + - test: ../bob/build/output/app-test2.apk + - test: ../bob/build/output/app-test3.apk + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent() + '\n', ) } @@ -986,12 +1025,12 @@ class YamlWriterTest { val expectedAdditional = """ - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - num-flaky-test-attempts: 0 + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + num-flaky-test-attempts: 0 """.trimIndent() assertEquals(expectedFlank, defaultFlankProperties) @@ -1000,72 +1039,80 @@ class YamlWriterTest { @Test fun writeRunTimeout() { - val extension = emptyExtension { - runTimeout.set("20m") - } + val extension = + emptyExtension { + runTimeout.set("20m") + } assertTrue(yamlWriter.writeFlankProperties(extension).contains(" run-timeout: 20m")) } @Test fun writeIgnoreFailedTests() { - val properties = emptyExtension { - ignoreFailedTests.set(true) - }.toFlankProperties() + val properties = + emptyExtension { + ignoreFailedTests.set(true) + }.toFlankProperties() assertTrue(properties.contains(" ignore-failed-tests: true")) } @Test fun writeDisableSharding() { - val properties = emptyExtension { - disableSharding.set(true) - }.toFlankProperties() + val properties = + emptyExtension { + disableSharding.set(true) + }.toFlankProperties() assertTrue(properties.contains(" disable-sharding: true")) } @Test fun writeSmartFlankDisableUpload() { - val properties = emptyExtension { - smartFlankDisableUpload.set(true) - }.toFlankProperties() + val properties = + emptyExtension { + smartFlankDisableUpload.set(true) + }.toFlankProperties() assertTrue(properties.contains(" smart-flank-disable-upload: true")) } @Test fun writeTestRunnerClass() { - val properties = emptyExtension { - testRunnerClass.set("any.class.Runner") - }.toAdditionalProperties() + val properties = + emptyExtension { + testRunnerClass.set("any.class.Runner") + }.toAdditionalProperties() assertTrue(properties.contains(" test-runner-class: any.class.Runner")) } @Test fun writeLocalResultsDir() { - val properties = emptyExtension { - localResultsDir.set("~/my/results/dir") - }.toFlankProperties() + val properties = + emptyExtension { + localResultsDir.set("~/my/results/dir") + }.toFlankProperties() assertTrue(properties.contains(" local-result-dir: ~/my/results/dir")) } @Test fun writeNumUniformShards() { - val properties = emptyExtension { - numUniformShards.set(20) - }.toAdditionalProperties() + val properties = + emptyExtension { + numUniformShards.set(20) + }.toAdditionalProperties() assertTrue(properties.contains(" num-uniform-shards: 20")) } @Test fun writeOutputStyle() { - val properties = emptyExtension { - outputStyle.set("anyString") - }.toFlankProperties() + val properties = + emptyExtension { + outputStyle.set("anyString") + }.toFlankProperties() assertTrue(properties.contains(" output-style: anyString")) } @@ -1079,9 +1126,10 @@ class YamlWriterTest { @Test fun writeLegacyJunitResult() { - val properties = emptyExtension { - legacyJunitResult.set(true) - }.toFlankProperties() + val properties = + emptyExtension { + legacyJunitResult.set(true) + }.toFlankProperties() assertTrue(properties.contains(" legacy-junit-result: true")) } @@ -1095,17 +1143,20 @@ class YamlWriterTest { @Test fun writeFullJunitResult() { - val properties = emptyExtension { - fullJunitResult.set(true) - }.toFlankProperties() + val properties = + emptyExtension { + fullJunitResult.set(true) + }.toFlankProperties() assertTrue(properties.contains(" full-junit-result: true")) } + @Test fun writeAsyncFlag() { - val properties = emptyExtension { - async.set(true) - }.toAdditionalProperties() + val properties = + emptyExtension { + async.set(true) + }.toAdditionalProperties() assertTrue(properties.contains(" async: true")) } @@ -1118,16 +1169,17 @@ class YamlWriterTest { @Test fun writeClientDetails() { - val properties = emptyExtension { - clientDetails.set( - project.provider { - mapOf( - "anyDetail1" to "anyValue1", - "anyDetail2" to "anyValue2" - ) - } - ) - }.toAdditionalProperties() + val properties = + emptyExtension { + clientDetails.set( + project.provider { + mapOf( + "anyDetail1" to "anyValue1", + "anyDetail2" to "anyValue2", + ) + }, + ) + }.toAdditionalProperties() assertTrue( properties.contains( @@ -1135,24 +1187,25 @@ class YamlWriterTest { | client-details: | anyDetail1: anyValue1 | anyDetail2: anyValue2 - """.trimMargin() - ) + """.trimMargin(), + ), ) } @Test fun writeTestTargetsAlwaysRun() { - val properties = emptyExtension { - testTargetsAlwaysRun.set( - project.provider { - listOf( - "com.example.FirstTests#test1", - "com.example.FirstTests#test2", - "com.example.FirstTests#test3" - ) - } - ) - }.toFlankProperties() + val properties = + emptyExtension { + testTargetsAlwaysRun.set( + project.provider { + listOf( + "com.example.FirstTests#test1", + "com.example.FirstTests#test2", + "com.example.FirstTests#test3", + ) + }, + ) + }.toFlankProperties() assertTrue( properties.contains( @@ -1161,23 +1214,24 @@ class YamlWriterTest { | - class com.example.FirstTests#test1 | - class com.example.FirstTests#test2 | - class com.example.FirstTests#test3 - """.trimMargin() - ) + """.trimMargin(), + ), ) } @Test fun writeOtherFiles() { - val properties = emptyExtension { - otherFiles.set( - project.provider { - mapOf( - "/example/path/test1" to "anyfile.txt", - "/example/path/test2" to "anyfile2.txt" - ) - } - ) - }.toAdditionalProperties() + val properties = + emptyExtension { + otherFiles.set( + project.provider { + mapOf( + "/example/path/test1" to "anyfile.txt", + "/example/path/test2" to "anyfile2.txt", + ) + }, + ) + }.toAdditionalProperties() assertTrue( properties.contains( @@ -1185,42 +1239,45 @@ class YamlWriterTest { | other-files: | /example/path/test1: anyfile.txt | /example/path/test2: anyfile2.txt - """.trimMargin() - ) + """.trimMargin(), + ), ) } @Test fun writeNetworkProfile() { - val properties = emptyExtension { - networkProfile.set("LTE") - }.toAdditionalProperties() + val properties = + emptyExtension { + networkProfile.set("LTE") + }.toAdditionalProperties() assertTrue(properties.contains(" network-profile: LTE")) } @Test fun writeRoboScript() { - val properties = emptyExtension { - roboScript.set("~/my/dir/with/script.json") - }.toAdditionalProperties() + val properties = + emptyExtension { + roboScript.set("~/my/dir/with/script.json") + }.toAdditionalProperties() assertTrue(properties.contains(" robo-script: ~/my/dir/with/script.json")) } @Test fun writeRoboDirectives() { - val properties = emptyExtension { - roboDirectives.set( - project.provider { - listOf( - listOf("click", "button3"), - listOf("ignore", "button1", ""), - listOf("text", "field1", "my common text") - ) - } - ) - }.toAdditionalProperties() + val properties = + emptyExtension { + roboDirectives.set( + project.provider { + listOf( + listOf("click", "button3"), + listOf("ignore", "button1", ""), + listOf("text", "field1", "my common text"), + ) + }, + ) + }.toAdditionalProperties() assertTrue( properties.contains( @@ -1229,130 +1286,140 @@ class YamlWriterTest { | click:button3: "" | ignore:button1: "" | text:field1: my common text - """.trimMargin() - ) + """.trimMargin(), + ), ) } @Test fun writeDefaultTestTime() { - val properties = emptyExtension { - defaultTestTime.set(240.5) - }.toFlankProperties() + val properties = + emptyExtension { + defaultTestTime.set(240.5) + }.toFlankProperties() assertThat(properties).contains("default-test-time: 240.5") } @Test fun writeDefaultClassTestTime() { - val properties = emptyExtension { - defaultClassTestTime.set(681.8) - }.toFlankProperties() + val properties = + emptyExtension { + defaultClassTestTime.set(681.8) + }.toFlankProperties() assertThat(properties).contains("default-class-test-time: 681.8") } @Test fun writeUseAverageTestTimeForNewTests() { - val properties = emptyExtension { - useAverageTestTimeForNewTests.set(true) - }.toFlankProperties() + val properties = + emptyExtension { + useAverageTestTimeForNewTests.set(true) + }.toFlankProperties() assertThat(properties).contains("use-average-test-time-for-new-tests: true") } @Test fun writeAdditionalApks() { - val properties = emptyExtension { - additionalApks.set( - project.provider { - listOf("gs://path/to/app1.apk", "localPath/to/app2.apk") - } - ) - }.toAdditionalProperties() + val properties = + emptyExtension { + additionalApks.set( + project.provider { + listOf("gs://path/to/app1.apk", "localPath/to/app2.apk") + }, + ) + }.toAdditionalProperties() assertThat(properties).contains( """ | additional-apks: | - gs://path/to/app1.apk | - localPath/to/app2.apk - """.trimMargin() + """.trimMargin(), ) } @Test fun writeDisableResultsUpload() { - val properties = emptyExtension { - disableResultsUpload.set(true) - }.toFlankProperties() + val properties = + emptyExtension { + disableResultsUpload.set(true) + }.toFlankProperties() assertThat(properties).contains("disable-results-upload: true") } @Test fun writeTestTargetsForShard() { - val properties = emptyExtension { - testTargetsForShard.addAll( - "class com.example.test_app.bar.BarInstrumentedTest", - "class com.example.test_app.foo.FooInstrumentedTest" - ) - }.toFlankProperties() + val properties = + emptyExtension { + testTargetsForShard.addAll( + "class com.example.test_app.bar.BarInstrumentedTest", + "class com.example.test_app.foo.FooInstrumentedTest", + ) + }.toFlankProperties() assertThat(properties).contains( """ | test-targets-for-shard: | - class com.example.test_app.bar.BarInstrumentedTest | - class com.example.test_app.foo.FooInstrumentedTest - """.trimMargin() + """.trimMargin(), ) } @Test fun writeGrantPermissions() { - val properties = emptyExtension { - grantPermissions.set("none") - }.toAdditionalProperties() + val properties = + emptyExtension { + grantPermissions.set("none") + }.toAdditionalProperties() assertThat(properties).contains("grant-permissions: none") } @Test fun writeType() { - val properties = emptyExtension { - type.set("game-loop") - }.toAdditionalProperties() + val properties = + emptyExtension { + type.set("game-loop") + }.toAdditionalProperties() assertThat(properties).contains("type: game-loop") } @Test fun writeScenarioLabels() { - val properties = emptyExtension { - scenarioLabels.set( - project.provider { - listOf("label1", "label2") - } - ) - }.toAdditionalProperties() + val properties = + emptyExtension { + scenarioLabels.set( + project.provider { + listOf("label1", "label2") + }, + ) + }.toAdditionalProperties() assertThat(properties).contains( """ | scenario-labels: | - label1 | - label2 - """.trimMargin() + """.trimMargin(), ) } @Test fun writeScenarioNumbers() { - val properties = emptyExtension { - scenarioNumbers.set( - project.provider { - listOf(1, 123, 543) - } - ) - }.toAdditionalProperties() + val properties = + emptyExtension { + scenarioNumbers.set( + project.provider { + listOf(1, 123, 543) + }, + ) + }.toAdditionalProperties() assertThat(properties).contains( """ @@ -1360,95 +1427,102 @@ class YamlWriterTest { | - 1 | - 123 | - 543 - """.trimMargin() + """.trimMargin(), ) } @Test fun writeObbFiles() { - val properties = emptyExtension { - obbFiles.set( - project.provider { - listOf( - "local/file/path/test1.obb", - "local/file/path/test2.obb" - ) - } - ) - }.toAdditionalProperties() + val properties = + emptyExtension { + obbFiles.set( + project.provider { + listOf( + "local/file/path/test1.obb", + "local/file/path/test2.obb", + ) + }, + ) + }.toAdditionalProperties() assertThat(properties).contains( """ | obb-files: | - local/file/path/test1.obb | - local/file/path/test2.obb - """.trimMargin() + """.trimMargin(), ) } @Test fun writeObbNames() { - val properties = emptyExtension { - obbNames.set( - project.provider { - listOf( - "patch.0300110.com.example.android.obb", - "patch.0300111.com.example.android.obb" - ) - } - ) - }.toAdditionalProperties() + val properties = + emptyExtension { + obbNames.set( + project.provider { + listOf( + "patch.0300110.com.example.android.obb", + "patch.0300111.com.example.android.obb", + ) + }, + ) + }.toAdditionalProperties() assertThat(properties).contains( """ | obb-names: | - patch.0300110.com.example.android.obb | - patch.0300111.com.example.android.obb - """.trimMargin() + """.trimMargin(), ) } @Test fun writeFailFast() { - val properties = emptyExtension { - failFast.set(true) - }.toAdditionalProperties() + val properties = + emptyExtension { + failFast.set(true) + }.toAdditionalProperties() assertThat(properties).contains("fail-fast: true") } @Test fun writeMaxTestShardOption() { - val properties = emptyExtension { - maxTestShards.set(8) - }.toFlankProperties() + val properties = + emptyExtension { + maxTestShards.set(8) + }.toFlankProperties() assertThat(properties).contains("max-test-shards: 8") } @Test fun writeSingleLineAdditionalFlankProperty() { - val properties = emptyExtension { - additionalFlankOptions.set("new_version_property: test") - }.toFlankProperties() + val properties = + emptyExtension { + additionalFlankOptions.set("new_version_property: test") + }.toFlankProperties() assertThat(properties).contains(" new_version_property: test") } @Test fun writeSingleLineAdditionalGcloudProperty() { - val properties = emptyExtension { - additionalGcloudOptions.set("new_version_property: test") - }.toAdditionalProperties() + val properties = + emptyExtension { + additionalGcloudOptions.set("new_version_property: test") + }.toAdditionalProperties() assertThat(properties).contains(" new_version_property: test") } @Test fun writeMultiLineAdditionalFlankProperies() { - val properties = emptyExtension { - additionalFlankOptions.set("new_version_property: test\nnew_version_property2: test2") - }.toFlankProperties() + val properties = + emptyExtension { + additionalFlankOptions.set("new_version_property: test\nnew_version_property2: test2") + }.toFlankProperties() assertThat(properties).contains(" new_version_property: test") assertThat(properties).contains(" new_version_property2: test2") @@ -1456,16 +1530,20 @@ class YamlWriterTest { @Test fun writeMultiLineAdditionalGcloudProperties() { - val properties = emptyExtension { - additionalGcloudOptions.set("new_version_property: test\nnew_version_property2: test2") - }.toAdditionalProperties() + val properties = + emptyExtension { + additionalGcloudOptions.set("new_version_property: test\nnew_version_property2: test2") + }.toAdditionalProperties() assertThat(properties).contains(" new_version_property: test") assertThat(properties).contains(" new_version_property2: test2") } private fun emptyExtension() = FlankGradleExtension(project.objects) + private fun emptyExtension(block: FlankGradleExtension.() -> Unit) = emptyExtension().apply(block) + private fun FlankGradleExtension.toFlankProperties() = yamlWriter.writeFlankProperties(this).trimIndent() + private fun FlankGradleExtension.toAdditionalProperties() = yamlWriter.writeAdditionalProperties(this) } diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/AndroidTestUtil.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/AndroidTestUtil.kt index 869f1fa9..a30daf45 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/AndroidTestUtil.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/AndroidTestUtil.kt @@ -35,7 +35,7 @@ internal fun androidHome(): String { } } throw IllegalStateException( - "Missing 'ANDROID_HOME' environment variable or local.properties with 'sdk.dir'" + "Missing 'ANDROID_HOME' environment variable or local.properties with 'sdk.dir'", ) } diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/AutoConfigureFladleTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/AutoConfigureFladleTest.kt index e295d2c5..13a82ded 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/AutoConfigureFladleTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/AutoConfigureFladleTest.kt @@ -7,9 +7,9 @@ import org.junit.Test import org.junit.rules.TemporaryFolder class AutoConfigureFladleTest { - @get:Rule var testProjectRoot = TemporaryFolder() + fun writeBuildGradle(build: String) { val file = testProjectRoot.newFile("build.gradle") file.writeText(build) @@ -22,63 +22,64 @@ class AutoConfigureFladleTest { testProjectRoot.newFile("gradle.properties").writeText("android.useAndroidX=true") writeBuildGradle( """ - allprojects { - repositories { - google() - mavenCentral() - } - } - """.trimIndent() + allprojects { + repositories { + google() + mavenCentral() + } + } + """.trimIndent(), ) testProjectRoot.newFile("settings.gradle").writeText( """ - include '$fixtureName' - """.trimIndent() + include '$fixtureName' + """.trimIndent(), ) testProjectRoot.setupFixture(fixtureName) - val result = GradleRunner.create() - .withProjectDir(testProjectRoot.root) - .withPluginClasspath() - .withArguments("assembleDebug", "assembleDebugAndroidTest", "printYml", "--stacktrace") - .build() + val result = + GradleRunner.create() + .withProjectDir(testProjectRoot.root) + .withPluginClasspath() + .withArguments("assembleDebug", "assembleDebugAndroidTest", "printYml", "--stacktrace") + .build() assertThat(result.output).contains("BUILD SUCCESSFUL") assertThat(result.output).containsMatch( """ - > Task :android-project:printYml - gcloud: - app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk - test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk - device: - - model: Pixel2 - version: 26 - - model: Nexus5 - version: 23 + > Task :android-project:printYml + gcloud: + app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk + test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk + device: + - model: Pixel2 + version: 26 + - model: Nexus5 + version: 23 - use-orchestrator: true - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - environment-variables: - clearPackageData: true - listener: com.osacky.flank.sample.Listener - test-targets: - - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#seeView - num-flaky-test-attempts: 0 + use-orchestrator: true + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + environment-variables: + clearPackageData: true + listener: com.osacky.flank.sample.Listener + test-targets: + - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#seeView + num-flaky-test-attempts: 0 - flank: - smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + flank: + smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) } } diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/ConfigurationCacheTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/ConfigurationCacheTest.kt index c8f24e7c..2f9b5582 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/ConfigurationCacheTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/ConfigurationCacheTest.kt @@ -7,7 +7,6 @@ import org.junit.Test import org.junit.rules.TemporaryFolder class ConfigurationCacheTest { - @get:Rule var testProjectRoot = TemporaryFolder() @@ -22,7 +21,7 @@ class ConfigurationCacheTest { """plugins { | id "com.osacky.fladle" |} - """.trimMargin() + """.trimMargin(), ) val result = configCachingRunner("help").build() @@ -47,7 +46,7 @@ class ConfigurationCacheTest { | localResultsDir = "foo" |} | - """.trimMargin() + """.trimMargin(), ) testProjectRoot.newFile("flank-gradle-service-account.json").writeText("{}") val result = configCachingRunner("writeConfigProps").build() @@ -79,7 +78,7 @@ class ConfigurationCacheTest { | instrumentationApk = "test.apk" |} | - """.trimMargin() + """.trimMargin(), ) testProjectRoot.newFile("flank-gradle-service-account.json").writeText("{}") val result = configCachingRunner("flankDoctor").build() @@ -109,7 +108,7 @@ class ConfigurationCacheTest { | localResultsDir = "foo" |} | - """.trimMargin() + """.trimMargin(), ) val settings = testProjectRoot.newFile("settings.gradle") @@ -118,7 +117,7 @@ class ConfigurationCacheTest { plugins { id 'com.gradle.enterprise' version '3.7' } - """.trimIndent() + """.trimIndent(), ) testProjectRoot.newFile("flank-gradle-service-account.json").writeText("{ \"project_id\": \"foo\" }") val result = configCachingRunner("runFlank").buildAndFail() diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FlankAuthTestTask.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FlankAuthTestTask.kt index 4be914c1..fffb40e9 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FlankAuthTestTask.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/integration/FlankAuthTestTask.kt @@ -27,7 +27,7 @@ class FlankAuthTestTask { | timeout.set(Duration.ofSeconds(5)) |} | - """.trimMargin() + """.trimMargin(), ) val result = testProjectRoot.gradleRunner().withArguments("flankAuth").buildAndFail() 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 2d7990c6..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 @@ -8,12 +8,11 @@ import org.junit.Test import org.junit.rules.TemporaryFolder class FlankGradlePluginIntegrationTest { - @get:Rule var testProjectRoot = TemporaryFolder() val minSupportGradleVersion = "6.5" - val oldVersion = "5.3.1" + val oldVersion = "6.4" fun writeBuildGradle(build: String) { testProjectRoot.writeBuildDotGradle(build) @@ -25,29 +24,31 @@ class FlankGradlePluginIntegrationTest { """plugins { | id "com.osacky.fladle" |} - """.trimMargin() + """.trimMargin(), ) - val result = GradleRunner.create() - .withProjectDir(testProjectRoot.root) - .withPluginClasspath() - .withGradleVersion(oldVersion) - .buildAndFail() - assertThat(result.output).contains("Fladle requires at minimum version Gradle 5.5. Detected version Gradle 5.3.1") + val result = + GradleRunner.create() + .withProjectDir(testProjectRoot.root) + .withPluginClasspath() + .withGradleVersion(oldVersion) + .buildAndFail() + assertThat(result.output).contains("Fladle requires at minimum version Gradle 6.5. Detected version Gradle 6.4") } @Test - fun testGradleSixZero() { + fun testGradleSevenOh() { writeBuildGradle( """plugins { | id "com.osacky.fladle" |} - """.trimMargin() + """.trimMargin(), ) - val result = GradleRunner.create() - .withProjectDir(testProjectRoot.root) - .withPluginClasspath() - .withGradleVersion("6.0") - .build() + val result = + GradleRunner.create() + .withProjectDir(testProjectRoot.root) + .withPluginClasspath() + .withGradleVersion("7.0") + .build() assertThat(result.output).contains("SUCCESS") } @@ -58,7 +59,7 @@ class FlankGradlePluginIntegrationTest { """plugins { | id "com.osacky.fladle" |} - """.trimMargin() + """.trimMargin(), ) GradleRunner.create() .withProjectDir(testProjectRoot.root) @@ -79,7 +80,7 @@ class FlankGradlePluginIntegrationTest { | debugApk = "foo" | instrumentationApk = "fakeInstrument.apk" |} - """.trimMargin() + """.trimMargin(), ) GradleRunner.create() .withProjectDir(testProjectRoot.root) @@ -99,15 +100,21 @@ class FlankGradlePluginIntegrationTest { |fladle { | debugApk = "foo" |} - """.trimMargin() + """.trimMargin(), + ) + val result = + GradleRunner.create() + .withProjectDir(testProjectRoot.root) + .withPluginClasspath() + .withGradleVersion(minSupportGradleVersion) + .withArguments("printYml") + .buildAndFail() + assertThat( + result.output, + ).contains( + "ServiceAccountCredentials in fladle extension not set." + + "https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials", ) - val result = GradleRunner.create() - .withProjectDir(testProjectRoot.root) - .withPluginClasspath() - .withGradleVersion(minSupportGradleVersion) - .withArguments("printYml") - .buildAndFail() - assertThat(result.output).contains("ServiceAccountCredentials in fladle extension not set. https://runningcode.github.io/fladle/configuration/#serviceaccountcredentials") } @Test @@ -120,37 +127,40 @@ class FlankGradlePluginIntegrationTest { | serviceAccountCredentials = project.layout.projectDirectory.file("foo") |} | - """.trimMargin() + """.trimMargin(), ) testProjectRoot.newFile("foo").writeText("{}") - val result = GradleRunner.create() - .withProjectDir(testProjectRoot.root) - .withPluginClasspath() - .withGradleVersion(minSupportGradleVersion) - .withArguments("runFlank") - .buildAndFail() + val result = + GradleRunner.create() + .withProjectDir(testProjectRoot.root) + .withPluginClasspath() + .withGradleVersion(minSupportGradleVersion) + .withArguments("runFlank") + .buildAndFail() assertThat(result.output).contains("debugApk must be specified") } @Test fun testMissingInstrumentationApkFailsBuild() { writeBuildGradle( - """plugins { - id "com.osacky.fladle" - } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("foo") - debugApk = "test-debug.apk" - } - """.trimIndent() + """ + plugins { + id "com.osacky.fladle" + } + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("foo") + debugApk = "test-debug.apk" + } + """.trimIndent(), ) testProjectRoot.newFile("foo").writeText("{}") - val result = GradleRunner.create() - .withProjectDir(testProjectRoot.root) - .withPluginClasspath() - .withGradleVersion(minSupportGradleVersion) - .withArguments("runFlank") - .buildAndFail() + val result = + GradleRunner.create() + .withProjectDir(testProjectRoot.root) + .withPluginClasspath() + .withGradleVersion(minSupportGradleVersion) + .withArguments("runFlank") + .buildAndFail() assertThat(result.output).contains("Must specify either a instrumentationApk file or a roboScript file or a robo directive.") } @@ -158,22 +168,24 @@ class FlankGradlePluginIntegrationTest { @Test fun testSpecifyingBothInstrumentationAndRoboscriptFailsBuild() { writeBuildGradle( - """plugins { - id "com.osacky.fladle" - } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") - debugApk = "test-debug.apk" - instrumentationApk = "instrumentation-debug.apk" - roboScript = "foo.script" - } - """.trimIndent() + """ + plugins { + id "com.osacky.fladle" + } + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") + debugApk = "test-debug.apk" + instrumentationApk = "instrumentation-debug.apk" + roboScript = "foo.script" + } + """.trimIndent(), ) testProjectRoot.writeEmptyServiceCredential() - val result = testProjectRoot.gradleRunner() - .withGradleVersion(minSupportGradleVersion) - .withArguments("printYml") - .buildAndFail() + val result = + testProjectRoot.gradleRunner() + .withGradleVersion(minSupportGradleVersion) + .withArguments("printYml") + .buildAndFail() assertThat(result.output).contains("Only one of instrumentationApk file, roboScript file, and robo directives must be specified.") } @@ -181,24 +193,26 @@ class FlankGradlePluginIntegrationTest { @Test fun testSpecifyingBothInstrumentationAndRobodirectiveFailsBuild() { writeBuildGradle( - """plugins { - id "com.osacky.fladle" - } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") - debugApk = "test-debug.apk" - instrumentationApk = "instrumentation-debug.apk" - roboDirectives = [ - ["click", "resource_id"], - ] - } - """.trimIndent() + """ + plugins { + id "com.osacky.fladle" + } + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") + debugApk = "test-debug.apk" + instrumentationApk = "instrumentation-debug.apk" + roboDirectives = [ + ["click", "resource_id"], + ] + } + """.trimIndent(), ) testProjectRoot.writeEmptyServiceCredential() - val result = testProjectRoot.gradleRunner() - .withGradleVersion(minSupportGradleVersion) - .withArguments("printYml") - .buildAndFail() + val result = + testProjectRoot.gradleRunner() + .withGradleVersion(minSupportGradleVersion) + .withArguments("printYml") + .buildAndFail() assertThat(result.output).contains("Only one of instrumentationApk file, roboScript file, and robo directives must be specified.") } @@ -206,24 +220,26 @@ class FlankGradlePluginIntegrationTest { @Test fun testSpecifyingBothRoboscriptAndRobodirectiveFailsBuild() { writeBuildGradle( - """plugins { - id "com.osacky.fladle" - } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") - debugApk = "test-debug.apk" - roboScript = "foo.script" - roboDirectives = [ - ["click", "resource_id"], - ] - } - """.trimIndent() + """ + plugins { + id "com.osacky.fladle" + } + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") + debugApk = "test-debug.apk" + roboScript = "foo.script" + roboDirectives = [ + ["click", "resource_id"], + ] + } + """.trimIndent(), ) testProjectRoot.writeEmptyServiceCredential() - val result = testProjectRoot.gradleRunner() - .withGradleVersion(minSupportGradleVersion) - .withArguments("printYml") - .buildAndFail() + val result = + testProjectRoot.gradleRunner() + .withGradleVersion(minSupportGradleVersion) + .withArguments("printYml") + .buildAndFail() assertThat(result.output).contains("Only one of instrumentationApk file, roboScript file, and robo directives must be specified.") } @@ -231,25 +247,27 @@ class FlankGradlePluginIntegrationTest { @Test fun testSpecifyingInstrumentationAndRoboscriptAndRobodirectiveFailsBuild() { writeBuildGradle( - """plugins { - id "com.osacky.fladle" - } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") - debugApk = "test-debug.apk" - instrumentationApk = "instrumentation-debug.apk" - roboScript = "foo.script" - roboDirectives = [ - ["click", "resource_id"], - ] - } - """.trimIndent() + """ + plugins { + id "com.osacky.fladle" + } + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") + debugApk = "test-debug.apk" + instrumentationApk = "instrumentation-debug.apk" + roboScript = "foo.script" + roboDirectives = [ + ["click", "resource_id"], + ] + } + """.trimIndent(), ) testProjectRoot.writeEmptyServiceCredential() - val result = testProjectRoot.gradleRunner() - .withGradleVersion(minSupportGradleVersion) - .withArguments("printYml") - .buildAndFail() + val result = + testProjectRoot.gradleRunner() + .withGradleVersion(minSupportGradleVersion) + .withArguments("printYml") + .buildAndFail() assertThat(result.output).contains("Only one of instrumentationApk file, roboScript file, and robo directives must be specified.") } @@ -269,13 +287,14 @@ class FlankGradlePluginIntegrationTest { } } } - """.trimMargin() + """.trimMargin(), ) testProjectRoot.writeEmptyServiceCredential() - val result = testProjectRoot.gradleRunner() - .withGradleVersion("7.0-rc-1") - .withArguments("printYmlFooConfig") - .build() + val result = + testProjectRoot.gradleRunner() + .withGradleVersion("7.0-rc-1") + .withArguments("printYmlFooConfig") + .build() assertThat(result.task(":printYmlFooConfig")!!.outcome).isEqualTo(TaskOutcome.SUCCESS) } } 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 77f83ec6..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 @@ -23,11 +23,12 @@ class FulladlePluginIntegrationTest { """plugins { | id "com.osacky.fulladle" |} - """.trimMargin() + """.trimMargin(), ) - val result = testProjectRoot.gradleRunner() - .withArguments("help") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments("help") + .build() assertThat(result.output).contains("SUCCESS") } @@ -38,17 +39,17 @@ class FulladlePluginIntegrationTest { val ignoredLibraryProject = "android-lib-ignored" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixture' - include '$libraryFixture' - include '$ignoredLibraryProject' - - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + include '$appFixture' + include '$libraryFixture' + include '$ignoredLibraryProject' + + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(libraryFixture) @@ -56,25 +57,25 @@ class FulladlePluginIntegrationTest { writeBuildGradle( """ - buildscript { - repositories { - google() - } + buildscript { + repositories { + google() + } - dependencies { - classpath '$agpDependency' - } - } - - plugins { - id "com.osacky.fulladle" - } - - - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - } - """.trimIndent() + dependencies { + classpath '$agpDependency' + } + } + + plugins { + id "com.osacky.fulladle" + } + + + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + } + """.trimIndent(), ) // Configure second included project to ignore fulladle module @@ -83,44 +84,45 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = false } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).contains("SUCCESS") // Ensure that there is only one additional test APK even though there are two library modules. assertThat(result.output).containsMatch( """ - > Task :printYml - gcloud: - app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk - test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk - device: - - model: NexusLowRes - version: 28 - - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - num-flaky-test-attempts: 0 - - flank: - keep-file-path: false - additional-app-test-apks: - - test: [0-9a-zA-Z\/_]*/android-library-project/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk - - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + > Task :printYml + gcloud: + app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk + test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk + device: + - model: NexusLowRes + version: 28 + + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + num-flaky-test-attempts: 0 + + flank: + keep-file-path: false + additional-app-test-apks: + - test: [0-9a-zA-Z\/_]*/android-library-project/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk + + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) } @@ -131,17 +133,17 @@ class FulladlePluginIntegrationTest { val nonAndroidFixture = "lib1" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixture' - include '$libraryFixture' - include '$nonAndroidFixture' + include '$appFixture' + include '$libraryFixture' + include '$nonAndroidFixture' - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(libraryFixture) @@ -149,25 +151,25 @@ class FulladlePluginIntegrationTest { writeBuildGradle( """ - buildscript { - repositories { - google() - } + buildscript { + repositories { + google() + } - dependencies { - classpath '$agpDependency' - } - } - - plugins { - id "com.osacky.fulladle" - } - - - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - } - """.trimIndent() + dependencies { + classpath '$agpDependency' + } + } + + plugins { + id "com.osacky.fulladle" + } + + + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + } + """.trimIndent(), ) // Configure second included project to ignore fulladle module @@ -176,19 +178,20 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = false } - """.trimIndent() + """.trimIndent(), ) File(testProjectRoot.root, "$nonAndroidFixture/build.gradle").writeText( """ - apply plugin: 'java-library' + apply plugin: 'java-library' - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).contains("SUCCESS") } @@ -201,18 +204,18 @@ class FulladlePluginIntegrationTest { val libraryFixture2 = "android-lib2" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixture' - include '$appFixture2' - include '$libraryFixture' - include '$libraryFixture2' + include '$appFixture' + include '$appFixture2' + include '$libraryFixture' + include '$libraryFixture2' - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(appFixture2) @@ -221,28 +224,28 @@ class FulladlePluginIntegrationTest { writeBuildGradle( """ - buildscript { - repositories { - google() - } + buildscript { + repositories { + google() + } - dependencies { - classpath '$agpDependency' - } - } + dependencies { + classpath '$agpDependency' + } + } - plugins { - id "com.osacky.fulladle" - } + plugins { + id "com.osacky.fulladle" + } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - environmentVariables = [ - "clearPackageData": "true", - "listener": "com.osacky.flank.sample.Listener" - ] - } - """.trimIndent() + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + environmentVariables = [ + "clearPackageData": "true", + "listener": "com.osacky.flank.sample.Listener" + ] + } + """.trimIndent(), ) File(testProjectRoot.root, "$libraryFixture2/build.gradle").appendText( @@ -251,7 +254,7 @@ class FulladlePluginIntegrationTest { maxTestShards = 4 clientDetails = ["test-type": "PR","build-number": "132"] } - """.trimIndent() + """.trimIndent(), ) File(testProjectRoot.root, "$libraryFixture/build.gradle").appendText( @@ -264,63 +267,64 @@ class FulladlePluginIntegrationTest { ] debugApk = "dummy_app.apk" } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).contains("SUCCESS") assertThat(result.output).containsMatch( """ - > Task :printYml - gcloud: - app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk - test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk - device: - - model: NexusLowRes - version: 28 - - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - environment-variables: - clearPackageData: true - listener: com.osacky.flank.sample.Listener - num-flaky-test-attempts: 0 - - flank: - keep-file-path: false - additional-app-test-apks: - - app: [0-9a-zA-Z\/_]*/android-project2/build/outputs/apk/debug/android-project2-debug.apk - test: [0-9a-zA-Z\/_]*/android-project2/build/outputs/apk/androidTest/debug/android-project2-debug-androidTest.apk - max-test-shards: 5 - environment-variables: - clearPackageData: false - - - test: [0-9a-zA-Z\/_]*/$libraryFixture2/build/outputs/apk/androidTest/debug/android-lib2-debug-androidTest.apk - max-test-shards: 4 - client-details: - test-type: PR - build-number: 132 - - - app: dummy_app.apk - test: [0-9a-zA-Z\/_]*/$libraryFixture/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk - max-test-shards: 7 - environment-variables: - clearPackageData: false - listener: com.osacky.flank.sample.Listener.Different - - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + > Task :printYml + gcloud: + app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk + test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk + device: + - model: NexusLowRes + version: 28 + + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + environment-variables: + clearPackageData: true + listener: com.osacky.flank.sample.Listener + num-flaky-test-attempts: 0 + + flank: + keep-file-path: false + additional-app-test-apks: + - app: [0-9a-zA-Z\/_]*/android-project2/build/outputs/apk/debug/android-project2-debug.apk + test: [0-9a-zA-Z\/_]*/android-project2/build/outputs/apk/androidTest/debug/android-project2-debug-androidTest.apk + max-test-shards: 5 + environment-variables: + clearPackageData: false + + - test: [0-9a-zA-Z\/_]*/$libraryFixture2/build/outputs/apk/androidTest/debug/android-lib2-debug-androidTest.apk + max-test-shards: 4 + client-details: + test-type: PR + build-number: 132 + + - app: dummy_app.apk + test: [0-9a-zA-Z\/_]*/$libraryFixture/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk + max-test-shards: 7 + environment-variables: + clearPackageData: false + listener: com.osacky.flank.sample.Listener.Different + + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) } @@ -343,7 +347,7 @@ class FulladlePluginIntegrationTest { google() } } - """.trimIndent() + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(libraryFixture) @@ -356,7 +360,7 @@ class FulladlePluginIntegrationTest { repositories { google() } - + dependencies { classpath '$agpDependency' } @@ -370,7 +374,7 @@ class FulladlePluginIntegrationTest { fladle { serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") } - """.trimIndent() + """.trimIndent(), ) // Configure flavors in project and library @@ -379,7 +383,7 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { variant = "vanillaDebug" } - """.trimIndent() + """.trimIndent(), ) File(testProjectRoot.root, "$flavourLibrary/build.gradle").appendText( @@ -387,48 +391,49 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { variant = "strawberryDebug" } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).contains("SUCCESS") assertThat(result.output).containsMatch( """ - > Task :printYml - gcloud: - app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk - test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk - device: - - model: NexusLowRes - version: 28 - - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - num-flaky-test-attempts: 0 - - flank: - keep-file-path: false - additional-app-test-apks: - - app: [0-9a-zA-Z\/_]*/android-project-flavors/build/outputs/apk/vanilla/debug/android-project-flavors-vanilla-debug.apk - test: [0-9a-zA-Z\/_]*/android-project-flavors/build/outputs/apk/androidTest/vanilla/debug/android-project-flavors-vanilla-debug-androidTest.apk - - - test: [0-9a-zA-Z\/_]*/android-library-project/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk - - - test: [0-9a-zA-Z\/_]*/android-library-project-flavors/build/outputs/apk/androidTest/strawberry/debug/android-library-project-flavors-strawberry-debug-androidTest.apk - - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + > Task :printYml + gcloud: + app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk + test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk + device: + - model: NexusLowRes + version: 28 + + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + num-flaky-test-attempts: 0 + + flank: + keep-file-path: false + additional-app-test-apks: + - app: [0-9a-zA-Z\/_]*/android-project-flavors/build/outputs/apk/vanilla/debug/android-project-flavors-vanilla-debug.apk + test: [0-9a-zA-Z\/_]*/android-project-flavors/build/outputs/apk/androidTest/vanilla/debug/android-project-flavors-vanilla-debug-androidTest.apk + + - test: [0-9a-zA-Z\/_]*/android-library-project/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk + + - test: [0-9a-zA-Z\/_]*/android-library-project-flavors/build/outputs/apk/androidTest/strawberry/debug/android-library-project-flavors-strawberry-debug-androidTest.apk + + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) } @@ -451,7 +456,7 @@ class FulladlePluginIntegrationTest { google() } } - """.trimIndent() + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(flavourProject) @@ -463,7 +468,7 @@ class FulladlePluginIntegrationTest { repositories { google() } - + dependencies { classpath '$agpDependency' } @@ -477,46 +482,47 @@ class FulladlePluginIntegrationTest { fladle { serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).contains("SUCCESS") assertThat(result.output).containsMatch( """ - > Task :printYml - gcloud: - app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk - test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk - device: - - model: NexusLowRes - version: 28 - - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - num-flaky-test-attempts: 0 - - flank: - keep-file-path: false - additional-app-test-apks: - - app: [0-9a-zA-Z\/_]*/android-project-flavors/build/outputs/apk/chocolate/debug/android-project-flavors-chocolate-debug.apk - test: [0-9a-zA-Z\/_]*/android-project-flavors/build/outputs/apk/androidTest/chocolate/debug/android-project-flavors-chocolate-debug-androidTest.apk - - - test: [0-9a-zA-Z\/_]*/android-library-project-flavors/build/outputs/apk/androidTest/lemon/debug/android-library-project-flavors-lemon-debug-androidTest.apk - - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + > Task :printYml + gcloud: + app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk + test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk + device: + - model: NexusLowRes + version: 28 + + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + num-flaky-test-attempts: 0 + + flank: + keep-file-path: false + additional-app-test-apks: + - app: [0-9a-zA-Z\/_]*/android-project-flavors/build/outputs/apk/chocolate/debug/android-project-flavors-chocolate-debug.apk + test: [0-9a-zA-Z\/_]*/android-project-flavors/build/outputs/apk/androidTest/chocolate/debug/android-project-flavors-chocolate-debug-androidTest.apk + + - test: [0-9a-zA-Z\/_]*/android-library-project-flavors/build/outputs/apk/androidTest/lemon/debug/android-library-project-flavors-lemon-debug-androidTest.apk + + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) } @@ -525,39 +531,39 @@ class FulladlePluginIntegrationTest { val appFixture = "android-project" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixture' + include '$appFixture' - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) writeBuildGradle( """ - buildscript { - repositories { - google() - } + buildscript { + repositories { + google() + } - dependencies { - classpath '$agpDependency' - } - } + dependencies { + classpath '$agpDependency' + } + } - plugins { - id "com.osacky.fulladle" - } + plugins { + id "com.osacky.fulladle" + } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - maxTestShards = 4 - } - """.trimIndent() + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + maxTestShards = 4 + } + """.trimIndent(), ) File(testProjectRoot.root, "$appFixture/build.gradle").appendText( @@ -566,12 +572,13 @@ class FulladlePluginIntegrationTest { enabled = true maxTestShards = 7 } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).doesNotContain("max-test-shards: 4") assertThat(result.output).contains("max-test-shards: 7") assertThat(result.output).doesNotContain("additional-app-test-apks") @@ -582,38 +589,38 @@ class FulladlePluginIntegrationTest { val appFixture = "android-project" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixture' + include '$appFixture' - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) writeBuildGradle( """ - buildscript { - repositories { - google() - } + buildscript { + repositories { + google() + } - dependencies { - classpath '$agpDependency' - } - } + dependencies { + classpath '$agpDependency' + } + } - plugins { - id "com.osacky.fulladle" - } + plugins { + id "com.osacky.fulladle" + } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - } - """.trimIndent() + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + } + """.trimIndent(), ) File(testProjectRoot.root, "$appFixture/build.gradle").appendText( @@ -621,12 +628,13 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = false } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .buildAndFail() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .buildAndFail() assertThat(result.output).contains("Task :configureFulladle FAILED") assertThat(result.output).contains("All modules were disabled for testing in fulladleModuleConfig or the enabled modules had no tests") @@ -645,17 +653,17 @@ class FulladlePluginIntegrationTest { val libraryFixture = "android-library-project" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixture' - include '$appFixture2' - include '$libraryFixture' + include '$appFixture' + include '$appFixture2' + include '$libraryFixture' - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(appFixture2) @@ -663,24 +671,24 @@ class FulladlePluginIntegrationTest { writeBuildGradle( """ - buildscript { - repositories { - google() - } + buildscript { + repositories { + google() + } - dependencies { - classpath '$agpDependency' - } - } + dependencies { + classpath '$agpDependency' + } + } - plugins { - id "com.osacky.fulladle" - } + plugins { + id "com.osacky.fulladle" + } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - } - """.trimIndent() + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + } + """.trimIndent(), ) File(testProjectRoot.root, "$appFixture/build.gradle").appendText( @@ -688,7 +696,7 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = false } - """.trimIndent() + """.trimIndent(), ) File(testProjectRoot.root, "$appFixture2/build.gradle").appendText( @@ -696,19 +704,21 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = false } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .buildAndFail() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .buildAndFail() 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" + "This is a required parameter in FTL which remains unused for library modules under test, and you can use a dummy apk here", ) } @@ -725,17 +735,17 @@ class FulladlePluginIntegrationTest { val libraryFixture = "android-library-project" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixture' - include '$appFixture2' - include '$libraryFixture' + include '$appFixture' + include '$appFixture2' + include '$libraryFixture' - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(appFixture2) @@ -743,24 +753,24 @@ class FulladlePluginIntegrationTest { writeBuildGradle( """ - buildscript { - repositories { - google() - } + buildscript { + repositories { + google() + } - dependencies { - classpath '$agpDependency' - } - } + dependencies { + classpath '$agpDependency' + } + } - plugins { - id "com.osacky.fulladle" - } + plugins { + id "com.osacky.fulladle" + } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - } - """.trimIndent() + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + } + """.trimIndent(), ) File(testProjectRoot.root, "$appFixture/build.gradle").appendText( @@ -768,7 +778,7 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = false } - """.trimIndent() + """.trimIndent(), ) File(testProjectRoot.root, "$appFixture2/build.gradle").appendText( @@ -776,28 +786,29 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = false } - """.trimIndent() + """.trimIndent(), ) File(testProjectRoot.root, "$libraryFixture/build.gradle").appendText( """ fulladleModuleConfig { debugApk = "dummy_app.apk" } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).doesNotContain("additional-app-test-apks") assertThat(result.output).containsMatch( """ - > Task :printYml - gcloud: - app: dummy_app.apk - test: [0-9a-zA-Z\/_]*/$libraryFixture/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk - """.trimIndent() + > Task :printYml + gcloud: + app: dummy_app.apk + test: [0-9a-zA-Z\/_]*/$libraryFixture/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk + """.trimIndent(), ) assertThat(result.output).contains("SUCCESS") } @@ -815,17 +826,17 @@ class FulladlePluginIntegrationTest { val libraryFixture = "android-library-project" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixture' - include '$appFixture2' - include '$libraryFixture' + include '$appFixture' + include '$appFixture2' + include '$libraryFixture' - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(appFixture2) @@ -833,24 +844,24 @@ class FulladlePluginIntegrationTest { writeBuildGradle( """ - buildscript { - repositories { - google() - } + buildscript { + repositories { + google() + } - dependencies { - classpath '$agpDependency' - } - } + dependencies { + classpath '$agpDependency' + } + } - plugins { - id "com.osacky.fulladle" - } + plugins { + id "com.osacky.fulladle" + } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - } - """.trimIndent() + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + } + """.trimIndent(), ) File(testProjectRoot.root, "$appFixture/build.gradle").appendText( @@ -858,7 +869,7 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = true } - """.trimIndent() + """.trimIndent(), ) File(testProjectRoot.root, "$appFixture2/build.gradle").appendText( @@ -866,12 +877,13 @@ class FulladlePluginIntegrationTest { fulladleModuleConfig { enabled = false } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).contains("BUILD SUCCESSFUL") } @@ -884,18 +896,18 @@ class FulladlePluginIntegrationTest { val libraryFixture = "android-library-project" testProjectRoot.newFile("settings.gradle").writeText( """ - include '$appFixtureWithAbiSplits' - include '$appFixture' - include '$appFixtureTwo' - include '$libraryFixture' + include '$appFixtureWithAbiSplits' + include '$appFixture' + include '$appFixtureTwo' + include '$libraryFixture' - dependencyResolutionManagement { - repositories { - mavenCentral() - google() - } + dependencyResolutionManagement { + repositories { + mavenCentral() + google() } - """.trimIndent() + } + """.trimIndent(), ) testProjectRoot.setupFixture(appFixture) testProjectRoot.setupFixture(appFixtureTwo) @@ -904,22 +916,22 @@ class FulladlePluginIntegrationTest { writeBuildGradle( """ - buildscript { - repositories { - google() - } - dependencies { - classpath '$agpDependency' - } - } - plugins { - id "com.osacky.fulladle" - } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") - abi = "armeabi-v7a" - } - """.trimIndent() + buildscript { + repositories { + google() + } + dependencies { + classpath '$agpDependency' + } + } + plugins { + id "com.osacky.fulladle" + } + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("android-project/flank-gradle-5cf02dc90531.json") + abi = "armeabi-v7a" + } + """.trimIndent(), ) // Overwrite android-project fixture to include ABI splits. @@ -929,11 +941,12 @@ class FulladlePluginIntegrationTest { id "com.android.application" } android { - compileSdkVersion 29 + compileSdk 33 + namespace "com.osacky.flank.gradle.sample" defaultConfig { applicationId "com.osacky.flank.gradle.sample" - minSdkVersion 23 - targetSdkVersion 29 + minSdk 23 + targetSdk 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -950,12 +963,13 @@ class FulladlePluginIntegrationTest { } } } - """.trimIndent() + """.trimIndent(), ) - val result = testProjectRoot.gradleRunner() - .withArguments(":printYml") - .build() + val result = + testProjectRoot.gradleRunner() + .withArguments(":printYml") + .build() assertThat(result.output).contains("SUCCESS") // Ensure that: @@ -963,42 +977,42 @@ class FulladlePluginIntegrationTest { // - Any application modules that don't use ABI splits are still present in additional-app-test-apks. assertThat(result.output).containsMatch( """ - > Task :printYml - gcloud: - app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk - test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk - device: - - model: NexusLowRes - version: 28 - - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - num-flaky-test-attempts: 0 - - flank: - keep-file-path: false - additional-app-test-apks: - - app: [0-9a-zA-Z\/_]*/android-project-with-abi-splits/build/outputs/apk/debug/android-project-with-abi-splits-armeabi-v7a-debug.apk - test: [0-9a-zA-Z\/_]*/android-project-with-abi-splits/build/outputs/apk/androidTest/debug/android-project-with-abi-splits-debug-androidTest.apk - - - app: [0-9a-zA-Z\/_]*/android-project2/build/outputs/apk/debug/android-project2-debug.apk - test: [0-9a-zA-Z\/_]*/android-project2/build/outputs/apk/androidTest/debug/android-project2-debug-androidTest.apk - max-test-shards: 5 - environment-variables: - clearPackageData: false - - - test: [0-9a-zA-Z\/_]*/android-library-project/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk - - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + > Task :printYml + gcloud: + app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk + test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk + device: + - model: NexusLowRes + version: 28 + + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + num-flaky-test-attempts: 0 + + flank: + keep-file-path: false + additional-app-test-apks: + - app: [0-9a-zA-Z\/_]*/android-project-with-abi-splits/build/outputs/apk/debug/android-project-with-abi-splits-armeabi-v7a-debug.apk + test: [0-9a-zA-Z\/_]*/android-project-with-abi-splits/build/outputs/apk/androidTest/debug/android-project-with-abi-splits-debug-androidTest.apk + + - app: [0-9a-zA-Z\/_]*/android-project2/build/outputs/apk/debug/android-project2-debug.apk + test: [0-9a-zA-Z\/_]*/android-project2/build/outputs/apk/androidTest/debug/android-project2-debug-androidTest.apk + max-test-shards: 5 + environment-variables: + clearPackageData: false + + - test: [0-9a-zA-Z\/_]*/android-library-project/build/outputs/apk/androidTest/debug/android-library-project-debug-androidTest.apk + + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) } } 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 93b997c8..b3a4767f 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 @@ -7,7 +7,12 @@ import org.junit.Test import org.junit.rules.TemporaryFolder private fun baseConfigMessage(option: String) = "Incorrect [base] configuration. [$option] can't be used together with sanityRobo." -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" + +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" class SanityRoboTest { @get:Rule @@ -35,7 +40,7 @@ class SanityRoboTest { | } | } |} - """.trimMargin() + """.trimMargin(), ) val runner = testProjectRoot.gradleRunner() @@ -63,7 +68,7 @@ class SanityRoboTest { | serviceAccountCredentials = layout.projectDirectory.file("flank-gradle-service.json") | roboScript = "some/path/script.json" |} - """.trimMargin() + """.trimMargin(), ) val result = testProjectRoot.gradleRunner().withArguments("printYml").buildAndFail() @@ -76,7 +81,7 @@ class SanityRoboTest { fun `sanityRobo - should throw an error if roboDirectives set`() { testProjectRoot.writeBuildDotGradle( buildScript = - """ + """ |plugins { | id "com.osacky.fladle" |} @@ -91,7 +96,7 @@ class SanityRoboTest { | ["text", "field1", "my text"], | ] |} - """.trimMargin() + """.trimMargin(), ) val result = testProjectRoot.gradleRunner().withArguments("printYml").buildAndFail() @@ -104,7 +109,7 @@ class SanityRoboTest { fun `sanityRobo - should throw an error if additionalTestApks set`() { testProjectRoot.writeBuildDotGradle( buildScript = - """ + """ |plugins { | id "com.osacky.fladle" |} @@ -119,7 +124,7 @@ class SanityRoboTest { | "- test: test3.apk" | ] |} - """.trimMargin() + """.trimMargin(), ) val result = testProjectRoot.gradleRunner().withArguments("printYml").buildAndFail() @@ -152,7 +157,7 @@ class SanityRoboTest { | } | } |} - """.trimMargin() + """.trimMargin(), ) val expectedMessage = additionalConfigMessage("roboScript", "sanity") @@ -191,7 +196,7 @@ class SanityRoboTest { | } | } |} - """.trimMargin() + """.trimMargin(), ) val runner = testProjectRoot.gradleRunner() @@ -226,7 +231,7 @@ class SanityRoboTest { | legacy-junit-result: false | full-junit-result: false | output-style: single - """.trimMargin() + """.trimMargin(), ) val resultOrange = runner.withArguments("printYmlOrange").build() @@ -255,7 +260,7 @@ class SanityRoboTest { | legacy-junit-result: false | full-junit-result: false | output-style: single - """.trimMargin() + """.trimMargin(), ) } @@ -283,7 +288,7 @@ class SanityRoboTest { | } | } |} - """.trimMargin() + """.trimMargin(), ) val runner = testProjectRoot.gradleRunner() @@ -313,7 +318,7 @@ class SanityRoboTest { | legacy-junit-result: false | full-junit-result: false | output-style: single - """.trimMargin() + """.trimMargin(), ) val resultOrange = runner.withArguments("printYmlOrange").build() @@ -347,7 +352,7 @@ class SanityRoboTest { | legacy-junit-result: false | full-junit-result: false | output-style: single - """.trimMargin() + """.trimMargin(), ) } } 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 40879192..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,18 +6,19 @@ 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' } android { - compileSdkVersion 29 + compileSdk 33 + namespace "com.osacky.flank.gradle.sample" defaultConfig { applicationId "com.osacky.flank.gradle.sample" - minSdkVersion 23 - targetSdkVersion 29 + minSdk 23 + targetSdk 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -29,7 +30,6 @@ private const val commonScriptPart = """ """ class SanityWithAutoConfigureTest { - @get:Rule var testProjectRoot = TemporaryFolder() @@ -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") @@ -78,7 +78,7 @@ class SanityWithAutoConfigureTest { } } } - """.trimMargin() + """.trimMargin(), ) val runner = testProjectRoot.gradleRunner() @@ -87,36 +87,36 @@ class SanityWithAutoConfigureTest { assertThat(baseResult.output).contains("BUILD SUCCESSFUL") assertThat(baseResult.output).containsMatch( """ - gcloud: - app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk - test: [0-9a-zA-Z\/_]*/build/outputs/apk/androidTest/debug/[0-9a-zA-Z\/_]*-debug-androidTest.apk - device: - - model: Pixel2 - version: 26 - - model: Nexus5 - version: 23 + gcloud: + app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk + test: [0-9a-zA-Z\/_]*/build/outputs/apk/androidTest/debug/[0-9a-zA-Z\/_]*-debug-androidTest.apk + device: + - model: Pixel2 + version: 26 + - model: Nexus5 + version: 23 - use-orchestrator: true - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - environment-variables: - clearPackageData: true - test-targets: - - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#seeView - num-flaky-test-attempts: 0 + use-orchestrator: true + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + environment-variables: + clearPackageData: true + test-targets: + - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#seeView + num-flaky-test-attempts: 0 - flank: - smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + flank: + smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) val sanityResult = runner.withArguments("printYmlSanity").build() @@ -124,35 +124,35 @@ class SanityWithAutoConfigureTest { assertThat(sanityResult.output).contains("BUILD SUCCESSFUL") assertThat(sanityResult.output).containsMatch( """ - gcloud: - app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk - device: - - model: Pixel2 - version: 26 - - model: Nexus5 - version: 23 + gcloud: + app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk + device: + - model: Pixel2 + version: 26 + - model: Nexus5 + version: 23 - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - environment-variables: - clearPackageData: true - test-targets: - - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#runAndFail - num-flaky-test-attempts: 3 + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + environment-variables: + clearPackageData: true + test-targets: + - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#runAndFail + num-flaky-test-attempts: 3 - flank: - smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + flank: + smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) val orangesResult = runner.withArguments("printYmlOranges").build() @@ -160,36 +160,36 @@ class SanityWithAutoConfigureTest { assertThat(orangesResult.output).contains("BUILD SUCCESSFUL") assertThat(orangesResult.output).containsMatch( """ - gcloud: - app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk - test: [0-9a-zA-Z\/_]*/build/outputs/apk/androidTest/debug/[0-9a-zA-Z\/_]*-debug-androidTest.apk - device: - - model: Pixel2 - version: 26 - - model: Nexus5 - version: 23 + gcloud: + app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk + test: [0-9a-zA-Z\/_]*/build/outputs/apk/androidTest/debug/[0-9a-zA-Z\/_]*-debug-androidTest.apk + device: + - model: Pixel2 + version: 26 + - model: Nexus5 + version: 23 - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - environment-variables: - clearPackageData: true - test-targets: - - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#runAndFail - num-flaky-test-attempts: 6 + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + environment-variables: + clearPackageData: true + test-targets: + - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#runAndFail + num-flaky-test-attempts: 6 - flank: - smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + flank: + smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) } @@ -197,7 +197,7 @@ class SanityWithAutoConfigureTest { fun `test auto configuration with sanityRobo set (base config)`() { testProjectRoot.writeBuildDotGradle( """ - $commonScriptPart + $COMMON_SCRIPT_PART fladle { sanityRobo = true @@ -226,7 +226,7 @@ class SanityWithAutoConfigureTest { } } } - """.trimMargin() + """.trimMargin(), ) val runner = testProjectRoot.gradleRunner() @@ -235,35 +235,35 @@ class SanityWithAutoConfigureTest { assertThat(baseResult.output).contains("BUILD SUCCESSFUL") assertThat(baseResult.output).containsMatch( """ - gcloud: - app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk - device: - - model: Pixel2 - version: 26 - - model: Nexus5 - version: 23 + gcloud: + app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk + device: + - model: Pixel2 + version: 26 + - model: Nexus5 + version: 23 - use-orchestrator: true - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - environment-variables: - clearPackageData: true - test-targets: - - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#seeView - num-flaky-test-attempts: 0 + use-orchestrator: true + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + environment-variables: + clearPackageData: true + test-targets: + - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#seeView + num-flaky-test-attempts: 0 - flank: - smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + flank: + smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) val orangesResult = runner.withArguments("printYmlOranges").build() @@ -271,36 +271,36 @@ class SanityWithAutoConfigureTest { assertThat(orangesResult.output).contains("BUILD SUCCESSFUL") assertThat(orangesResult.output).containsMatch( """ - gcloud: - app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk - test: instrumentation-apk-not-detected-from-root.apk - device: - - model: Pixel2 - version: 26 - - model: Nexus5 - version: 23 + gcloud: + app: [0-9a-zA-Z\/_]*/build/outputs/apk/debug/[0-9a-zA-Z\/_]*-debug.apk + test: instrumentation-apk-not-detected-from-root.apk + device: + - model: Pixel2 + version: 26 + - model: Nexus5 + version: 23 - use-orchestrator: false - auto-google-login: false - record-video: true - performance-metrics: true - timeout: 15m - environment-variables: - clearPackageData: true - test-targets: - - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#runAndFail - num-flaky-test-attempts: 3 + use-orchestrator: false + auto-google-login: false + record-video: true + performance-metrics: true + timeout: 15m + environment-variables: + clearPackageData: true + test-targets: + - class com.osacky.flank.gradle.sample.ExampleInstrumentedTest#runAndFail + num-flaky-test-attempts: 3 - flank: - smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml - keep-file-path: false - ignore-failed-tests: false - disable-sharding: false - smart-flank-disable-upload: false - legacy-junit-result: false - full-junit-result: false - output-style: single - """.trimIndent() + flank: + smart-flank-gcs-path: gs://test-lab-yr9w6qsdvy45q-iurp80dm95h8a/flank/test_app_android.xml + keep-file-path: false + ignore-failed-tests: false + disable-sharding: false + smart-flank-disable-upload: false + legacy-junit-result: false + full-junit-result: false + output-style: single + """.trimIndent(), ) } } 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 408f95c7..c0f9a0c5 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 @@ -5,9 +5,9 @@ import org.gradle.testkit.runner.BuildResult import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder +import java.io.File class VariantTests { - @get:Rule var testProjectRoot = TemporaryFolder() @@ -48,25 +48,27 @@ class VariantTests { @Test fun testAdditionalFladleConfigForVariant() { - testProjectRoot.newFile("settings.gradle").writeText("rootProject.name = 'chocovanilla'") - val result = setUpDependOnAssemble( - dependsOnAssemble = true, withFlavors = true, - withFladleConfig = """ - configs { - vanilla { - variant.set("vanillaDebug") + val result = + setUpDependOnAssemble( + dependsOnAssemble = true, + withFlavors = true, + withFladleConfig = + """ + configs { + vanilla { + variant.set("vanillaDebug") + } } - } - """.trimIndent(), - withTask = "runFlankVanilla" - ) + """.trimIndent(), + withTask = "runFlankVanilla", + ) assertThat(result.output).contains(":assembleVanillaDebug") assertThat(result.output).contains(":assembleVanillaDebugAndroidTest") 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") @@ -99,68 +101,90 @@ class VariantTests { withTask: String = "runFlank", dryRun: Boolean = true, ): BuildResult { + testProjectRoot.newFile("settings.gradle").writeText( + """rootProject.name = 'chocovanilla' + |include ':android-project' + """.trimMargin(), + ) testProjectRoot.setupFixture("android-project") - testProjectRoot.writeEmptyServiceCredential() - val flavors = if (withFlavors) { - """ - flavorDimensions "flavor" - productFlavors { - chocolate { - dimension "flavor" - } - vanilla { - dimension "flavor" - } - } - """.trimIndent() - } else { "" } - val abiSplits = if (withAbiSplit) { - """ - splits { - abi { - enable true - reset() - include "x86", "x86_64" - universalApk false - } + val flavors = + if (withFlavors) { + """ + flavorDimensions "flavor" + productFlavors { + chocolate { + dimension "flavor" + } + vanilla { + dimension "flavor" + } + } + """.trimIndent() + } else { + "" + } + val abiSplits = + if (withAbiSplit) { + """ + splits { + abi { + enable true + reset() + include "x86", "x86_64" + universalApk false + } + } + """.trimIndent() + } else { + "" + } + val variant = + if (withFlavors) { + """variant = "chocolateDebug"""" + } else { + "" + } + val abi = + if (withAbiSplit) { + "abi = \"x86\"" + } else { + "" } - """.trimIndent() - } else "" - val variant = if (withFlavors) { """variant = "chocolateDebug"""" } else { "" } - val abi = if (withAbiSplit) { "abi = \"x86\"" } else "" writeBuildGradle( - """plugins { - id "com.osacky.fladle" - id "com.android.application" - } - repositories { - google() - mavenCentral() + """ + plugins { + id "com.osacky.fladle" + id "com.android.application" + } + repositories { + google() + mavenCentral() + } + android { + compileSdk 33 + namespace = "com.osacky.flank.gradle.sample" + defaultConfig { + applicationId "com.osacky.flank.gradle.sample" + minSdk 23 + targetSdk 33 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - android { - compileSdkVersion 29 - defaultConfig { - applicationId "com.osacky.flank.gradle.sample" - minSdkVersion 23 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - testOptions { - execution 'ANDROIDX_TEST_ORCHESTRATOR' - } - $flavors - $abiSplits - } - fladle { - serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-service.json") - dependOnAssemble = $dependsOnAssemble - $variant - $abi - $withFladleConfig - } - """.trimIndent() + testOptions { + execution 'ANDROIDX_TEST_ORCHESTRATOR' + } + $flavors + $abiSplits + } + fladle { + serviceAccountCredentials = project.layout.projectDirectory.file("flank-gradle-5cf02dc90531.json") + dependOnAssemble = $dependsOnAssemble + $variant + $abi + $withFladleConfig + } + """.trimIndent(), ) val arguments = mutableListOf(withTask) @@ -173,7 +197,8 @@ class VariantTests { } private fun writeBuildGradle(build: String) { - val file = testProjectRoot.newFile("build.gradle") + // Overwrite existing build.gradle file in "android-project" directory with new text + val file = File(testProjectRoot.root, "android-project/build.gradle") file.writeText(build) } } diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/validation/ValidateExclusionsTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/validation/ValidateExclusionsTest.kt index fc019bf7..0b5d05b4 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/validation/ValidateExclusionsTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/validation/ValidateExclusionsTest.kt @@ -28,12 +28,13 @@ class ValidateExclusionsTest { | maxTestShards.set(2) | flankVersion.set("21.01.0") |} - """.trimMargin() + """.trimMargin(), ) - val result = testProjectRoot.gradleRunner() - .withArguments("printYml") - .buildAndFail() + val result = + testProjectRoot.gradleRunner() + .withArguments("printYml") + .buildAndFail() assertThat(result.output).contains("FAILED") assertThat(result.output).contains("Options testShards and maxTestShards cannot be used together. Choose one of them.") @@ -59,7 +60,7 @@ class ValidateExclusionsTest { | } | } |} - """.trimMargin() + """.trimMargin(), ) testProjectRoot.writeEmptyServiceCredential() diff --git a/fladle-plugin/src/test/java/com/osacky/flank/gradle/validation/ValidateOptionsTest.kt b/fladle-plugin/src/test/java/com/osacky/flank/gradle/validation/ValidateOptionsTest.kt index d698da67..cde95f54 100644 --- a/fladle-plugin/src/test/java/com/osacky/flank/gradle/validation/ValidateOptionsTest.kt +++ b/fladle-plugin/src/test/java/com/osacky/flank/gradle/validation/ValidateOptionsTest.kt @@ -30,7 +30,9 @@ class ValidateOptionsTest { config.useAverageTestTimeForNewTests.set(true) assertThrows(IllegalStateException::class.java) { validateOptionsUsed(config, "20.05.0") }.run { - assertThat(message).containsMatch("Option useAverageTestTimeForNewTests is available since flank 20.8.4, which is higher than used 20.5.0") + assertThat( + message, + ).containsMatch("Option useAverageTestTimeForNewTests is available since flank 20.8.4, which is higher than used 20.5.0") } } @@ -53,7 +55,9 @@ class ValidateOptionsTest { try { validateOptionsUsed(config, "20.09.10") } catch (e: IllegalStateException) { - assertThat(e).hasMessageThat().contains("Option testTargetsForShard is available since flank 20.12.0, which is higher than used 20.9.10") + assertThat( + e, + ).hasMessageThat().contains("Option testTargetsForShard is available since flank 20.12.0, which is higher than used 20.9.10") } } @@ -79,7 +83,7 @@ class ValidateOptionsTest { | } | } |} - """.trimMargin() + """.trimMargin(), ) val runner = testProjectRoot.gradleRunner() @@ -117,7 +121,7 @@ class ValidateOptionsTest { | } | } |} - """.trimMargin() + """.trimMargin(), ) val runner = testProjectRoot.gradleRunner() @@ -148,7 +152,7 @@ class ValidateOptionsTest { | legacy-junit-result: false | full-junit-result: false | output-style: single - """.trimMargin() + """.trimMargin(), ) val resultOrange = runner.withArguments("printYmlNoRecord").build() @@ -178,7 +182,7 @@ class ValidateOptionsTest { | legacy-junit-result: false | full-junit-result: false | output-style: single - """.trimMargin() + """.trimMargin(), ) } } diff --git a/fladle-plugin/src/test/resources/android-library-project-flavors/build.gradle b/fladle-plugin/src/test/resources/android-library-project-flavors/build.gradle index 6d646bbe..73bcc57c 100644 --- a/fladle-plugin/src/test/resources/android-library-project-flavors/build.gradle +++ b/fladle-plugin/src/test/resources/android-library-project-flavors/build.gradle @@ -3,9 +3,10 @@ plugins { } android { - compileSdkVersion 29 + compileSdk 33 + namespace = "com.osacky.flank.gradle.sample" defaultConfig { - targetSdkVersion 29 + targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -26,11 +27,11 @@ android { } dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation("androidx.navigation:navigation-fragment-ktx:2.3.0") implementation 'androidx.constraintlayout:constraintlayout:2.0.1' - testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test:rules:1.3.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test:rules:1.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } diff --git a/fladle-plugin/src/test/resources/android-library-project-flavors/src/main/AndroidManifest.xml b/fladle-plugin/src/test/resources/android-library-project-flavors/src/main/AndroidManifest.xml index b4f20408..2d886939 100644 --- a/fladle-plugin/src/test/resources/android-library-project-flavors/src/main/AndroidManifest.xml +++ b/fladle-plugin/src/test/resources/android-library-project-flavors/src/main/AndroidManifest.xml @@ -1,11 +1,12 @@ - - + diff --git a/fladle-plugin/src/test/resources/android-library-project/build.gradle b/fladle-plugin/src/test/resources/android-library-project/build.gradle index 6fc1bd08..7890fc20 100644 --- a/fladle-plugin/src/test/resources/android-library-project/build.gradle +++ b/fladle-plugin/src/test/resources/android-library-project/build.gradle @@ -3,9 +3,10 @@ plugins { } android { - compileSdkVersion 29 + compileSdk 33 + namespace = "com.osacky.flank.gradle.sample" defaultConfig { - targetSdkVersion 29 + targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -16,12 +17,12 @@ android { } dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation("androidx.navigation:navigation-fragment-ktx:2.3.0") implementation 'androidx.constraintlayout:constraintlayout:2.0.1' - testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test:rules:1.3.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test:rules:1.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } diff --git a/fladle-plugin/src/test/resources/android-library-project/src/main/AndroidManifest.xml b/fladle-plugin/src/test/resources/android-library-project/src/main/AndroidManifest.xml index b4f20408..2d886939 100644 --- a/fladle-plugin/src/test/resources/android-library-project/src/main/AndroidManifest.xml +++ b/fladle-plugin/src/test/resources/android-library-project/src/main/AndroidManifest.xml @@ -1,11 +1,12 @@ - - + diff --git a/fladle-plugin/src/test/resources/android-project-flavors/build.gradle b/fladle-plugin/src/test/resources/android-project-flavors/build.gradle index 7a06d197..f9e08150 100644 --- a/fladle-plugin/src/test/resources/android-project-flavors/build.gradle +++ b/fladle-plugin/src/test/resources/android-project-flavors/build.gradle @@ -4,11 +4,12 @@ plugins { } android { - compileSdkVersion 29 + compileSdk 33 + namespace = "com.osacky.flank.gradle.sample" defaultConfig { applicationId "com.osacky.flank.gradle.sample" - minSdkVersion 23 - targetSdkVersion 29 + minSdk 23 + targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -16,7 +17,7 @@ android { testOptions { execution 'ANDROIDX_TEST_ORCHESTRATOR' } - flavorDimensions("flavor") + flavorDimensions += "flavor" productFlavors { create("chocolate") { @@ -29,12 +30,12 @@ android { } dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation("androidx.navigation:navigation-fragment-ktx:2.3.0") implementation 'androidx.constraintlayout:constraintlayout:2.0.1' - testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test:rules:1.3.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test:rules:1.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } diff --git a/fladle-plugin/src/test/resources/android-project-flavors/src/main/AndroidManifest.xml b/fladle-plugin/src/test/resources/android-project-flavors/src/main/AndroidManifest.xml index b4f20408..2d886939 100644 --- a/fladle-plugin/src/test/resources/android-project-flavors/src/main/AndroidManifest.xml +++ b/fladle-plugin/src/test/resources/android-project-flavors/src/main/AndroidManifest.xml @@ -1,11 +1,12 @@ - - + diff --git a/fladle-plugin/src/test/resources/android-project/build.gradle b/fladle-plugin/src/test/resources/android-project/build.gradle index 7da86ca4..3d4ab993 100644 --- a/fladle-plugin/src/test/resources/android-project/build.gradle +++ b/fladle-plugin/src/test/resources/android-project/build.gradle @@ -4,11 +4,12 @@ plugins { } android { - compileSdkVersion 29 + compileSdk 33 + namespace = "com.osacky.flank.gradle.sample" defaultConfig { applicationId "com.osacky.flank.gradle.sample" - minSdkVersion 23 - targetSdkVersion 29 + minSdk 23 + targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -45,12 +46,12 @@ fladle { } dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation("androidx.navigation:navigation-fragment-ktx:2.3.0") implementation 'androidx.constraintlayout:constraintlayout:2.0.1' - testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test:rules:1.3.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test:rules:1.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } diff --git a/fladle-plugin/src/test/resources/android-project/src/main/AndroidManifest.xml b/fladle-plugin/src/test/resources/android-project/src/main/AndroidManifest.xml index b4f20408..2d886939 100644 --- a/fladle-plugin/src/test/resources/android-project/src/main/AndroidManifest.xml +++ b/fladle-plugin/src/test/resources/android-project/src/main/AndroidManifest.xml @@ -1,11 +1,12 @@ - - + diff --git a/fladle-plugin/src/test/resources/android-project2/build.gradle b/fladle-plugin/src/test/resources/android-project2/build.gradle index 0dff4d89..9a1bc5bc 100644 --- a/fladle-plugin/src/test/resources/android-project2/build.gradle +++ b/fladle-plugin/src/test/resources/android-project2/build.gradle @@ -4,11 +4,12 @@ plugins { } android { - compileSdkVersion 29 + compileSdk 33 + namespace = "com.osacky.flank.gradle.sample" defaultConfig { applicationId "com.osacky.flank.gradle.sample" - minSdkVersion 23 - targetSdkVersion 29 + minSdk 23 + targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -48,12 +49,12 @@ fulladleModuleConfig { environmentVariables = ["clearPackageData": "false"] } dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation("androidx.navigation:navigation-fragment-ktx:2.3.0") implementation 'androidx.constraintlayout:constraintlayout:2.0.1' - testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test:rules:1.3.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test:rules:1.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } diff --git a/fladle-plugin/src/test/resources/android-project2/src/main/AndroidManifest.xml b/fladle-plugin/src/test/resources/android-project2/src/main/AndroidManifest.xml index b4f20408..2d886939 100644 --- a/fladle-plugin/src/test/resources/android-project2/src/main/AndroidManifest.xml +++ b/fladle-plugin/src/test/resources/android-project2/src/main/AndroidManifest.xml @@ -1,11 +1,12 @@ - - + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 965d0fba..f043dca4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ ben-manes-versions = { id = "com.github.ben-manes.versions", version = "0.51.0" } -kotlinter = { id = "org.jmailen.kotlinter", version = "3.9.0" } +kotlinter = { id = "org.jmailen.kotlinter", version = "4.0.0" } gradle-plugin-publish = {id = "com.gradle.plugin-publish", version = "1.2.1" } @@ -13,7 +13,7 @@ agp = { id = "com.android.application", version.ref = "agp-version"} [versions] -androidx-appcompat = "1.2.0" +androidx-appcompat = "1.6.1" androidx-constraintlayout = "1.1.3" @@ -21,14 +21,14 @@ androidx-navigation = "2.3.0" androidx-test-espresso = "3.5.1" -androidx-test-ext-junit = "1.1.1" +androidx-test-ext-junit = "1.1.5" androidx-test-rules = "1.5.0" junit-version = "4.13.2" -kotlin = "1.8.10" -agp-version = "4.2.2" +kotlin = "1.9.10" +agp-version = "7.4.0" flank-version = "23.10.1" [libraries] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index afba1092..7f93135c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b1624c47..3fa8f862 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/sample-android-library/build.gradle.kts b/sample-android-library/build.gradle.kts index 9e190848..751c6fca 100644 --- a/sample-android-library/build.gradle.kts +++ b/sample-android-library/build.gradle.kts @@ -17,13 +17,23 @@ fulladleModuleConfig { } android { - compileSdkVersion(29) + namespace = "com.osacky.flank.gradle.sample" + compileSdk = 33 defaultConfig { - minSdkVersion(23) - targetSdkVersion(29) + minSdk = 23 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } testOptions.execution = "ANDROIDX_TEST_ORCHESTRATOR" + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } } dependencies { diff --git a/sample-android-library/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt b/sample-android-library/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt index 639f7df8..ab896993 100644 --- a/sample-android-library/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt +++ b/sample-android-library/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt @@ -6,7 +6,6 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { - @Test fun seeView() { assert(true) diff --git a/sample-android-library/src/main/AndroidManifest.xml b/sample-android-library/src/main/AndroidManifest.xml index 8487ce01..8072ee00 100644 --- a/sample-android-library/src/main/AndroidManifest.xml +++ b/sample-android-library/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ - + diff --git a/sample-android-library/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt b/sample-android-library/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt index c0132658..964eb395 100644 --- a/sample-android-library/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt +++ b/sample-android-library/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt @@ -4,7 +4,6 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } diff --git a/sample-flavors-kotlin/build.gradle.kts b/sample-flavors-kotlin/build.gradle.kts index 9e9afadf..f4c1932b 100644 --- a/sample-flavors-kotlin/build.gradle.kts +++ b/sample-flavors-kotlin/build.gradle.kts @@ -5,39 +5,49 @@ plugins { } android { - compileSdkVersion(29) - defaultConfig { - applicationId = "com.osacky.flank.gradle.sample.kotlin" - minSdkVersion(23) - targetSdkVersion(29) - versionCode = 1 - versionName = "1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - testOptions.execution = "ANDROIDX_TEST_ORCHESTRATOR" - flavorDimensions("flavor") + namespace = "com.osacky.flank.gradle.sample.kotlin" + compileSdk = 33 + defaultConfig { + applicationId = "com.osacky.flank.gradle.sample.kotlin" + minSdk = 23 + versionCode = 1 + versionName = "1.0" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } - productFlavors { - create("chocolate") { - dimension = "flavor" - } - create("vanilla") { - dimension = "flavor" - } - } + testOptions.execution = "ANDROIDX_TEST_ORCHESTRATOR" + flavorDimensions += "flavor" + productFlavors { + create("chocolate") { + dimension = "flavor" + } + create("vanilla") { + dimension = "flavor" + } + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } } androidComponents { - beforeVariants(selector().withName("vanilla")) { variantBuilder -> - variantBuilder.enabled = false - } + beforeVariants(selector().withName("vanilla")) { variantBuilder -> + variantBuilder.enable = false + } } fladle { flankVersion.set("23.10.1") variant.set("chocolateDebug") - debugApk.set(project.provider { "${buildDir.toString()}/outputs/apk/chocolate/debug/*.apk" }) + debugApk.set(provider { layout.buildDirectory.file("/outputs/apk/chocolate/debug/*.apk").get().toString()}) serviceAccountCredentials.set(project.layout.projectDirectory.file("flank-gradle-5cf02dc90531.json")) // Project Id is not needed if serviceAccountCredentials are set. // projectId("flank-gradle") diff --git a/sample-flavors-kotlin/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt b/sample-flavors-kotlin/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt index 22f874dd..5d25f62c 100644 --- a/sample-flavors-kotlin/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt +++ b/sample-flavors-kotlin/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt @@ -14,7 +14,6 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { - @Rule @JvmField val testRule = ActivityTestRule(MainActivity::class.java) diff --git a/sample-flavors-kotlin/src/main/AndroidManifest.xml b/sample-flavors-kotlin/src/main/AndroidManifest.xml index c98c1b7f..12058c6f 100644 --- a/sample-flavors-kotlin/src/main/AndroidManifest.xml +++ b/sample-flavors-kotlin/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - - + diff --git a/sample-flavors-kotlin/src/main/java/com/osacky/flank/gradle/sample/kotlin/MainActivity.kt b/sample-flavors-kotlin/src/main/java/com/osacky/flank/gradle/sample/kotlin/MainActivity.kt index 5eb2507a..90fce2f0 100644 --- a/sample-flavors-kotlin/src/main/java/com/osacky/flank/gradle/sample/kotlin/MainActivity.kt +++ b/sample-flavors-kotlin/src/main/java/com/osacky/flank/gradle/sample/kotlin/MainActivity.kt @@ -4,7 +4,6 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) diff --git a/sample-kotlin/build.gradle.kts b/sample-kotlin/build.gradle.kts index de7b775d..93cc9d16 100644 --- a/sample-kotlin/build.gradle.kts +++ b/sample-kotlin/build.gradle.kts @@ -5,16 +5,26 @@ plugins { } android { - compileSdkVersion(29) - defaultConfig { - applicationId = "com.osacky.flank.gradle.sample.kotlin" - minSdkVersion(23) - targetSdkVersion(29) - versionCode = 1 - versionName = "1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - testOptions.execution = "ANDROIDX_TEST_ORCHESTRATOR" + namespace = "com.osacky.flank.gradle.sample.kotlin" + compileSdk = 33 + defaultConfig { + applicationId = "com.osacky.flank.gradle.sample.kotlin" + minSdk = 23 + versionCode = 1 + versionName = "1.0" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + testOptions.execution = "ANDROIDX_TEST_ORCHESTRATOR" +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } } fladle { diff --git a/sample-kotlin/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt b/sample-kotlin/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt index 90a4828c..57d1a72f 100644 --- a/sample-kotlin/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt +++ b/sample-kotlin/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt @@ -13,7 +13,6 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { - @Rule @JvmField val testRule = ActivityTestRule(MainActivity::class.java) diff --git a/sample-kotlin/src/main/AndroidManifest.xml b/sample-kotlin/src/main/AndroidManifest.xml index d527e8d3..4e2143cd 100644 --- a/sample-kotlin/src/main/AndroidManifest.xml +++ b/sample-kotlin/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - - + diff --git a/sample-kotlin/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt b/sample-kotlin/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt index d96b3e25..781d1f01 100644 --- a/sample-kotlin/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt +++ b/sample-kotlin/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt @@ -5,7 +5,6 @@ import androidx.appcompat.app.AppCompatActivity import com.osacky.flank.gradle.sample.kotlin.R class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) diff --git a/sample/build.gradle b/sample/build.gradle index 6a894ec2..19dc3426 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -3,11 +3,12 @@ apply plugin: 'kotlin-android' apply plugin: 'com.osacky.fladle' android { - compileSdkVersion 29 + compileSdk = 33 + namespace = "com.osacky.flank.gradle.sample" defaultConfig { applicationId "com.osacky.flank.gradle.sample" - minSdkVersion 23 - targetSdkVersion 29 + minSdk 23 + targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -15,6 +16,16 @@ android { testOptions { execution 'ANDROIDX_TEST_ORCHESTRATOR' } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } } fladle { diff --git a/sample/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt b/sample/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt index bd33fa61..2587b288 100644 --- a/sample/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt +++ b/sample/src/androidTest/java/com/osacky/flank/gradle/sample/ExampleInstrumentedTest.kt @@ -13,7 +13,6 @@ import java.lang.RuntimeException @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { - @Rule @JvmField val testRule = ActivityTestRule(MainActivity::class.java) diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index b6767e24..95244300 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - - + diff --git a/sample/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt b/sample/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt index 35264e91..bed8adcc 100644 --- a/sample/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt +++ b/sample/src/main/java/com/osacky/flank/gradle/sample/MainActivity.kt @@ -4,7 +4,6 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main)