aboutsummaryrefslogtreecommitdiff
path: root/java/dagger/hilt/android/plugin/main/src/test/kotlin/IncrementalProcessorTest.kt
diff options
context:
space:
mode:
authorSadaf Ebrahimi <sadafebrahimi@google.com>2024-03-05 22:32:05 +0000
committerSadaf Ebrahimi <sadafebrahimi@google.com>2024-04-10 16:26:18 +0000
commit6e122a5665bfe6169574f578311d44f81d3882d3 (patch)
tree8c39faf93432b4da3e7ef07f5643befaa87ec726 /java/dagger/hilt/android/plugin/main/src/test/kotlin/IncrementalProcessorTest.kt
parent7a2c823d73c7cf0fff8a3f1e622aae46c546fa03 (diff)
parent0786d0af598028098849cb88a16b72549f238dcc (diff)
downloaddagger2-6e122a5665bfe6169574f578311d44f81d3882d3.tar.gz
Upgrade dagger2 to dagger-2.51
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update dagger2 For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I6a876e5d65cdd1d83ad3db931a09c349bdfa17cd
Diffstat (limited to 'java/dagger/hilt/android/plugin/main/src/test/kotlin/IncrementalProcessorTest.kt')
-rw-r--r--java/dagger/hilt/android/plugin/main/src/test/kotlin/IncrementalProcessorTest.kt1291
1 files changed, 668 insertions, 623 deletions
diff --git a/java/dagger/hilt/android/plugin/main/src/test/kotlin/IncrementalProcessorTest.kt b/java/dagger/hilt/android/plugin/main/src/test/kotlin/IncrementalProcessorTest.kt
index 1e8490f1b..4fb25a0b3 100644
--- a/java/dagger/hilt/android/plugin/main/src/test/kotlin/IncrementalProcessorTest.kt
+++ b/java/dagger/hilt/android/plugin/main/src/test/kotlin/IncrementalProcessorTest.kt
@@ -34,11 +34,9 @@ import org.junit.runners.Parameterized
@RunWith(Parameterized::class)
class IncrementalProcessorTest(private val incapMode: String) {
- @get:Rule
- val testProjectDir = TemporaryFolder()
+ @get:Rule val testProjectDir = TemporaryFolder()
- @get:Rule
- val expect: Expect = Expect.create()
+ @get:Rule val expect: Expect = Expect.create()
// Original source files
private lateinit var srcApp: File
@@ -108,16 +106,18 @@ class IncrementalProcessorTest(private val incapMode: String) {
private lateinit var unchangedFiles: Set<File>
private lateinit var deletedFiles: Set<File>
- private val compileTaskName = if (incapMode == ISOLATING_MODE) {
- ":hiltJavaCompileDebug"
- } else {
- ":compileDebugJavaWithJavac"
- }
- private val testCompileTaskName = if (incapMode == ISOLATING_MODE) {
- ":hiltJavaCompileDebugUnitTest"
- } else {
- ":compileDebugUnitTestJavaWithJavac"
- }
+ private val compileTaskName =
+ if (incapMode == ISOLATING_MODE) {
+ ":hiltJavaCompileDebug"
+ } else {
+ ":compileDebugJavaWithJavac"
+ }
+ private val testCompileTaskName =
+ if (incapMode == ISOLATING_MODE) {
+ ":hiltJavaCompileDebugUnitTest"
+ } else {
+ ":compileDebugUnitTestJavaWithJavac"
+ }
private val aggregatingTaskName = ":hiltAggregateDepsDebug"
private val testAggregatingTaskName = ":hiltAggregateDepsDebugUnitTest"
@@ -128,8 +128,9 @@ class IncrementalProcessorTest(private val incapMode: String) {
File("src/test/data/simple-project").copyRecursively(projectRoot)
// set up build file
- File(projectRoot, "build.gradle").writeText(
- """
+ File(projectRoot, "build.gradle")
+ .writeText(
+ """
buildscript {
repositories {
google()
@@ -146,13 +147,13 @@ class IncrementalProcessorTest(private val incapMode: String) {
}
android {
- compileSdkVersion 32
- buildToolsVersion "32.0.0"
+ compileSdkVersion 33
+ buildToolsVersion "33.0.0"
defaultConfig {
applicationId "hilt.simple"
minSdkVersion 21
- targetSdkVersion 32
+ targetSdkVersion 33
javaCompileOptions {
annotationProcessorOptions {
arguments += ["dagger.hilt.shareTestComponents" : "true"]
@@ -190,32 +191,36 @@ class IncrementalProcessorTest(private val incapMode: String) {
hilt {
enableAggregatingTask = ${if (incapMode == ISOLATING_MODE) "true" else "false"}
}
- """.trimIndent()
- )
+ """
+ .trimIndent()
+ )
// Compute directory paths
val defaultGenSrcDir = "build/generated/ap_generated_sources/debug/out/"
- fun getComponentTreeDepsGenSrcDir(variant: String) = if (incapMode == ISOLATING_MODE) {
- "build/generated/hilt/component_trees/$variant/"
- } else {
- "build/generated/ap_generated_sources/$variant/out/"
- }
+ fun getComponentTreeDepsGenSrcDir(variant: String) =
+ if (incapMode == ISOLATING_MODE) {
+ "build/generated/hilt/component_trees/$variant/"
+ } else {
+ "build/generated/ap_generated_sources/$variant/out/"
+ }
val componentTreeDepsGenSrcDir = getComponentTreeDepsGenSrcDir("debug")
val testComponentTreeDepsGenSrcDir = getComponentTreeDepsGenSrcDir("debugUnitTest")
- fun getRootGenSrcDir(variant: String) = if (incapMode == ISOLATING_MODE) {
- "build/generated/hilt/component_sources/$variant/"
- } else {
- "build/generated/ap_generated_sources/$variant/out/"
- }
+ fun getRootGenSrcDir(variant: String) =
+ if (incapMode == ISOLATING_MODE) {
+ "build/generated/hilt/component_sources/$variant/"
+ } else {
+ "build/generated/ap_generated_sources/$variant/out/"
+ }
val rootGenSrcDir = getRootGenSrcDir("debug")
val testRootGenSrcDir = getRootGenSrcDir("debugUnitTest")
val defaultClassesDir = "build/intermediates/javac/debug/classes"
val testDefaultClassesDir = "build/intermediates/javac/debugUnitTest/classes"
- fun getRootClassesDir(variant: String) = if (incapMode == ISOLATING_MODE) {
- "build/intermediates/hilt/component_classes/$variant/"
- } else {
- "build/intermediates/javac/$variant/classes"
- }
+ fun getRootClassesDir(variant: String) =
+ if (incapMode == ISOLATING_MODE) {
+ "build/intermediates/hilt/component_classes/$variant/"
+ } else {
+ "build/intermediates/javac/$variant/classes"
+ }
val rootClassesDir = getRootClassesDir("debug")
val testRootClassesDir = getRootClassesDir("debugUnitTest")
@@ -236,59 +241,64 @@ class IncrementalProcessorTest(private val incapMode: String) {
File(projectRoot, "$defaultGenSrcDir/simple/Activity1_GeneratedInjector.java")
genActivityInjector2 =
File(projectRoot, "$defaultGenSrcDir/simple/Activity2_GeneratedInjector.java")
- genAppInjectorDeps = File(
- projectRoot,
- "$defaultGenSrcDir/hilt_aggregated_deps/_simple_SimpleApp_GeneratedInjector.java"
- )
- genActivityInjectorDeps1 = File(
- projectRoot,
- "$defaultGenSrcDir/hilt_aggregated_deps/_simple_Activity1_GeneratedInjector.java"
- )
- genActivityInjectorDeps2 = File(
- projectRoot,
- "$defaultGenSrcDir/hilt_aggregated_deps/_simple_Activity2_GeneratedInjector.java"
- )
- genModuleDeps1 = File(
- projectRoot,
- "$defaultGenSrcDir/hilt_aggregated_deps/_simple_Module1.java"
- )
+ genAppInjectorDeps =
+ File(
+ projectRoot,
+ "$defaultGenSrcDir/hilt_aggregated_deps/_simple_SimpleApp_GeneratedInjector.java"
+ )
+ genActivityInjectorDeps1 =
+ File(
+ projectRoot,
+ "$defaultGenSrcDir/hilt_aggregated_deps/_simple_Activity1_GeneratedInjector.java"
+ )
+ genActivityInjectorDeps2 =
+ File(
+ projectRoot,
+ "$defaultGenSrcDir/hilt_aggregated_deps/_simple_Activity2_GeneratedInjector.java"
+ )
+ genModuleDeps1 =
+ File(projectRoot, "$defaultGenSrcDir/hilt_aggregated_deps/_simple_Module1.java")
genModuleDeps2 =
File(projectRoot, "$defaultGenSrcDir/hilt_aggregated_deps/_simple_Module2.java")
genComponentTreeDeps =
File(projectRoot, "$componentTreeDepsGenSrcDir/simple/SimpleApp_ComponentTreeDeps.java")
genHiltComponents = File(projectRoot, "$rootGenSrcDir/simple/SimpleApp_HiltComponents.java")
- genDaggerHiltApplicationComponent = File(
- projectRoot,
- "$rootGenSrcDir/simple/DaggerSimpleApp_HiltComponents_SingletonC.java"
- )
- genTest1ComponentTreeDeps = File(
- projectRoot,
- testComponentTreeDepsGenSrcDir +
- "/dagger/hilt/android/internal/testing/root/Test1_ComponentTreeDeps.java"
- )
- genTest2ComponentTreeDeps = File(
- projectRoot,
- testComponentTreeDepsGenSrcDir +
- "/dagger/hilt/android/internal/testing/root/Test2_ComponentTreeDeps.java"
- )
- genTest1HiltComponents = File(
- projectRoot,
- "$testRootGenSrcDir/dagger/hilt/android/internal/testing/root/Test1_HiltComponents.java"
- )
- genTest2HiltComponents = File(
- projectRoot,
- "$testRootGenSrcDir/dagger/hilt/android/internal/testing/root/Test2_HiltComponents.java"
- )
- genTest1DaggerHiltApplicationComponent = File(
- projectRoot,
- testRootGenSrcDir +
- "/dagger/hilt/android/internal/testing/root/DaggerTest1_HiltComponents_SingletonC.java"
- )
- genTest2DaggerHiltApplicationComponent = File(
- projectRoot,
- testRootGenSrcDir +
- "/dagger/hilt/android/internal/testing/root/DaggerTest2_HiltComponents_SingletonC.java"
- )
+ genDaggerHiltApplicationComponent =
+ File(projectRoot, "$rootGenSrcDir/simple/DaggerSimpleApp_HiltComponents_SingletonC.java")
+ genTest1ComponentTreeDeps =
+ File(
+ projectRoot,
+ testComponentTreeDepsGenSrcDir +
+ "/dagger/hilt/android/internal/testing/root/Test1_ComponentTreeDeps.java"
+ )
+ genTest2ComponentTreeDeps =
+ File(
+ projectRoot,
+ testComponentTreeDepsGenSrcDir +
+ "/dagger/hilt/android/internal/testing/root/Test2_ComponentTreeDeps.java"
+ )
+ genTest1HiltComponents =
+ File(
+ projectRoot,
+ "$testRootGenSrcDir/dagger/hilt/android/internal/testing/root/Test1_HiltComponents.java"
+ )
+ genTest2HiltComponents =
+ File(
+ projectRoot,
+ "$testRootGenSrcDir/dagger/hilt/android/internal/testing/root/Test2_HiltComponents.java"
+ )
+ genTest1DaggerHiltApplicationComponent =
+ File(
+ projectRoot,
+ testRootGenSrcDir +
+ "/dagger/hilt/android/internal/testing/root/DaggerTest1_HiltComponents_SingletonC.java"
+ )
+ genTest2DaggerHiltApplicationComponent =
+ File(
+ projectRoot,
+ testRootGenSrcDir +
+ "/dagger/hilt/android/internal/testing/root/DaggerTest2_HiltComponents_SingletonC.java"
+ )
classSrcApp = File(projectRoot, "$defaultClassesDir/simple/SimpleApp.class")
classSrcActivity1 = File(projectRoot, "$defaultClassesDir/simple/Activity1.class")
@@ -302,70 +312,69 @@ class IncrementalProcessorTest(private val incapMode: String) {
classGenHiltActivity2 = File(projectRoot, "$defaultClassesDir/simple/Hilt_Activity2.class")
classGenAppInjector =
File(projectRoot, "$defaultClassesDir/simple/SimpleApp_GeneratedInjector.class")
- classGenActivityInjector1 = File(
- projectRoot,
- "$defaultClassesDir/simple/Activity1_GeneratedInjector.class"
- )
- classGenActivityInjector2 = File(
- projectRoot,
- "$defaultClassesDir/simple/Activity2_GeneratedInjector.class"
- )
- classGenAppInjectorDeps = File(
- projectRoot,
- "$defaultClassesDir/hilt_aggregated_deps/_simple_SimpleApp_GeneratedInjector.class"
- )
- classGenActivityInjectorDeps1 = File(
- projectRoot,
- "$defaultClassesDir/hilt_aggregated_deps/_simple_Activity1_GeneratedInjector.class"
- )
- classGenActivityInjectorDeps2 = File(
- projectRoot,
- "$defaultClassesDir/hilt_aggregated_deps/_simple_Activity2_GeneratedInjector.class"
- )
+ classGenActivityInjector1 =
+ File(projectRoot, "$defaultClassesDir/simple/Activity1_GeneratedInjector.class")
+ classGenActivityInjector2 =
+ File(projectRoot, "$defaultClassesDir/simple/Activity2_GeneratedInjector.class")
+ classGenAppInjectorDeps =
+ File(
+ projectRoot,
+ "$defaultClassesDir/hilt_aggregated_deps/_simple_SimpleApp_GeneratedInjector.class"
+ )
+ classGenActivityInjectorDeps1 =
+ File(
+ projectRoot,
+ "$defaultClassesDir/hilt_aggregated_deps/_simple_Activity1_GeneratedInjector.class"
+ )
+ classGenActivityInjectorDeps2 =
+ File(
+ projectRoot,
+ "$defaultClassesDir/hilt_aggregated_deps/_simple_Activity2_GeneratedInjector.class"
+ )
classGenModuleDeps1 =
File(projectRoot, "$defaultClassesDir/hilt_aggregated_deps/_simple_Module1.class")
classGenModuleDeps2 =
File(projectRoot, "$defaultClassesDir/hilt_aggregated_deps/_simple_Module2.class")
- classGenComponentTreeDeps = File(
- projectRoot,
- "$rootClassesDir/simple/SimpleApp_ComponentTreeDeps.class"
- )
- classGenHiltComponents = File(
- projectRoot,
- "$rootClassesDir/simple/SimpleApp_HiltComponents.class"
- )
- classGenDaggerHiltApplicationComponent = File(
- projectRoot,
- "$rootClassesDir/simple/DaggerSimpleApp_HiltComponents_SingletonC.class"
- )
- classGenTest1ComponentTreeDeps = File(
- projectRoot,
- testRootClassesDir +
- "/dagger/hilt/android/internal/testing/root/Test1_ComponentTreeDeps.class"
- )
- classGenTest2ComponentTreeDeps = File(
- projectRoot,
- testRootClassesDir +
- "/dagger/hilt/android/internal/testing/root/Test2_ComponentTreeDeps.class"
- )
- classGenTest1HiltComponents = File(
- projectRoot,
- "$testRootClassesDir/dagger/hilt/android/internal/testing/root/Test1_HiltComponents.class"
- )
- classGenTest2HiltComponents = File(
- projectRoot,
- "$testRootClassesDir/dagger/hilt/android/internal/testing/root/Test2_HiltComponents.class"
- )
- classGenTest1DaggerHiltApplicationComponent = File(
- projectRoot,
- testRootClassesDir +
- "/dagger/hilt/android/internal/testing/root/DaggerTest1_HiltComponents_SingletonC.class"
- )
- classGenTest2DaggerHiltApplicationComponent = File(
- projectRoot,
- testRootClassesDir +
- "/dagger/hilt/android/internal/testing/root/DaggerTest2_HiltComponents_SingletonC.class"
- )
+ classGenComponentTreeDeps =
+ File(projectRoot, "$rootClassesDir/simple/SimpleApp_ComponentTreeDeps.class")
+ classGenHiltComponents =
+ File(projectRoot, "$rootClassesDir/simple/SimpleApp_HiltComponents.class")
+ classGenDaggerHiltApplicationComponent =
+ File(projectRoot, "$rootClassesDir/simple/DaggerSimpleApp_HiltComponents_SingletonC.class")
+ classGenTest1ComponentTreeDeps =
+ File(
+ projectRoot,
+ testRootClassesDir +
+ "/dagger/hilt/android/internal/testing/root/Test1_ComponentTreeDeps.class"
+ )
+ classGenTest2ComponentTreeDeps =
+ File(
+ projectRoot,
+ testRootClassesDir +
+ "/dagger/hilt/android/internal/testing/root/Test2_ComponentTreeDeps.class"
+ )
+ classGenTest1HiltComponents =
+ File(
+ projectRoot,
+ "$testRootClassesDir/dagger/hilt/android/internal/testing/root/Test1_HiltComponents.class"
+ )
+ classGenTest2HiltComponents =
+ File(
+ projectRoot,
+ "$testRootClassesDir/dagger/hilt/android/internal/testing/root/Test2_HiltComponents.class"
+ )
+ classGenTest1DaggerHiltApplicationComponent =
+ File(
+ projectRoot,
+ testRootClassesDir +
+ "/dagger/hilt/android/internal/testing/root/DaggerTest1_HiltComponents_SingletonC.class"
+ )
+ classGenTest2DaggerHiltApplicationComponent =
+ File(
+ projectRoot,
+ testRootClassesDir +
+ "/dagger/hilt/android/internal/testing/root/DaggerTest2_HiltComponents_SingletonC.class"
+ )
}
@Test
@@ -428,13 +437,15 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Change Activity 1 source
searchAndReplace(
- srcActivity1, "// Insert-change",
+ srcActivity1,
+ "// Insert-change",
"""
@Override
public void onResume() {
super.onResume();
}
- """.trimIndent()
+ """
+ .trimIndent()
)
val result = runIncrementalBuild()
@@ -442,66 +453,69 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Check annotation processing outputs
// * Only activity 1 sources are re-generated, isolation in modules and from other activities
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- // * Aggregating task did not run, no change in deps
- expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
- // * Components are re-generated due to a recompilation of a dep
- listOf(
- genHiltApp, // Re-gen because components got re-gen
- genHiltActivity1,
- genActivityInjector1,
- genActivityInjectorDeps1,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- } else {
- // * Root classes along with components are always re-generated (aggregated processor)
- listOf(
- genHiltApp,
- genHiltActivity1,
- genAppInjector,
- genActivityInjector1,
- genAppInjectorDeps,
- genActivityInjectorDeps1,
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- }
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ // * Aggregating task did not run, no change in deps
+ expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
+ // * Components are re-generated due to a recompilation of a dep
+ listOf(
+ genHiltApp, // Re-gen because components got re-gen
+ genHiltActivity1,
+ genActivityInjector1,
+ genActivityInjectorDeps1,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ } else {
+ // * Root classes along with components are always re-generated (aggregated processor)
+ listOf(
+ genHiltApp,
+ genHiltActivity1,
+ genAppInjector,
+ genActivityInjector1,
+ genAppInjectorDeps,
+ genActivityInjectorDeps1,
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
val componentTreeDepsIncrementalBuild = genComponentTreeDeps.readText(Charsets.UTF_8)
- expect.withMessage("Full build")
- .that(componentTreeDepsFullBuild)
- .isEqualTo(componentTreeDepsIncrementalBuild)
+ expect
+ .withMessage("Full build")
+ .that(componentTreeDepsFullBuild)
+ .isEqualTo(componentTreeDepsIncrementalBuild)
// Check compilation outputs
// * Gen sources from activity 1 are re-compiled
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- listOf(
- classSrcActivity1,
- classGenHiltApp,
- classGenHiltActivity1,
- classGenActivityInjector1,
- classGenActivityInjectorDeps1,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent,
- )
- } else {
- // * All aggregating processor gen sources are re-compiled
- listOf(
- classSrcActivity1,
- classGenHiltApp,
- classGenHiltActivity1,
- classGenAppInjector,
- classGenActivityInjector1,
- classGenAppInjectorDeps,
- classGenActivityInjectorDeps1,
- classGenHiltComponents,
- classGenComponentTreeDeps,
- classGenDaggerHiltApplicationComponent
- )
- }
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(
+ classSrcActivity1,
+ classGenHiltApp,
+ classGenHiltActivity1,
+ classGenActivityInjector1,
+ classGenActivityInjectorDeps1,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent,
+ )
+ } else {
+ // * All aggregating processor gen sources are re-compiled
+ listOf(
+ classSrcActivity1,
+ classGenHiltApp,
+ classGenHiltActivity1,
+ classGenAppInjector,
+ classGenActivityInjector1,
+ classGenAppInjectorDeps,
+ classGenActivityInjectorDeps1,
+ classGenHiltComponents,
+ classGenComponentTreeDeps,
+ classGenDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -512,76 +526,82 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Change Activity 1 source
searchAndReplace(
- srcActivity1, "// Insert-change",
+ srcActivity1,
+ "// Insert-change",
"""
private void foo() { }
- """.trimIndent()
+ """
+ .trimIndent()
)
val result = runIncrementalBuild()
- val expectedOutcome = if (incapMode == ISOLATING_MODE) {
- // In isolating mode, changes that do not affect ABI will not cause re-compilation.
- TaskOutcome.UP_TO_DATE
- } else {
- TaskOutcome.SUCCESS
- }
+ val expectedOutcome =
+ if (incapMode == ISOLATING_MODE) {
+ // In isolating mode, changes that do not affect ABI will not cause re-compilation.
+ TaskOutcome.UP_TO_DATE
+ } else {
+ TaskOutcome.SUCCESS
+ }
expect.that(result.task(compileTaskName)!!.outcome).isEqualTo(expectedOutcome)
// Check annotation processing outputs
// * Only activity 1 sources are re-generated, isolation in modules and from other activities
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- // * Aggregating task did not run, no change in deps
- expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
- listOf(
- genHiltActivity1,
- genActivityInjector1,
- genActivityInjectorDeps1,
- )
- } else {
- // * Root classes along with components are always re-generated (aggregated processor)
- listOf(
- genHiltApp,
- genHiltActivity1,
- genAppInjector,
- genActivityInjector1,
- genAppInjectorDeps,
- genActivityInjectorDeps1,
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- }
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ // * Aggregating task did not run, no change in deps
+ expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
+ listOf(
+ genHiltActivity1,
+ genActivityInjector1,
+ genActivityInjectorDeps1,
+ )
+ } else {
+ // * Root classes along with components are always re-generated (aggregated processor)
+ listOf(
+ genHiltApp,
+ genHiltActivity1,
+ genAppInjector,
+ genActivityInjector1,
+ genAppInjectorDeps,
+ genActivityInjectorDeps1,
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
val componentTreeDepsIncrementalBuild = genComponentTreeDeps.readText(Charsets.UTF_8)
- expect.withMessage("Full build")
- .that(componentTreeDepsFullBuild)
- .isEqualTo(componentTreeDepsIncrementalBuild)
+ expect
+ .withMessage("Full build")
+ .that(componentTreeDepsFullBuild)
+ .isEqualTo(componentTreeDepsIncrementalBuild)
// Check compilation outputs
// * Gen sources from activity 1 are re-compiled
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- listOf(
- classSrcActivity1,
- classGenHiltActivity1,
- classGenActivityInjector1,
- classGenActivityInjectorDeps1
- )
- } else {
- // * All aggregating processor gen sources are re-compiled
- listOf(
- classSrcActivity1,
- classGenHiltApp,
- classGenHiltActivity1,
- classGenAppInjector,
- classGenActivityInjector1,
- classGenAppInjectorDeps,
- classGenActivityInjectorDeps1,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- }
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(
+ classSrcActivity1,
+ classGenHiltActivity1,
+ classGenActivityInjector1,
+ classGenActivityInjectorDeps1
+ )
+ } else {
+ // * All aggregating processor gen sources are re-compiled
+ listOf(
+ classSrcActivity1,
+ classGenHiltApp,
+ classGenHiltActivity1,
+ classGenAppInjector,
+ classGenActivityInjector1,
+ classGenAppInjectorDeps,
+ classGenActivityInjectorDeps1,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -592,13 +612,15 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Change Module 1 source
searchAndReplace(
- srcModule1, "// Insert-change",
+ srcModule1,
+ "// Insert-change",
"""
@Provides
static double provideDouble() {
return 10.10;
}
- """.trimIndent()
+ """
+ .trimIndent()
)
val result = runIncrementalBuild()
@@ -606,58 +628,61 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Check annotation processing outputs
// * Only module 1 sources are re-generated, isolation from other modules
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- // * Aggregating task did not run, no change in deps
- expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
- // * Components are re-generated due to a recompilation of a dep
- listOf(
- genHiltApp, // Re-generated because components got re-generated
- genModuleDeps1,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- } else {
- // * Root classes along with components are always re-generated (aggregated processor)
- listOf(
- genHiltApp,
- genAppInjector,
- genAppInjectorDeps,
- genModuleDeps1,
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- }
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ // * Aggregating task did not run, no change in deps
+ expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
+ // * Components are re-generated due to a recompilation of a dep
+ listOf(
+ genHiltApp, // Re-generated because components got re-generated
+ genModuleDeps1,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ } else {
+ // * Root classes along with components are always re-generated (aggregated processor)
+ listOf(
+ genHiltApp,
+ genAppInjector,
+ genAppInjectorDeps,
+ genModuleDeps1,
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
val componentTreeDepsIncrementalBuild = genComponentTreeDeps.readText(Charsets.UTF_8)
- expect.withMessage("Full build")
- .that(componentTreeDepsFullBuild)
- .isEqualTo(componentTreeDepsIncrementalBuild)
+ expect
+ .withMessage("Full build")
+ .that(componentTreeDepsFullBuild)
+ .isEqualTo(componentTreeDepsIncrementalBuild)
// Check compilation outputs
// * Gen sources from module 1 are re-compiled
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- listOf(
- classSrcModule1,
- classGenHiltApp,
- classGenModuleDeps1,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- } else {
- // * All aggregating processor gen sources are re-compiled
- listOf(
- classSrcModule1,
- classGenHiltApp,
- classGenAppInjector,
- classGenAppInjectorDeps,
- classGenModuleDeps1,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- }
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(
+ classSrcModule1,
+ classGenHiltApp,
+ classGenModuleDeps1,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ } else {
+ // * All aggregating processor gen sources are re-compiled
+ listOf(
+ classSrcModule1,
+ classGenHiltApp,
+ classGenAppInjector,
+ classGenAppInjectorDeps,
+ classGenModuleDeps1,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -668,13 +693,15 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Change Application source
searchAndReplace(
- srcApp, "// Insert-change",
+ srcApp,
+ "// Insert-change",
"""
@Override
public void onCreate() {
super.onCreate();
}
- """.trimIndent()
+ """
+ .trimIndent()
)
val result = runIncrementalBuild()
@@ -682,57 +709,60 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Check annotation processing outputs
// * No modules or activities (or any other non-root) classes should be generated
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- // * Aggregating task did not run, no change in deps
- expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
- // * Components are re-generated due to a recompilation of a dep
- listOf(
- genHiltApp, // Re-generated because components got re-generated
- genAppInjector,
- genAppInjectorDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- } else {
- // * Root classes along with components are always re-generated (aggregated processor)
- listOf(
- genHiltApp,
- genAppInjector,
- genAppInjectorDeps,
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- }
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ // * Aggregating task did not run, no change in deps
+ expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
+ // * Components are re-generated due to a recompilation of a dep
+ listOf(
+ genHiltApp, // Re-generated because components got re-generated
+ genAppInjector,
+ genAppInjectorDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ } else {
+ // * Root classes along with components are always re-generated (aggregated processor)
+ listOf(
+ genHiltApp,
+ genAppInjector,
+ genAppInjectorDeps,
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
val componentTreeDepsIncrementalBuild = genComponentTreeDeps.readText(Charsets.UTF_8)
- expect.withMessage("Full build")
- .that(componentTreeDepsFullBuild)
- .isEqualTo(componentTreeDepsIncrementalBuild)
+ expect
+ .withMessage("Full build")
+ .that(componentTreeDepsFullBuild)
+ .isEqualTo(componentTreeDepsIncrementalBuild)
// Check compilation outputs
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- listOf(
- classSrcApp,
- classGenHiltApp,
- classGenAppInjector,
- classGenAppInjectorDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- } else {
- // * All aggregating processor gen sources are re-compiled
- listOf(
- classSrcApp,
- classGenHiltApp,
- classGenAppInjector,
- classGenAppInjectorDeps,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- }
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(
+ classSrcApp,
+ classGenHiltApp,
+ classGenAppInjector,
+ classGenAppInjectorDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ } else {
+ // * All aggregating processor gen sources are re-compiled
+ listOf(
+ classSrcApp,
+ classGenHiltApp,
+ classGenAppInjector,
+ classGenAppInjectorDeps,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -749,33 +779,28 @@ class IncrementalProcessorTest(private val incapMode: String) {
// * All related gen classes from activity 2 should be deleted
// * Unrelated activities and modules are in isolation and should be unchanged
// * Root classes along with components are always re-generated (aggregated processor)
- assertDeletedFiles(
- listOf(
- genHiltActivity2,
- genActivityInjector2,
- genActivityInjectorDeps2
- )
- )
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- // * Aggregating task ran due to a change in dep
- expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.SUCCESS)
- // * Components are re-generated since there was a change in dep
- listOf(
- genHiltApp, // Re-generated because components got re-generated
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- } else {
- listOf(
- genHiltApp,
- genAppInjector,
- genAppInjectorDeps,
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- }
+ assertDeletedFiles(listOf(genHiltActivity2, genActivityInjector2, genActivityInjectorDeps2))
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ // * Aggregating task ran due to a change in dep
+ expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.SUCCESS)
+ // * Components are re-generated since there was a change in dep
+ listOf(
+ genHiltApp, // Re-generated because components got re-generated
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ } else {
+ listOf(
+ genHiltApp,
+ genAppInjector,
+ genAppInjectorDeps,
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
// Check compilation outputs
@@ -789,23 +814,24 @@ class IncrementalProcessorTest(private val incapMode: String) {
classGenActivityInjectorDeps2
)
)
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- listOf(
- classGenHiltApp,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- } else {
- listOf(
- classGenHiltApp,
- classGenAppInjector,
- classGenAppInjectorDeps,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- }
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(
+ classGenHiltApp,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ } else {
+ listOf(
+ classGenHiltApp,
+ classGenAppInjector,
+ classGenAppInjectorDeps,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -822,58 +848,53 @@ class IncrementalProcessorTest(private val incapMode: String) {
// * All related gen classes from module 2 should be deleted
// * Unrelated activities and modules are in isolation and should be unchanged
- assertDeletedFiles(
- listOf(genModuleDeps2)
- )
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- // * Aggregating task ran due to a change in dep
- expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.SUCCESS)
- // * Components are re-generated since there was a change in dep
- listOf(
- genHiltApp, // Re-generated because components got re-generated
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- } else {
- // * Root classes along with components are always re-generated (aggregated processor)
- listOf(
- genHiltApp,
- genAppInjector,
- genAppInjectorDeps,
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- }
+ assertDeletedFiles(listOf(genModuleDeps2))
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ // * Aggregating task ran due to a change in dep
+ expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.SUCCESS)
+ // * Components are re-generated since there was a change in dep
+ listOf(
+ genHiltApp, // Re-generated because components got re-generated
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ } else {
+ // * Root classes along with components are always re-generated (aggregated processor)
+ listOf(
+ genHiltApp,
+ genAppInjector,
+ genAppInjectorDeps,
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
// Check compilation outputs
// * All compiled classes from module 2 should be deleted
// * Unrelated activities and modules are in isolation and should be unchanged
- assertDeletedFiles(
- listOf(
- classSrcModule2,
- classGenModuleDeps2
- )
- )
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- listOf(
- classGenHiltApp,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- } else {
- listOf(
- classGenHiltApp,
- classGenAppInjector,
- classGenAppInjectorDeps,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- }
+ assertDeletedFiles(listOf(classSrcModule2, classGenModuleDeps2))
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(
+ classGenHiltApp,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ } else {
+ listOf(
+ classGenHiltApp,
+ classGenAppInjector,
+ classGenAppInjectorDeps,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -887,48 +908,52 @@ class IncrementalProcessorTest(private val incapMode: String) {
package simple;
public class Foo { }
- """.trimIndent()
+ """
+ .trimIndent()
)
val result = runIncrementalBuild()
- val expectedOutcome = if (incapMode == ISOLATING_MODE) {
- // In isolating mode, component compile task does not re-compile.
- TaskOutcome.UP_TO_DATE
- } else {
- TaskOutcome.SUCCESS
- }
+ val expectedOutcome =
+ if (incapMode == ISOLATING_MODE) {
+ // In isolating mode, component compile task does not re-compile.
+ TaskOutcome.UP_TO_DATE
+ } else {
+ TaskOutcome.SUCCESS
+ }
expect.that(result.task(compileTaskName)!!.outcome).isEqualTo(expectedOutcome)
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- // * Aggregating task did not run, no change in deps
- expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
- // * Non-DI related source causes no files to be generated
- emptyList()
- } else {
- // * Root classes are always re-generated (aggregated processor)
- listOf(
- genHiltApp,
- genAppInjector,
- genAppInjectorDeps,
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent
- )
- }
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ // * Aggregating task did not run, no change in deps
+ expect.that(result.task(aggregatingTaskName)!!.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
+ // * Non-DI related source causes no files to be generated
+ emptyList()
+ } else {
+ // * Root classes are always re-generated (aggregated processor)
+ listOf(
+ genHiltApp,
+ genAppInjector,
+ genAppInjectorDeps,
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- emptyList()
- } else {
- listOf(
- classGenHiltApp,
- classGenAppInjector,
- classGenAppInjectorDeps,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent
- )
- }
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ emptyList()
+ } else {
+ listOf(
+ classGenHiltApp,
+ classGenAppInjector,
+ classGenAppInjectorDeps,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -970,11 +995,13 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Change Test 1 source
searchAndReplace(
- srcTest1, "// Insert-change",
+ srcTest1,
+ "// Insert-change",
"""
@Test
public void newTest() { }
- """.trimIndent()
+ """
+ .trimIndent()
)
val result = runIncrementalTestBuild()
@@ -983,49 +1010,53 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Check annotation processing outputs
// * Unrelated test components should be unchanged
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- listOf(
- genTest1HiltComponents,
- genTest1DaggerHiltApplicationComponent,
- )
- } else {
- listOf(
- genTest1ComponentTreeDeps,
- genTest2ComponentTreeDeps,
- genTest1HiltComponents,
- genTest2HiltComponents,
- genTest1DaggerHiltApplicationComponent,
- genTest2DaggerHiltApplicationComponent,
- )
- }
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(
+ genTest1HiltComponents,
+ genTest1DaggerHiltApplicationComponent,
+ )
+ } else {
+ listOf(
+ genTest1ComponentTreeDeps,
+ genTest2ComponentTreeDeps,
+ genTest1HiltComponents,
+ genTest2HiltComponents,
+ genTest1DaggerHiltApplicationComponent,
+ genTest2DaggerHiltApplicationComponent,
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
val test1ComponentTreeDepsIncrementalBuild = genTest1ComponentTreeDeps.readText(Charsets.UTF_8)
val test2ComponentTreeDepsIncrementalBuild = genTest2ComponentTreeDeps.readText(Charsets.UTF_8)
- expect.withMessage("Full build")
- .that(test1ComponentTreeDepsFullBuild)
- .isEqualTo(test1ComponentTreeDepsIncrementalBuild)
- expect.withMessage("Full build")
- .that(test2ComponentTreeDepsFullBuild)
- .isEqualTo(test2ComponentTreeDepsIncrementalBuild)
-
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- listOf(
- classSrcTest1,
- classGenTest1HiltComponents,
- classGenTest1DaggerHiltApplicationComponent,
- )
- } else {
- listOf(
- classSrcTest1,
- classGenTest1ComponentTreeDeps,
- classGenTest2ComponentTreeDeps,
- classGenTest1HiltComponents,
- classGenTest2HiltComponents,
- classGenTest1DaggerHiltApplicationComponent,
- classGenTest2DaggerHiltApplicationComponent,
- )
- }
+ expect
+ .withMessage("Full build")
+ .that(test1ComponentTreeDepsFullBuild)
+ .isEqualTo(test1ComponentTreeDepsIncrementalBuild)
+ expect
+ .withMessage("Full build")
+ .that(test2ComponentTreeDepsFullBuild)
+ .isEqualTo(test2ComponentTreeDepsIncrementalBuild)
+
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(
+ classSrcTest1,
+ classGenTest1HiltComponents,
+ classGenTest1DaggerHiltApplicationComponent,
+ )
+ } else {
+ listOf(
+ classSrcTest1,
+ classGenTest1ComponentTreeDeps,
+ classGenTest2ComponentTreeDeps,
+ classGenTest1HiltComponents,
+ classGenTest2HiltComponents,
+ classGenTest1DaggerHiltApplicationComponent,
+ classGenTest2DaggerHiltApplicationComponent,
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -1037,60 +1068,67 @@ class IncrementalProcessorTest(private val incapMode: String) {
// Change Test 1 source
searchAndReplace(
- srcTest1, "// Insert-change",
+ srcTest1,
+ "// Insert-change",
"""
private void newMethod() { }
- """.trimIndent()
+ """
+ .trimIndent()
)
val result = runIncrementalTestBuild()
- val expectedOutcome = if (incapMode == ISOLATING_MODE) {
- // In isolating mode, changes that do not affect ABI will not cause re-compilation.
- TaskOutcome.UP_TO_DATE
- } else {
- TaskOutcome.SUCCESS
- }
+ val expectedOutcome =
+ if (incapMode == ISOLATING_MODE) {
+ // In isolating mode, changes that do not affect ABI will not cause re-compilation.
+ TaskOutcome.UP_TO_DATE
+ } else {
+ TaskOutcome.SUCCESS
+ }
expect.that(result.task(testCompileTaskName)!!.outcome).isEqualTo(expectedOutcome)
// Check annotation processing outputs
// * Unrelated test components should be unchanged
- val regeneratedSourceFiles = if (incapMode == ISOLATING_MODE) {
- emptyList()
- } else {
- listOf(
- genTest1ComponentTreeDeps,
- genTest2ComponentTreeDeps,
- genTest1HiltComponents,
- genTest2HiltComponents,
- genTest1DaggerHiltApplicationComponent,
- genTest2DaggerHiltApplicationComponent,
- )
- }
+ val regeneratedSourceFiles =
+ if (incapMode == ISOLATING_MODE) {
+ emptyList()
+ } else {
+ listOf(
+ genTest1ComponentTreeDeps,
+ genTest2ComponentTreeDeps,
+ genTest1HiltComponents,
+ genTest2HiltComponents,
+ genTest1DaggerHiltApplicationComponent,
+ genTest2DaggerHiltApplicationComponent,
+ )
+ }
assertChangedFiles(FileType.JAVA, regeneratedSourceFiles)
val test1ComponentTreeDepsIncrementalBuild = genTest1ComponentTreeDeps.readText(Charsets.UTF_8)
val test2ComponentTreeDepsIncrementalBuild = genTest2ComponentTreeDeps.readText(Charsets.UTF_8)
- expect.withMessage("Full build")
- .that(test1ComponentTreeDepsFullBuild)
- .isEqualTo(test1ComponentTreeDepsIncrementalBuild)
- expect.withMessage("Full build")
- .that(test2ComponentTreeDepsFullBuild)
- .isEqualTo(test2ComponentTreeDepsIncrementalBuild)
-
- val recompiledClassFiles = if (incapMode == ISOLATING_MODE) {
- listOf(classSrcTest1)
- } else {
- listOf(
- classSrcTest1,
- classGenTest1ComponentTreeDeps,
- classGenTest2ComponentTreeDeps,
- classGenTest1HiltComponents,
- classGenTest2HiltComponents,
- classGenTest1DaggerHiltApplicationComponent,
- classGenTest2DaggerHiltApplicationComponent,
- )
- }
+ expect
+ .withMessage("Full build")
+ .that(test1ComponentTreeDepsFullBuild)
+ .isEqualTo(test1ComponentTreeDepsIncrementalBuild)
+ expect
+ .withMessage("Full build")
+ .that(test2ComponentTreeDepsFullBuild)
+ .isEqualTo(test2ComponentTreeDepsIncrementalBuild)
+
+ val recompiledClassFiles =
+ if (incapMode == ISOLATING_MODE) {
+ listOf(classSrcTest1)
+ } else {
+ listOf(
+ classSrcTest1,
+ classGenTest1ComponentTreeDeps,
+ classGenTest2ComponentTreeDeps,
+ classGenTest1HiltComponents,
+ classGenTest2HiltComponents,
+ classGenTest1DaggerHiltApplicationComponent,
+ classGenTest2DaggerHiltApplicationComponent,
+ )
+ }
assertChangedFiles(FileType.CLASS, recompiledClassFiles)
}
@@ -1129,83 +1167,93 @@ class IncrementalProcessorTest(private val incapMode: String) {
}
private fun recordTimestamps() {
- val files = listOf(
- genHiltApp,
- genHiltActivity1,
- genHiltActivity2,
- genAppInjector,
- genActivityInjector1,
- genActivityInjector2,
- genAppInjectorDeps,
- genActivityInjectorDeps1,
- genActivityInjectorDeps2,
- genModuleDeps1,
- genModuleDeps2,
- genComponentTreeDeps,
- genHiltComponents,
- genDaggerHiltApplicationComponent,
- genTest1ComponentTreeDeps,
- genTest2ComponentTreeDeps,
- genTest1HiltComponents,
- genTest2HiltComponents,
- genTest1DaggerHiltApplicationComponent,
- genTest2DaggerHiltApplicationComponent,
- classSrcApp,
- classSrcActivity1,
- classSrcActivity2,
- classSrcModule1,
- classSrcModule2,
- classSrcTest1,
- classSrcTest2,
- classGenHiltApp,
- classGenHiltActivity1,
- classGenHiltActivity2,
- classGenAppInjector,
- classGenActivityInjector1,
- classGenActivityInjector2,
- classGenAppInjectorDeps,
- classGenActivityInjectorDeps1,
- classGenActivityInjectorDeps2,
- classGenModuleDeps1,
- classGenModuleDeps2,
- classGenComponentTreeDeps,
- classGenHiltComponents,
- classGenDaggerHiltApplicationComponent,
- classGenTest1ComponentTreeDeps,
- classGenTest2ComponentTreeDeps,
- classGenTest1HiltComponents,
- classGenTest2HiltComponents,
- classGenTest1DaggerHiltApplicationComponent,
- classGenTest2DaggerHiltApplicationComponent,
- )
+ val files =
+ listOf(
+ genHiltApp,
+ genHiltActivity1,
+ genHiltActivity2,
+ genAppInjector,
+ genActivityInjector1,
+ genActivityInjector2,
+ genAppInjectorDeps,
+ genActivityInjectorDeps1,
+ genActivityInjectorDeps2,
+ genModuleDeps1,
+ genModuleDeps2,
+ genComponentTreeDeps,
+ genHiltComponents,
+ genDaggerHiltApplicationComponent,
+ genTest1ComponentTreeDeps,
+ genTest2ComponentTreeDeps,
+ genTest1HiltComponents,
+ genTest2HiltComponents,
+ genTest1DaggerHiltApplicationComponent,
+ genTest2DaggerHiltApplicationComponent,
+ classSrcApp,
+ classSrcActivity1,
+ classSrcActivity2,
+ classSrcModule1,
+ classSrcModule2,
+ classSrcTest1,
+ classSrcTest2,
+ classGenHiltApp,
+ classGenHiltActivity1,
+ classGenHiltActivity2,
+ classGenAppInjector,
+ classGenActivityInjector1,
+ classGenActivityInjector2,
+ classGenAppInjectorDeps,
+ classGenActivityInjectorDeps1,
+ classGenActivityInjectorDeps2,
+ classGenModuleDeps1,
+ classGenModuleDeps2,
+ classGenComponentTreeDeps,
+ classGenHiltComponents,
+ classGenDaggerHiltApplicationComponent,
+ classGenTest1ComponentTreeDeps,
+ classGenTest2ComponentTreeDeps,
+ classGenTest1HiltComponents,
+ classGenTest2HiltComponents,
+ classGenTest1DaggerHiltApplicationComponent,
+ classGenTest2DaggerHiltApplicationComponent,
+ )
- fileToTimestampMap = mutableMapOf<File, Long>().apply {
- for (file in files) {
- this[file] = file.lastModified()
+ fileToTimestampMap =
+ mutableMapOf<File, Long>().apply {
+ for (file in files) {
+ this[file] = file.lastModified()
+ }
}
- }
}
private fun recordFileChanges() {
- changedFiles = fileToTimestampMap.filter { (file, previousTimestamp) ->
- file.exists() && file.lastModified() != previousTimestamp
- }.keys
+ changedFiles =
+ fileToTimestampMap
+ .filter { (file, previousTimestamp) ->
+ file.exists() && file.lastModified() != previousTimestamp
+ }
+ .keys
- unchangedFiles = fileToTimestampMap.filter { (file, previousTimestamp) ->
- file.exists() && file.lastModified() == previousTimestamp
- }.keys
+ unchangedFiles =
+ fileToTimestampMap
+ .filter { (file, previousTimestamp) ->
+ file.exists() && file.lastModified() == previousTimestamp
+ }
+ .keys
deletedFiles = fileToTimestampMap.filter { (file, _) -> !file.exists() }.keys
}
private fun assertFilesExist(files: Collection<File>) {
- expect.withMessage("Existing files")
+ expect
+ .withMessage("Existing files")
.that(files.filter { it.exists() })
.containsExactlyElementsIn(files)
}
private fun assertChangedFiles(type: FileType, files: Collection<File>) {
- expect.withMessage("Changed files")
+ expect
+ .withMessage("Changed files")
.that(changedFiles.filter { it.name.endsWith(type.extension) })
.containsExactlyElementsIn(files)
}
@@ -1227,10 +1275,7 @@ class IncrementalProcessorTest(private val incapMode: String) {
@JvmStatic
@Parameterized.Parameters(name = "{0}")
- fun parameters() = listOf(
- ISOLATING_MODE,
- AGGREGATING_MODE
- )
+ fun parameters() = listOf(ISOLATING_MODE, AGGREGATING_MODE)
private const val ISOLATING_MODE = "isolating"
private const val AGGREGATING_MODE = "aggregating"