diff --git a/java/dagger/hilt/android/plugin/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt b/java/dagger/hilt/android/plugin/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt index 20390657ccd..fc298515f29 100644 --- a/java/dagger/hilt/android/plugin/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt +++ b/java/dagger/hilt/android/plugin/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt @@ -92,15 +92,13 @@ class HiltGradlePlugin : Plugin { val dependencies = project.configurations.flatMap { configuration -> configuration.dependencies.map { dependency -> dependency.group to dependency.name } } - // TODO(user): Consider also validating Dagger compiler dependency. - listOf( - LIBRARY_GROUP to "hilt-android", - LIBRARY_GROUP to "hilt-android-compiler" - ).filterNot { dependencies.contains(it) }.forEach { (groupId, artifactId) -> - error( - "The Hilt Android Gradle plugin is applied but no $groupId:$artifactId dependency " + - "was found." - ) + if (!dependencies.contains(LIBRARY_GROUP to "hilt-android")) { + error(missingDepError("$LIBRARY_GROUP:hilt-android")) + } + if (!dependencies.contains(LIBRARY_GROUP to "hilt-android-compiler") && + !dependencies.contains(LIBRARY_GROUP to "hilt-compiler") + ) { + error(missingDepError("$LIBRARY_GROUP:hilt-compiler")) } } @@ -110,5 +108,8 @@ class HiltGradlePlugin : Plugin { "dagger.fastInit" to "enabled", "dagger.hilt.android.internal.disableAndroidSuperclassValidation" to "true" ) + val missingDepError: (String) -> String = { depCoordinate -> + "The Hilt Android Gradle plugin is applied but no $depCoordinate dependency was found." + } } } diff --git a/java/dagger/hilt/android/plugin/src/test/kotlin/HiltGradlePluginTest.kt b/java/dagger/hilt/android/plugin/src/test/kotlin/HiltGradlePluginTest.kt index 7ea3bfe93f3..c0cf71ea9cc 100644 --- a/java/dagger/hilt/android/plugin/src/test/kotlin/HiltGradlePluginTest.kt +++ b/java/dagger/hilt/android/plugin/src/test/kotlin/HiltGradlePluginTest.kt @@ -67,7 +67,7 @@ class HiltGradlePluginTest { gradleTransformRunner.addDependencies( "implementation 'androidx.appcompat:appcompat:1.1.0'", "implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT'", - "annotationProcessor 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT'" + "annotationProcessor 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT'" ) gradleTransformRunner.addActivities( "" @@ -105,7 +105,7 @@ class HiltGradlePluginTest { gradleTransformRunner.addDependencies( "implementation 'androidx.appcompat:appcompat:1.1.0'", "implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT'", - "annotationProcessor 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT'" + "annotationProcessor 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT'" ) gradleTransformRunner.addSrc( @@ -141,7 +141,7 @@ class HiltGradlePluginTest { gradleTransformRunner.addDependencies( "implementation 'androidx.appcompat:appcompat:1.1.0'", "implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT'", - "annotationProcessor 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT'" + "annotationProcessor 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT'" ) gradleTransformRunner.addSrc( @@ -177,7 +177,7 @@ class HiltGradlePluginTest { gradleTransformRunner.addDependencies( "implementation 'androidx.appcompat:appcompat:1.1.0'", "implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT'", - "annotationProcessor 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT'" + "annotationProcessor 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT'" ) gradleTransformRunner.addSrc( @@ -232,7 +232,7 @@ class HiltGradlePluginTest { val result = gradleTransformRunner.buildAndFail() assertThat(result.getOutput()).contains( "The Hilt Android Gradle plugin is applied but no " + - "com.google.dagger:hilt-android-compiler dependency was found." + "com.google.dagger:hilt-compiler dependency was found." ) } @@ -242,7 +242,7 @@ class HiltGradlePluginTest { gradleTransformRunner.addDependencies( "implementation 'androidx.appcompat:appcompat:1.1.0'", "implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT'", - "annotationProcessor 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT'" + "annotationProcessor 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT'" ) val srcFile = gradleTransformRunner.addSrc( @@ -305,7 +305,7 @@ class HiltGradlePluginTest { gradleTransformRunner.addDependencies( "implementation 'androidx.appcompat:appcompat:1.1.0'", "implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT'", - "annotationProcessor 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT'" + "annotationProcessor 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT'" ) gradleTransformRunner.addSrcPackage("ui/") diff --git a/java/dagger/hilt/android/plugin/src/test/kotlin/IncrementalProcessorTest.kt b/java/dagger/hilt/android/plugin/src/test/kotlin/IncrementalProcessorTest.kt index 55021b2c6cb..631a58fa0dd 100644 --- a/java/dagger/hilt/android/plugin/src/test/kotlin/IncrementalProcessorTest.kt +++ b/java/dagger/hilt/android/plugin/src/test/kotlin/IncrementalProcessorTest.kt @@ -137,7 +137,7 @@ class IncrementalProcessorTest { implementation 'com.google.dagger:dagger:LOCAL-SNAPSHOT' annotationProcessor 'com.google.dagger:dagger-compiler:LOCAL-SNAPSHOT' implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT' - annotationProcessor 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT' + annotationProcessor 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT' } """.trimIndent() ) diff --git a/javatests/artifacts/hilt-android/simple/app/build.gradle b/javatests/artifacts/hilt-android/simple/app/build.gradle index 417b0608260..6ead8809f2b 100644 --- a/javatests/artifacts/hilt-android/simple/app/build.gradle +++ b/javatests/artifacts/hilt-android/simple/app/build.gradle @@ -66,7 +66,7 @@ dependencies { implementation project(':lib') implementation 'androidx.appcompat:appcompat:1.1.0' implementation "com.google.dagger:hilt-android:$dagger_version" - annotationProcessor "com.google.dagger:hilt-android-compiler:$dagger_version" + annotationProcessor "com.google.dagger:hilt-compiler:$dagger_version" testImplementation 'com.google.truth:truth:1.0.1' testImplementation 'junit:junit:4.13' @@ -76,7 +76,7 @@ dependencies { testImplementation 'androidx.test:runner:1.2.0' testImplementation 'androidx.test.espresso:espresso-core:3.2.0' testImplementation "com.google.dagger:hilt-android-testing:$dagger_version" - testAnnotationProcessor "com.google.dagger:hilt-android-compiler:$dagger_version" + testAnnotationProcessor "com.google.dagger:hilt-compiler:$dagger_version" androidTestImplementation 'com.google.truth:truth:1.0.1' androidTestImplementation 'junit:junit:4.13' @@ -84,7 +84,7 @@ dependencies { androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation "com.google.dagger:hilt-android-testing:$dagger_version" - androidTestAnnotationProcessor "com.google.dagger:hilt-android-compiler:$dagger_version" + androidTestAnnotationProcessor "com.google.dagger:hilt-compiler:$dagger_version" // To help us catch usages of Guava APIs for Java 8 in the '-jre' variant. annotationProcessor'com.google.guava:guava:28.1-android' diff --git a/javatests/artifacts/hilt-android/simple/feature/build.gradle b/javatests/artifacts/hilt-android/simple/feature/build.gradle index c73b4a51b09..35576837130 100644 --- a/javatests/artifacts/hilt-android/simple/feature/build.gradle +++ b/javatests/artifacts/hilt-android/simple/feature/build.gradle @@ -50,5 +50,5 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation "com.google.dagger:hilt-android:$dagger_version" - kapt "com.google.dagger:hilt-android-compiler:$dagger_version" + kapt "com.google.dagger:hilt-compiler:$dagger_version" } diff --git a/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle index a6b70334624..3f42cb1172f 100644 --- a/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle +++ b/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle @@ -49,7 +49,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT' - kapt 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT' + kapt 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT' testImplementation 'com.google.truth:truth:1.0.1' testImplementation 'junit:junit:4.13' @@ -58,5 +58,5 @@ dependencies { // TODO(bcorso): This multidex dep shouldn't be required -- it's a dep for the generated code. testImplementation 'androidx.multidex:multidex:2.0.0' testImplementation 'com.google.dagger:hilt-android-testing:LOCAL-SNAPSHOT' - kaptTest 'com.google.dagger:hilt-android-compiler:LOCAL-SNAPSHOT' + kaptTest 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT' }