xref: /aosp_15_r20/external/dagger2/javatests/artifacts/hilt-android/simple/earlyentrypoint/build.gradle (revision f585d8a307d0621d6060bd7e80091fdcbf94fe27)
1plugins {
2    id 'com.android.library'
3    id 'com.google.dagger.hilt.android'
4}
5
6android {
7    compileSdkVersion 33
8    buildToolsVersion "33.0.0"
9
10    defaultConfig {
11        minSdkVersion 16
12        targetSdkVersion 33
13        versionCode 1
14        versionName "1.0"
15    }
16    compileOptions {
17        sourceCompatibility JavaVersion.VERSION_11
18        targetCompatibility JavaVersion.VERSION_11
19    }
20    testOptions {
21        unitTests.includeAndroidResources = true
22    }
23}
24
25hilt {
26    enableTransformForLocalTests = true
27    enableAggregatingTask = true
28}
29
30// This is a regression test for https://github.com/google/dagger/issues/2789.
31// Reproducing this issue requires that we don't have unexpected tests, so this
32// check validates that. In particular, if we accidentally add a test with no
33// test-specific bindings the EarlyEntryPoints will use the component for that
34// test instead of generating a component just for the EarlyEntryPoints, which
35// causes this issue.
36task checkSourceSetTask(){
37    sourceSets {
38        test {
39            def actualSrcs = allSource.files.name as Set
40            def expectedSrcs = [
41                'EarlyEntryPointWithBindValueTest.java',
42                'EarlyEntryPointWithBindValueObjects.java'
43            ] as Set
44            if (!actualSrcs.equals(expectedSrcs)) {
45                throw new StopExecutionException(
46                    'Unexpected test sources: ' + allSource.files.name)
47            }
48        }
49    }
50}
51
52gradle.projectsEvaluated {
53    preBuild.dependsOn checkSourceSetTask
54}
55
56dependencies {
57    implementation "com.google.dagger:hilt-android:$dagger_version"
58    annotationProcessor "com.google.dagger:hilt-compiler:$dagger_version"
59
60    testImplementation 'com.google.truth:truth:1.0.1'
61    testImplementation 'junit:junit:4.13'
62    testImplementation 'org.robolectric:robolectric:4.5-alpha-3'
63    testImplementation 'androidx.core:core:1.3.2'
64    testImplementation 'androidx.test.ext:junit:1.1.3'
65    testImplementation 'androidx.test:runner:1.4.0'
66    testImplementation "com.google.dagger:hilt-android-testing:$dagger_version"
67    testAnnotationProcessor "com.google.dagger:hilt-compiler:$dagger_version"
68}
69