Skip to content

Commit 94f877c

Browse files
danysantiagoDagger Team
authored andcommitted
Add hilt-android-testing to the Gradle projects
Also move out HiltCompilerTests utilities used in compile tests as those are not part of the runtime testing artifact. RELNOTES=N/A PiperOrigin-RevId: 794808342
1 parent 57a439b commit 94f877c

File tree

22 files changed

+187
-24
lines changed

22 files changed

+187
-24
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.3.1
2727
androidx-fragment = { module = "androidx.fragment:fragment", version = "1.5.1" }
2828
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version.ref = "lifecycle" }
2929
androidx-lifecycle-viewmodel-savedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "lifecycle" }
30+
androidx-multidex = { module = "androidx.multidex:multidex", version = "2.0.1" }
3031
androidx-savedstate = { module = "androidx.savedstate:savedstate", version = "1.2.0" }
3132
androidx-lint = { module = "androidx.lint:lint-gradle", version = "1.0.0-alpha04" }
3233
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version = "1.2.1" }
34+
androidx-test-core = { module = "androidx.test:core", version = "1.4.0" }
3335
auto-common = { module = "com.google.auto:auto-common", version = "1.2.1" }
3436
auto-factory-annotations = { module = "com.google.auto.factory:auto-factory", version.ref = "autoFactory" }
3537
auto-factory-compiler = { module = "com.google.auto.factory:auto-factory", version.ref = "autoFactory" }
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
public abstract class dagger/hilt/android/internal/testing/EarlySingletonComponentCreator {
2+
public fun <init> ()V
3+
}
4+
5+
public abstract interface annotation class dagger/hilt/android/internal/testing/InternalTestRoot : java/lang/annotation/Annotation {
6+
public abstract fun applicationBaseClass ()Ljava/lang/Class;
7+
public abstract fun testClass ()Ljava/lang/Class;
8+
}
9+
10+
public final class dagger/hilt/android/internal/testing/MarkThatRulesRanRule : org/junit/rules/TestRule {
11+
public fun <init> (Ljava/lang/Object;)V
12+
public fun apply (Lorg/junit/runners/model/Statement;Lorg/junit/runner/Description;)Lorg/junit/runners/model/Statement;
13+
public fun componentReady ()V
14+
public fun delayComponentReady ()V
15+
public fun inject ()V
16+
}
17+
18+
public final class dagger/hilt/android/internal/testing/TestApplicationComponentManager : dagger/hilt/android/testing/OnComponentReadyRunner$OnComponentReadyRunnerHolder, dagger/hilt/internal/TestSingletonComponentManager {
19+
public fun <init> (Landroid/app/Application;)V
20+
public fun earlySingletonComponent ()Ljava/lang/Object;
21+
public fun generatedComponent ()Ljava/lang/Object;
22+
public fun getDescription ()Lorg/junit/runner/Description;
23+
public fun getOnComponentReadyRunner ()Ldagger/hilt/android/testing/OnComponentReadyRunner;
24+
public fun getTestInstance ()Ljava/lang/Object;
25+
public fun registerModule (Ljava/lang/Class;Ljava/lang/Object;)V
26+
}
27+
28+
public abstract interface class dagger/hilt/android/internal/testing/TestApplicationComponentManagerHolder : dagger/hilt/internal/GeneratedComponentManagerHolder {
29+
}
30+
31+
public final class dagger/hilt/android/internal/testing/TestComponentData {
32+
public fun <init> (ZLdagger/hilt/android/internal/testing/TestInjector;Ljava/util/Set;Ljava/util/Set;Ldagger/hilt/android/internal/testing/TestComponentData$ComponentSupplier;)V
33+
public fun componentSupplier ()Ldagger/hilt/android/internal/testing/TestComponentData$ComponentSupplier;
34+
public fun daggerRequiredModules ()Ljava/util/Set;
35+
public fun hiltRequiredModules ()Ljava/util/Set;
36+
public fun testInjector ()Ldagger/hilt/android/internal/testing/TestInjector;
37+
public fun waitForBindValue ()Z
38+
}
39+
40+
public abstract interface class dagger/hilt/android/internal/testing/TestComponentData$ComponentSupplier {
41+
public abstract fun get (Ljava/util/Map;Ljava/lang/Object;Ljava/lang/Boolean;)Ljava/lang/Object;
42+
}
43+
44+
public abstract class dagger/hilt/android/internal/testing/TestComponentDataSupplier {
45+
public fun <init> ()V
46+
protected abstract fun get ()Ldagger/hilt/android/internal/testing/TestComponentData;
47+
}
48+
49+
public abstract interface class dagger/hilt/android/internal/testing/TestInjector {
50+
public abstract fun injectTest (Ljava/lang/Object;)V
51+
}
52+
53+
public abstract interface annotation class dagger/hilt/android/internal/uninstallmodules/AggregatedUninstallModules : java/lang/annotation/Annotation {
54+
public abstract fun test ()Ljava/lang/String;
55+
public abstract fun uninstallModules ()[Ljava/lang/String;
56+
}
57+
58+
public abstract interface annotation class dagger/hilt/android/testing/BindElementsIntoSet : java/lang/annotation/Annotation {
59+
}
60+
61+
public abstract interface annotation class dagger/hilt/android/testing/BindValue : java/lang/annotation/Annotation {
62+
}
63+
64+
public abstract interface annotation class dagger/hilt/android/testing/BindValueIntoMap : java/lang/annotation/Annotation {
65+
}
66+
67+
public abstract interface annotation class dagger/hilt/android/testing/BindValueIntoSet : java/lang/annotation/Annotation {
68+
}
69+
70+
public abstract interface annotation class dagger/hilt/android/testing/CustomTestApplication : java/lang/annotation/Annotation {
71+
public abstract fun value ()Ljava/lang/Class;
72+
}
73+
74+
public final class dagger/hilt/android/testing/HiltAndroidRule : org/junit/rules/TestRule {
75+
public fun <init> (Ljava/lang/Object;)V
76+
public fun apply (Lorg/junit/runners/model/Statement;Lorg/junit/runner/Description;)Lorg/junit/runners/model/Statement;
77+
public fun componentReady ()Ldagger/hilt/android/testing/HiltAndroidRule;
78+
public fun delayComponentReady ()Ldagger/hilt/android/testing/HiltAndroidRule;
79+
public fun inject ()V
80+
}
81+
82+
public abstract interface annotation class dagger/hilt/android/testing/HiltAndroidTest : java/lang/annotation/Annotation {
83+
}
84+
85+
public final class dagger/hilt/android/testing/HiltTestApplication : androidx/multidex/MultiDexApplication, dagger/hilt/android/internal/testing/TestApplicationComponentManagerHolder, dagger/hilt/internal/GeneratedComponentManager {
86+
public fun <init> ()V
87+
public final fun componentManager ()Ldagger/hilt/internal/GeneratedComponentManager;
88+
public final fun generatedComponent ()Ljava/lang/Object;
89+
}
90+
91+
public final class dagger/hilt/android/testing/OnComponentReadyRunner {
92+
public fun <init> ()V
93+
public static fun addListener (Landroid/content/Context;Ljava/lang/Class;Ldagger/hilt/android/testing/OnComponentReadyRunner$OnComponentReadyListener;)V
94+
public fun isEmpty ()Z
95+
public fun setComponentManager (Ldagger/hilt/internal/GeneratedComponentManager;)V
96+
}
97+
98+
public abstract interface class dagger/hilt/android/testing/OnComponentReadyRunner$OnComponentReadyListener {
99+
public abstract fun onComponentReady (Ljava/lang/Object;)V
100+
}
101+
102+
public abstract interface class dagger/hilt/android/testing/OnComponentReadyRunner$OnComponentReadyRunnerHolder {
103+
public abstract fun getOnComponentReadyRunner ()Ldagger/hilt/android/testing/OnComponentReadyRunner;
104+
}
105+
106+
public abstract interface annotation class dagger/hilt/android/testing/SkipTestInjection : java/lang/annotation/Annotation {
107+
}
108+
109+
public abstract interface annotation class dagger/hilt/android/testing/UninstallModules : java/lang/annotation/Annotation {
110+
public abstract fun value ()[Ljava/lang/Class;
111+
}
112+
113+
public abstract interface annotation class dagger/hilt/testing/TestInstallIn : java/lang/annotation/Annotation {
114+
public abstract fun components ()[Ljava/lang/Class;
115+
public abstract fun replaces ()[Ljava/lang/Class;
116+
}
117+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import dagger.gradle.build.SoftwareType
2+
import dagger.gradle.build.findXProcessingJar
3+
4+
plugins {
5+
alias(libs.plugins.daggerBuild)
6+
id(libs.plugins.android.library.get().pluginId)
7+
id(libs.plugins.kotlinAndroid.get().pluginId)
8+
id(libs.plugins.binaryCompatibilityValidator.get().pluginId)
9+
}
10+
11+
dependencies {
12+
api(project(":dagger"))
13+
api(project(":hilt-android"))
14+
15+
api(libs.androidx.activity)
16+
api(libs.androidx.annotations)
17+
api(libs.androidx.fragment)
18+
api(libs.androidx.lifecycle.viewmodel)
19+
api(libs.androidx.lifecycle.viewmodel.savedstate)
20+
api(libs.androidx.multidex)
21+
api(libs.androidx.savedstate)
22+
api(libs.androidx.test.core)
23+
api(libs.junit)
24+
implementation(libs.auto.value.annotations)
25+
implementation(libs.findBugs)
26+
implementation(libs.kotlin.stdlib)
27+
28+
annotationProcessor(project(":dagger-compiler", "unshaded"))
29+
annotationProcessor(project(":hilt-compiler", "unshaded"))
30+
annotationProcessor(libs.auto.common)
31+
annotationProcessor(files(project.findXProcessingJar()))
32+
annotationProcessor(libs.auto.value.compiler)
33+
}
34+
35+
daggerBuild {
36+
type = SoftwareType.ANDROID_LIBRARY
37+
isPublished = true
38+
}
39+
40+
android { namespace = "dagger.hilt.android.testing" }
41+
42+
kotlin { explicitApi() }

hilt-android/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ daggerBuild {
4141
isPublished = true
4242
}
4343

44-
android { namespace = "dagger.android" }
44+
android { namespace = "dagger.hilt.android" }
4545

4646
kotlin { explicitApi() }

javatests/dagger/hilt/android/processor/internal/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ compiler_test(
2828
deps = [
2929
"//dagger-compiler:xprocessing",
3030
"//dagger-compiler/main/java/dagger/internal/codegen/xprocessing:xprocessing-testing",
31-
"//hilt-android-testing/main/java/dagger/hilt/android/testing/compile",
31+
"//hilt-testing/main/java/dagger/hilt/android/testing/compile",
3232
"//third_party/java/guava/base",
3333
"//third_party/java/junit",
3434
"//third_party/java/truth",

javatests/dagger/hilt/android/processor/internal/aggregateddeps/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ compiler_test(
3333
],
3434
deps = [
3535
"//dagger-compiler/main/java/dagger/internal/codegen/xprocessing:xprocessing-testing",
36-
"//hilt-android-testing/main/java/dagger/hilt/android/testing/compile",
36+
"//hilt-testing/main/java/dagger/hilt/android/testing/compile",
3737
"//third_party/java/compile_testing",
3838
"//third_party/java/junit",
3939
],
@@ -52,7 +52,7 @@ compiler_test(
5252
],
5353
deps = [
5454
"//dagger-compiler/main/java/dagger/internal/codegen/xprocessing:xprocessing-testing",
55-
"//hilt-android-testing/main/java/dagger/hilt/android/testing/compile",
55+
"//hilt-testing/main/java/dagger/hilt/android/testing/compile",
5656
"//third_party/java/junit",
5757
],
5858
)

javatests/dagger/hilt/android/processor/internal/androidentrypoint/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ compiler_test(
2828
]),
2929
deps = [
3030
"//dagger-compiler/main/java/dagger/internal/codegen/xprocessing:xprocessing-testing",
31-
"//hilt-android-testing/main/java/dagger/hilt/android/testing/compile",
31+
"//hilt-testing/main/java/dagger/hilt/android/testing/compile",
3232
"//java/dagger/testing/golden",
3333
"//third_party/java/junit",
3434
],
@@ -45,8 +45,8 @@ compiler_test(
4545
deps = [
4646
"//dagger-compiler:xprocessing",
4747
"//dagger-compiler/main/java/dagger/internal/codegen/xprocessing:xprocessing-testing",
48-
"//hilt-android-testing/main/java/dagger/hilt/android/testing/compile",
4948
"//hilt-compiler/main/java/dagger/hilt/processor/internal:base_processor",
49+
"//hilt-testing/main/java/dagger/hilt/android/testing/compile",
5050
"//third_party/java/guava/collect",
5151
"//third_party/java/javapoet",
5252
"//third_party/java/junit",
@@ -63,7 +63,7 @@ kt_compiler_test(
6363
],
6464
deps = [
6565
"//dagger-compiler/main/java/dagger/internal/codegen/xprocessing:xprocessing-testing",
66-
"//hilt-android-testing/main/java/dagger/hilt/android/testing/compile",
66+
"//hilt-testing/main/java/dagger/hilt/android/testing/compile",
6767
"//third_party/java/guava/collect",
6868
"//third_party/java/junit",
6969
"//third_party/java/truth",

0 commit comments

Comments
 (0)