buildSrc/src/main/kotlin/Avdl.kt
changeset 19 91a3ad3b1b9c
parent 10 9aad34f43f71
child 20 5d8a0555733d
equal deleted inserted replaced
18:3ccb29f83309 19:91a3ad3b1b9c
    44 
    44 
    45 
    45 
    46 fun Project.configureAvdlDevices(flydroidUrl: String, flydroidKey: String) {
    46 fun Project.configureAvdlDevices(flydroidUrl: String, flydroidKey: String) {
    47     apply<FlydroidPlugin>()
    47     apply<FlydroidPlugin>()
    48 
    48 
       
    49     // as FlydroidPlugin add some repositories to look for dependencies
       
    50     // the repositories set in settings.gradle.kts via dependencyResolutionManagement
       
    51     // are ignored because we are in mode PREFER_PROJECT
       
    52     // to fix that we add the missing repository here too
       
    53     repositories { // this mirror contents in settings.gradle.kts
       
    54         google {
       
    55             content {
       
    56                 includeGroupByRegex("""android\.arch\..*""")
       
    57                 includeGroupByRegex("""androidx\..*""")
       
    58                 includeGroupByRegex("""com\.android\..*""")
       
    59                 includeGroupByRegex("""com\.google\..*""")
       
    60                 includeGroup("com.crashlytics.sdk.android")
       
    61                 includeGroup("io.fabric.sdk.android")
       
    62                 includeGroup("org.chromium.net")
       
    63                 includeGroup("zipflinger")
       
    64                 includeGroup("com.android")
       
    65             }
       
    66         }
       
    67         mavenCentral()
       
    68         // for geekdroid
       
    69         flatDir {
       
    70             dirs("$rootDir/libs")
       
    71         }
       
    72         maven {
       
    73             url = uri("https://jitpack.io")
       
    74         }
       
    75 
       
    76     }
    49     val oneInstrumentedTestService = gradle.sharedServices.registerIfAbsent(
    77     val oneInstrumentedTestService = gradle.sharedServices.registerIfAbsent(
    50             "oneInstrumentedTest", OneInstrumentedTestService::class.java) {
    78             "oneInstrumentedTest", OneInstrumentedTestService::class.java) {
    51         maxParallelUsages.set(1)
    79         maxParallelUsages.set(1)
    52     }
    80     }
    53 
    81 
    55 
    83 
    56     val android = the<TestedExtension>()
    84     val android = the<TestedExtension>()
    57     configure<AvdlExtension> {
    85     configure<AvdlExtension> {
    58         devices {
    86         devices {
    59             android.testVariants.all {
    87             android.testVariants.all {
    60                 register("android-n-${project.path}-$baseName") {
    88                 register("android-p-${project.path}-$baseName") {
    61                     setup = flydroid {
    89                     setup = flydroid {
    62                         url = flydroidUrl
    90                         url = flydroidUrl
    63                         this.flydroidKey = flydroidKey
    91                         this.flydroidKey = flydroidKey
    64                         // android-q images fail, don't manage to start the tests
    92                         // android-q images fail, don't manage to start the tests
    65                         image = "android-n"
    93                         image = "android-p"
    66                          useTunnel = true
    94                          useTunnel = true
    67                     }
    95                     }
    68                 }
    96                 }
    69             }
    97             }
    70         }
    98         }
    73     tasks {
   101     tasks {
    74         var lastStopTask: TaskProvider<out Task>? = null
   102         var lastStopTask: TaskProvider<out Task>? = null
    75         var lastTestTask: TaskProvider<out Task>? = null
   103         var lastTestTask: TaskProvider<out Task>? = null
    76         android.testVariants.all {
   104         android.testVariants.all {
    77             val (startTask, stopTask ) =
   105             val (startTask, stopTask ) =
    78                 registerAvdlDevicesTaskForVariant(this, listOf("android-n-${project.path}-$baseName"))
   106                 registerAvdlDevicesTaskForVariant(this, listOf("android-p-${project.path}-$baseName"))
    79             listOf(startTask, stopTask).forEach {
   107             listOf(startTask, stopTask).forEach {
    80                 it.configure {
   108                 it.configure {
    81                     usesService(oneInstrumentedTestService)
   109                     usesService(oneInstrumentedTestService)
    82                 }
   110                 }
    83             }
   111             }