Remove AGP 4.2 from Hilt Gradle Plugin

RELNOTES=Remove AGP 4.2 from Hilt Gradle Plugin
PiperOrigin-RevId: 487198126
diff --git a/java/dagger/hilt/android/plugin/agp-wrapper-4-2/build.gradle b/java/dagger/hilt/android/plugin/agp-wrapper-4-2/build.gradle
deleted file mode 100644
index 7e55632..0000000
--- a/java/dagger/hilt/android/plugin/agp-wrapper-4-2/build.gradle
+++ /dev/null
@@ -1,9 +0,0 @@
-plugins {
-  id 'org.jetbrains.kotlin.jvm'
-}
-
-dependencies {
-  implementation project(':agp-wrapper')
-  compileOnly gradleApi()
-  compileOnly "com.android.tools.build:gradle:4.2.0"
-}
\ No newline at end of file
diff --git a/java/dagger/hilt/android/plugin/agp-wrapper-4-2/src/main/kotlin/dagger/hilt/android/plugin/util/AndroidComponentsExtensionCompatApi42Impl.kt b/java/dagger/hilt/android/plugin/agp-wrapper-4-2/src/main/kotlin/dagger/hilt/android/plugin/util/AndroidComponentsExtensionCompatApi42Impl.kt
deleted file mode 100644
index e8df1a5..0000000
--- a/java/dagger/hilt/android/plugin/agp-wrapper-4-2/src/main/kotlin/dagger/hilt/android/plugin/util/AndroidComponentsExtensionCompatApi42Impl.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2022 The Dagger Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package dagger.hilt.android.plugin.util
-
-import com.android.build.api.component.Component
-import com.android.build.api.extension.AndroidComponentsExtension
-import org.gradle.api.Project
-
-@Suppress("UnstableApiUsage")
-class AndroidComponentsExtensionCompatApi42Impl(
-  private val project: Project
-) : AndroidComponentsExtensionCompat {
-
-  override fun onAllVariants(block: (ComponentCompat) -> Unit) {
-    val actual = project.extensions.getByType(AndroidComponentsExtension::class.java)
-    val allSelectors = actual.selector().all()
-    val wrapFunction: (Component) -> Unit = { block.invoke(ComponentCompatApi42Impl(it)) }
-    actual.onVariants(allSelectors, wrapFunction)
-    actual.androidTests(allSelectors, wrapFunction)
-    actual.unitTests(allSelectors, wrapFunction)
-  }
-}
diff --git a/java/dagger/hilt/android/plugin/agp-wrapper-4-2/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi42Impl.kt b/java/dagger/hilt/android/plugin/agp-wrapper-4-2/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi42Impl.kt
deleted file mode 100644
index a55d92a..0000000
--- a/java/dagger/hilt/android/plugin/agp-wrapper-4-2/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi42Impl.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2022 The Dagger Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package dagger.hilt.android.plugin.util
-
-import com.android.build.api.component.Component
-import com.android.build.api.instrumentation.AsmClassVisitorFactory
-import com.android.build.api.instrumentation.FramesComputationMode
-import com.android.build.api.instrumentation.InstrumentationParameters
-import com.android.build.api.instrumentation.InstrumentationScope
-
-@Suppress("UnstableApiUsage")
-internal class ComponentCompatApi42Impl(private val component: Component) : ComponentCompat() {
-
-  override val name: String
-    get() = component.name
-
-  override fun <ParamT : InstrumentationParameters> transformClassesWith(
-    classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>,
-    scope: InstrumentationScope,
-    instrumentationParamsConfig: (ParamT) -> Unit
-  ) {
-    component.transformClassesWith(classVisitorFactoryImplClass, scope, instrumentationParamsConfig)
-  }
-
-  override fun setAsmFramesComputationMode(mode: FramesComputationMode) {
-    component.setAsmFramesComputationMode(mode)
-  }
-}
diff --git a/java/dagger/hilt/android/plugin/agp-wrapper-impl/build.gradle b/java/dagger/hilt/android/plugin/agp-wrapper-impl/build.gradle
index 34300b2..7f2bfac 100644
--- a/java/dagger/hilt/android/plugin/agp-wrapper-impl/build.gradle
+++ b/java/dagger/hilt/android/plugin/agp-wrapper-impl/build.gradle
@@ -4,7 +4,6 @@
 
 dependencies {
   api project(':agp-wrapper')
-  implementation project(':agp-wrapper-4-2')
   implementation project(':agp-wrapper-7-0')
   implementation project(':agp-wrapper-7-1')
   implementation project(':agp-wrapper-7-2')
diff --git a/java/dagger/hilt/android/plugin/agp-wrapper-impl/src/main/kotlin/dagger/hilt/android/plugin/util/AGPVersionCompat.kt b/java/dagger/hilt/android/plugin/agp-wrapper-impl/src/main/kotlin/dagger/hilt/android/plugin/util/AGPVersionCompat.kt
index 49d71b8..3ddd484 100644
--- a/java/dagger/hilt/android/plugin/agp-wrapper-impl/src/main/kotlin/dagger/hilt/android/plugin/util/AGPVersionCompat.kt
+++ b/java/dagger/hilt/android/plugin/agp-wrapper-impl/src/main/kotlin/dagger/hilt/android/plugin/util/AGPVersionCompat.kt
@@ -30,9 +30,6 @@
     version >= SimpleAGPVersion(7, 0) -> {
       AndroidComponentsExtensionCompatApi70Impl(project)
     }
-    version >= SimpleAGPVersion(4, 2) -> {
-      AndroidComponentsExtensionCompatApi42Impl(project)
-    }
     else -> {
       error("Android Gradle Plugin $version is not supported")
     }
diff --git a/java/dagger/hilt/android/plugin/settings.gradle b/java/dagger/hilt/android/plugin/settings.gradle
index d4312cb..55724bf 100644
--- a/java/dagger/hilt/android/plugin/settings.gradle
+++ b/java/dagger/hilt/android/plugin/settings.gradle
@@ -18,7 +18,6 @@
 include ':main'
 include ':agp-wrapper'
 include ':agp-wrapper-impl'
-include ':agp-wrapper-4-2'
 include ':agp-wrapper-7-0'
 include ':agp-wrapper-7-1'
 include ':agp-wrapper-7-2'