1plugins {
2    id 'java-library'
3}
4apply plugin: AarDepsPlugin
5
6final String GIT_BRANCH = ""
7final int BUILD_ID = -1
8
9java {
10    sourceCompatibility = JavaVersion.VERSION_17
11    targetCompatibility = JavaVersion.VERSION_17
12}
13
14sourceSets {
15  main {
16    java.srcDirs = [
17            "src",
18            "${ANDROID_TOP}/external/robolectric/utils/src/main/java/",
19            "${ANDROID_TOP}/external/robolectric/resources/src/main/java/",
20            "${ANDROID_TOP}/external/robolectric/nativeruntime/src/main/java/",
21            "${ANDROID_TOP}/external/robolectric/sandbox/src/main/java/",
22            "${ANDROID_TOP}/external/robolectric/robolectric/src/main/java/",
23            //shadow jar code
24            "${ANDROID_TOP}/external/robolectric/shadows/framework/src/main/java/",
25            //android specific robolectric extensions
26            "${ANDROID_TOP}/test/robolectric-extensions/plugins/src/main/java/"
27    ]
28    resources.srcDirs = [
29            "${ANDROID_TOP}/test/robolectric-extensions/resources/",
30            "${ANDROID_TOP}/prebuilts/misc/common/robolectric-native-prebuilt/resources/"
31      ]
32  }
33}
34
35task generateBuildConfig {
36    ext.outputDir = "$buildDir/generated/java"
37    inputs.property('version', project.version)
38    outputs.dir outputDir
39    doLast {
40        mkdir "$outputDir/com/google/android/sysui"
41        file("$outputDir/com/google/android/sysui/BuildConfig.java").text =
42                """|package com.google.android.sysui;
43               |class BuildConfig {
44               |    public static final String OUT_PATH = "$buildDir";
45               |}""".stripMargin()
46    }
47}
48
49task downloadAndroidAll(type: RoboJarFetcherTask) {
50    rootPath = ANDROID_TOP
51    outPath = buildDir
52    suggestedGitBranch = GIT_BRANCH
53    buildId = BUILD_ID
54}
55
56compileJava {
57    options.compilerArgs << '-Aorg.robolectric.annotation.processing.shadowPackage=org.robolectric'
58    dependsOn generateBuildConfig
59    dependsOn downloadAndroidAll
60}
61sourceSets.main.java.srcDir generateBuildConfig.outputDir
62
63dependencies {
64    api libs.robolectric
65    // Dependencies for shadow jar code:
66    api 'androidx.annotation:annotation-jvm:1.6.0@jar'
67    annotationProcessor 'com.google.auto.service:auto-service:1.0.1'
68    compileOnly 'com.google.auto.service:auto-service-annotations:1.0.1'
69    // Robolectic specific configurations for code generation (of shadow jar code)
70    annotationProcessor 'org.robolectric:processor:4.11-SNAPSHOT'
71    annotationProcessor 'com.google.auto.service:auto-service:1.0.1'
72    implementation 'com.google.auto.service:auto-service-annotations:1.0.1'
73    implementation 'junit:junit:4.13.2'
74    implementation 'org.conscrypt:conscrypt-openjdk-uber:2.5.2'
75    api 'androidx.test.espresso:espresso-core:3.6.0-alpha1@aar'
76    api 'androidx.test.espresso:espresso-idling-resource:3.6.0-alpha1@aar'
77
78
79    // Android-all jar
80    implementation fileTree(dir: "${buildDir}/android_all/", include: '*.jar')
81}
82