build.gradle.kts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. plugins {
  2. alias(libs.plugins.android.test)
  3. alias(libs.plugins.baselineprofile)
  4. }
  5. android {
  6. namespace = "io.legado.baselineprofile"
  7. compileSdk {
  8. version = release(36) {
  9. minorApiLevel = 1
  10. }
  11. }
  12. compileOptions {
  13. sourceCompatibility = JavaVersion.VERSION_11
  14. targetCompatibility = JavaVersion.VERSION_11
  15. }
  16. defaultConfig {
  17. minSdk = 28
  18. targetSdk = 37
  19. testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
  20. testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = "DEBUGGABLE"
  21. }
  22. targetProjectPath = ":app"
  23. flavorDimensions += listOf("mode")
  24. productFlavors {
  25. create("app") { dimension = "mode" }
  26. }
  27. }
  28. // This is the configuration block for the Baseline Profile plugin.
  29. // You can specify to run the generators on a managed devices or connected devices.
  30. baselineProfile {
  31. // managedDevices += "pixel6Api34"
  32. useConnectedDevices = true
  33. }
  34. dependencies {
  35. implementation(libs.androidx.benchmark.macro.junit4)
  36. implementation(libs.androidx.espresso.core)
  37. implementation(libs.androidx.junit)
  38. implementation(libs.androidx.uiautomator)
  39. }
  40. androidComponents {
  41. beforeVariants { v ->
  42. if (v.buildType == "noR8" || v.buildType == "debug") {
  43. v.enable = false
  44. }
  45. }
  46. onVariants { v ->
  47. val artifactsLoader = v.artifacts.getBuiltArtifactsLoader()
  48. v.instrumentationRunnerArguments.put(
  49. "targetAppId",
  50. v.testedApks.map { artifactsLoader.load(it)?.applicationId }
  51. )
  52. }
  53. }