From 91450da6a09845e86d92407dfda33b906a6c71bf Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Date: Sat, 11 Jan 2025 06:38:08 -0800 Subject: [PATCH] Fix the isolated project violation `dependency.group` would be accessed which, for project dependencies, would cause an isolated project violation. Now project dependencies are filtered out. This partially fixes https://github.com/google/dagger/issues/4423 Closes https://github.com/google/dagger/pull/4570 RELNOTES=Fix project isolation violation when checking that Hilt libraries are applied along the Gradle plugin. PiperOrigin-RevId: 714428280 --- .../kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/dagger/hilt/android/plugin/main/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt b/java/dagger/hilt/android/plugin/main/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt index 34a80d1f5eb..5c6f5ee680d 100644 --- a/java/dagger/hilt/android/plugin/main/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt +++ b/java/dagger/hilt/android/plugin/main/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt @@ -51,6 +51,7 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.ExternalDependency import org.gradle.api.artifacts.component.ProjectComponentIdentifier import org.gradle.api.attributes.Attribute import org.gradle.api.provider.ProviderFactory @@ -421,7 +422,9 @@ class HiltGradlePlugin @Inject constructor(private val providers: ProviderFactor it.name.startsWith("hiltAnnotationProcessor") || it.name.startsWith("hiltCompileOnly") } .flatMap { configuration -> - configuration.dependencies.map { dependency -> dependency.group to dependency.name } + configuration.dependencies.filterIsInstance().map { dependency -> + dependency.group to dependency.name + } } .toSet() fun getMissingDepMsg(depCoordinate: String): String =