Removed UnitTestImpl and associated DslInfo types

Those types are not useful as everything is now handled by a
generic HostTestImpl and associated HostTest types.
ComponentTypeImpl will most likely be further simplified in a
subsequent CL.

Test: Existing
Bug: N/A
Change-Id: I81e0f65869edc5a1b31798e90f98a85a407f7acd
diff --git a/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/HostTestImpl.kt b/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/HostTestImpl.kt
index 199421f..ddf2106 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/HostTestImpl.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/HostTestImpl.kt
@@ -17,13 +17,17 @@
 package com.android.build.api.component.impl
 
 import com.android.build.api.artifact.impl.ArtifactsImpl
+import com.android.build.api.component.UnitTest
+import com.android.build.api.component.impl.features.AndroidResourcesCreationConfigImpl
 import com.android.build.api.variant.AndroidVersion
 import com.android.build.api.variant.ComponentIdentity
 import com.android.build.api.variant.HostTest
 import com.android.build.api.variant.HostTestBuilder
+import com.android.build.api.variant.impl.AndroidResourcesImpl
 import com.android.build.api.variant.impl.HostTestBuilderImpl
 import com.android.build.gradle.internal.component.HostTestCreationConfig
 import com.android.build.gradle.internal.component.VariantCreationConfig
+import com.android.build.gradle.internal.component.features.AndroidResourcesCreationConfig
 import com.android.build.gradle.internal.component.features.BuildConfigCreationConfig
 import com.android.build.gradle.internal.component.features.ManifestPlaceholdersCreationConfig
 import com.android.build.gradle.internal.core.VariantSources
@@ -37,7 +41,7 @@
 import com.android.build.gradle.internal.tasks.factory.GlobalTaskCreationConfig
 import com.android.build.gradle.internal.variant.BaseVariantData
 import com.android.build.gradle.internal.variant.VariantPathHelper
-import com.android.builder.core.ComponentType
+import com.android.builder.core.ComponentTypeImpl
 import org.gradle.api.provider.MapProperty
 import org.gradle.api.provider.Provider
 import org.gradle.api.tasks.TaskProvider
@@ -59,8 +63,6 @@
     taskCreationServices: TaskCreationServices,
     global: GlobalTaskCreationConfig,
     hostTestBuilder: HostTestBuilderImpl,
-    override val hostTestName: String,
-    override val useBuiltInKotlinSupport: Boolean,
 ) : TestComponentImpl<HostTestComponentDslInfo>(
     componentIdentity,
     buildFeatureValues,
@@ -75,13 +77,16 @@
     internalServices,
     taskCreationServices,
     global
-), HostTest, HostTestCreationConfig {
+), HostTest, HostTestCreationConfig, UnitTest {
 
     // ---------------------------------------------------------------------------------------------
     // PUBLIC API
     // ---------------------------------------------------------------------------------------------
     override val isCodeCoverageEnabled: Boolean = hostTestBuilder._enableCodeCoverage
 
+    final override val hostTestName: String
+    final override val useBuiltInKotlinSupport: Boolean
+
     // ---------------------------------------------------------------------------------------------
     // INTERNAL API
     // ---------------------------------------------------------------------------------------------
@@ -92,9 +97,6 @@
     override val applicationId: Provider<String> =
         internalServices.providerOf(String::class.java, dslInfo.applicationId)
 
-    override val targetSdkVersion: AndroidVersion
-        get() = getMainTargetSdkVersion()
-
     /**
      * Return the default runner as with host tests, there is no dexing. However, aapt2 requires
      * the instrumentation tag to be present in the merged manifest to process android resources.
@@ -134,4 +136,63 @@
             testTaskProvider.configure { testTask -> it(testTask) }
         }
     }
+
+    /**
+     * In unit tests, we don't produce an apk. However, we still need to set the target sdk version
+     * in the test manifest as robolectric depends on it.
+     */
+    override val targetSdkVersion: AndroidVersion
+        get() = when(dslInfo.componentType) {
+            ComponentTypeImpl.UNIT_TEST -> {
+                /**
+                 * In unit tests, we don't produce an apk. However, we still need to set the
+                 * target sdk version in the test manifest as robolectric depends on it.
+                 */
+                global.unitTestOptions.targetSdkVersion ?: getMainTargetSdkVersion()
+            }
+            ComponentTypeImpl.SCREENSHOT_TEST -> {
+                getMainTargetSdkVersion()
+            }
+            else -> throw RuntimeException("Invalid component type ${dslInfo.componentType}")
+        }
+
+    override val androidResourcesCreationConfig: AndroidResourcesCreationConfig? by lazy(
+        LazyThreadSafetyMode.NONE
+    ) {
+        // in case of unit tests, we add the R jar even if android resources are
+        // disabled (includeAndroidResources) as we want to be able to compile against
+        // the values inside.
+        if (buildFeatures.androidResources ||
+            (dslInfo.componentType == ComponentTypeImpl.UNIT_TEST &&  mainVariant.buildFeatures.androidResources)) {
+            AndroidResourcesCreationConfigImpl(
+                this,
+                dslInfo,
+                dslInfo.androidResourcesDsl!!,
+                internalServices,
+            )
+        } else {
+            null
+        }
+    }
+
+
+    override val androidResources: AndroidResourcesImpl =
+        getAndroidResources(dslInfo.androidResourcesDsl!!.androidResources)
+
+
+    init {
+        when(dslInfo.componentType) {
+            ComponentTypeImpl.UNIT_TEST -> {
+                hostTestName = HostTestBuilder.UNIT_TEST_TYPE
+                useBuiltInKotlinSupport = false
+            }
+            ComponentTypeImpl.SCREENSHOT_TEST -> {
+                hostTestName = HostTestBuilder.SCREENSHOT_TEST_TYPE
+                useBuiltInKotlinSupport = true
+            }
+            else -> throw IllegalStateException(
+                "Expected a test component type, but ${componentIdentity.name} has type " +
+                        "$dslInfo.componentType")
+        }
+    }
 }
diff --git a/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/UnitTestImpl.kt b/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/UnitTestImpl.kt
deleted file mode 100644
index 3e83179..0000000
--- a/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/UnitTestImpl.kt
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * 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 com.android.build.api.component.impl
-
-import com.android.build.api.artifact.impl.ArtifactsImpl
-import com.android.build.api.component.UnitTest
-import com.android.build.api.component.impl.features.AndroidResourcesCreationConfigImpl
-import com.android.build.api.variant.AndroidVersion
-import com.android.build.api.variant.ComponentIdentity
-import com.android.build.api.variant.HostTestBuilder
-import com.android.build.api.variant.impl.AndroidResourcesImpl
-import com.android.build.api.variant.impl.HostTestBuilderImpl
-import com.android.build.gradle.internal.component.VariantCreationConfig
-import com.android.build.gradle.internal.component.features.AndroidResourcesCreationConfig
-import com.android.build.gradle.internal.core.VariantSources
-import com.android.build.gradle.internal.core.dsl.HostTestComponentDslInfo
-import com.android.build.gradle.internal.dependency.VariantDependencies
-import com.android.build.gradle.internal.scope.BuildFeatureValues
-import com.android.build.gradle.internal.scope.MutableTaskContainer
-import com.android.build.gradle.internal.services.TaskCreationServices
-import com.android.build.gradle.internal.services.VariantServices
-import com.android.build.gradle.internal.tasks.factory.GlobalTaskCreationConfig
-import com.android.build.gradle.internal.variant.BaseVariantData
-import com.android.build.gradle.internal.variant.VariantPathHelper
-import com.android.builder.core.ComponentTypeImpl
-import javax.inject.Inject
-
-open class UnitTestImpl @Inject constructor(
-    componentIdentity: ComponentIdentity,
-    buildFeatureValues: BuildFeatureValues,
-    dslInfo: HostTestComponentDslInfo,
-    variantDependencies: VariantDependencies,
-    variantSources: VariantSources,
-    paths: VariantPathHelper,
-    artifacts: ArtifactsImpl,
-    variantData: BaseVariantData,
-    taskContainer: MutableTaskContainer,
-    testedVariant: VariantCreationConfig,
-    internalServices: VariantServices,
-    taskCreationServices: TaskCreationServices,
-    global: GlobalTaskCreationConfig,
-    hostTestBuilder: HostTestBuilderImpl,
-) : HostTestImpl(
-    componentIdentity,
-    buildFeatureValues,
-    dslInfo,
-    variantDependencies,
-    variantSources,
-    paths,
-    artifacts,
-    variantData,
-    taskContainer,
-    testedVariant,
-    internalServices,
-    taskCreationServices,
-    global,
-    hostTestBuilder,
-    HostTestBuilder.UNIT_TEST_TYPE,
-    useBuiltInKotlinSupport = false
-), UnitTest {
-
-    /**
-     * In unit tests, we don't produce an apk. However, we still need to set the target sdk version
-     * in the test manifest as robolectric depends on it.
-     */
-    override val targetSdkVersion: AndroidVersion
-        get() = global.unitTestOptions.targetSdkVersion ?: getMainTargetSdkVersion()
-
-    override val androidResourcesCreationConfig: AndroidResourcesCreationConfig? by lazy(
-        LazyThreadSafetyMode.NONE
-    ) {
-        // in case of unit tests, we add the R jar even if android resources are
-        // disabled (includeAndroidResources) as we want to be able to compile against
-        // the values inside.
-        if (buildFeatures.androidResources || mainVariant.buildFeatures.androidResources) {
-            AndroidResourcesCreationConfigImpl(
-                    this,
-                    dslInfo,
-                    dslInfo.androidResourcesDsl!!,
-                    internalServices,
-            )
-        } else {
-            null
-        }
-    }
-
-    override val androidResources: AndroidResourcesImpl =
-            getAndroidResources(dslInfo.androidResourcesDsl!!.androidResources)
-}
diff --git a/build-system/gradle-core/src/main/java/com/android/build/api/variant/impl/VariantImpl.kt b/build-system/gradle-core/src/main/java/com/android/build/api/variant/impl/VariantImpl.kt
index 2e13ffd..7ad1d67 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/api/variant/impl/VariantImpl.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/api/variant/impl/VariantImpl.kt
@@ -55,6 +55,7 @@
 import com.android.build.gradle.internal.tasks.factory.GlobalTaskCreationConfig
 import com.android.build.gradle.internal.variant.BaseVariantData
 import com.android.build.gradle.internal.variant.VariantPathHelper
+import com.android.builder.core.ComponentTypeImpl
 import com.android.utils.appendCapitalized
 import com.android.utils.capitalizeAndAppend
 import com.google.common.collect.ImmutableMap
@@ -156,7 +157,9 @@
     )
     @Suppress("DEPRECATION")
     override val unitTest: UnitTest?
-        get() = hostTests().firstOrNull() { it is UnitTest } as? UnitTest
+        get() = hostTests().firstOrNull() {
+            it.componentType == ComponentTypeImpl.UNIT_TEST
+        } as? UnitTest
 
     // ---------------------------------------------------------------------------------------------
     // INTERNAL API
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/VariantManager.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/VariantManager.kt
index ba351f5..6ebac2d 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/VariantManager.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/VariantManager.kt
@@ -23,6 +23,7 @@
 import com.android.build.api.dsl.CommonExtension
 import com.android.build.api.dsl.TestedExtension
 import com.android.build.api.extension.impl.VariantApiOperationsRegistrar
+import com.android.build.api.variant.DeviceTestBuilder
 import com.android.build.api.variant.HasDeviceTests
 import com.android.build.api.variant.HasDeviceTestsBuilder
 import com.android.build.api.variant.HasHostTests
@@ -585,8 +586,7 @@
         testedComponentInfo: VariantComponentInfo<VariantBuilderT, VariantDslInfoT, VariantT>,
         componentType: ComponentType,
         testFixturesEnabled: Boolean,
-        deviceTestBuilder: DeviceTestBuilderImpl? = null,
-        hostTestBuilder: HostTestBuilderImpl? = null,
+        testBuilder: Any,
     ): TestComponentCreationConfig {
 
         // handle test variant
@@ -628,16 +628,10 @@
             }
         }
 
-        // TODO: Eventually, we must get rid of screenshot_test component type and specific types
-        val testComponentDslInfo = when(componentType) {
-            ComponentTypeImpl.UNIT_TEST ->
-                variantDslInfoBuilder.createUnitTestComponentDslInfo(
-                    hostTestBuilder?._enableCodeCoverage ?: false)
-            ComponentTypeImpl.SCREENSHOT_TEST ->
-                variantDslInfoBuilder.createScreenshotTestComponentDslInfo(
-                    hostTestBuilder?._enableCodeCoverage ?: false)
-            else ->
-                variantDslInfoBuilder.createDslInfo()
+        val testComponentDslInfo = when(testBuilder) {
+            is HostTestBuilder -> variantDslInfoBuilder.createHostTestComponentDslInfo()
+            is DeviceTestBuilder -> variantDslInfoBuilder.createAndroidTestComponentDslInfo()
+            else -> throw RuntimeException("Unknown test builder instance ${testBuilder.javaClass.name}")
         }
 
         createCompoundSourceSets(productFlavorDataList, variantDslInfoBuilder)
@@ -714,13 +708,13 @@
 
         val testComponent = when(componentType) {
             // this is ANDROID_TEST
-            ComponentTypeImpl.ANDROID_TEST -> deviceTestBuilder?.let {
+            ComponentTypeImpl.ANDROID_TEST ->
                 variantFactory.createAndroidTest(
                     testComponentDslInfo.componentIdentity,
                     variantFactory.createAndroidTestBuildFeatureValues(
-                            dslExtension.buildFeatures,
-                            dslExtension.dataBinding,
-                            dslServices.projectOptions
+                        dslExtension.buildFeatures,
+                        dslExtension.dataBinding,
+                        dslServices.projectOptions
                     ),
                     testComponentDslInfo as AndroidTestComponentDslInfo,
                     variantDependencies,
@@ -733,11 +727,10 @@
                     variantPropertiesApiServices,
                     taskCreationServices,
                     globalTaskCreationConfig,
-                    it,
+                    testBuilder as DeviceTestBuilderImpl,
                 )
-            } ?: throw IllegalStateException("Expected a test component type, but ${componentIdentity.name} has type $componentType")
             // this is UNIT_TEST
-            ComponentTypeImpl.UNIT_TEST -> hostTestBuilder?.let {
+            ComponentTypeImpl.UNIT_TEST ->
                 variantFactory.createUnitTest(
                     testComponentDslInfo.componentIdentity,
                     variantFactory.createHostTestBuildFeatureValues(
@@ -758,10 +751,9 @@
                     variantPropertiesApiServices,
                     taskCreationServices,
                     globalTaskCreationConfig,
-                    it,
+                    testBuilder as HostTestBuilderImpl,
                 )
-            } ?: throw IllegalArgumentException("Expected a HostTestBuilder instance for UNIT_TEST")
-            ComponentTypeImpl.SCREENSHOT_TEST -> hostTestBuilder?.let {
+            ComponentTypeImpl.SCREENSHOT_TEST ->
                 variantFactory.createHostTest(
                     testComponentDslInfo.componentIdentity,
                     variantFactory.createHostTestBuildFeatureValues(
@@ -782,11 +774,8 @@
                     variantPropertiesApiServices,
                     taskCreationServices,
                     globalTaskCreationConfig,
-                    it,
-                    HostTestBuilder.SCREENSHOT_TEST_TYPE,
-                    true,
+                    testBuilder as HostTestBuilderImpl,
                 )
-            } ?: throw IllegalArgumentException("Expected a HostTestBuilder instance for UNIT_TEST")
             else -> throw IllegalStateException("Expected a test component type, but ${componentIdentity.name} has type $componentType")
         }
 
@@ -899,8 +888,7 @@
                                 variantInfo,
                                 ComponentTypeImpl.ANDROID_TEST,
                                 testFixturesEnabledForVariant,
-                                deviceTestBuilder = deviceTestBuilder as DeviceTestBuilderImpl,
-                                hostTestBuilder = null,
+                                deviceTestBuilder,
                             )
                             addTestComponent(androidTest)
                             (variant as InternalHasDeviceTests).deviceTests.add(androidTest as DeviceTestImpl)
@@ -916,8 +904,7 @@
                                 variantInfo,
                                 (hostTestBuilder as HostTestBuilderImpl).componentType,
                                 testFixturesEnabledForVariant,
-                                deviceTestBuilder = null,
-                                hostTestBuilder = hostTestBuilder
+                                hostTestBuilder
                             )
                             addTestComponent(testComponent)
                             (variant as HasHostTestsCreationConfig)
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/DslInfoBuilder.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/DslInfoBuilder.kt
index b9f54e6..2e88773 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/DslInfoBuilder.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/DslInfoBuilder.kt
@@ -31,7 +31,6 @@
 import com.android.build.gradle.internal.core.dsl.TestFixturesComponentDslInfo
 import com.android.build.gradle.internal.core.dsl.TestProjectVariantDslInfo
 import com.android.build.gradle.internal.core.dsl.TestedVariantDslInfo
-import com.android.build.gradle.internal.core.dsl.HostTestComponentDslInfo
 import com.android.build.gradle.internal.dsl.ApplicationPublishingImpl
 import com.android.build.gradle.internal.dsl.DefaultConfig
 import com.android.build.gradle.internal.dsl.InternalApplicationExtension
@@ -248,11 +247,8 @@
         )
     }
 
-    // TODO : Move this back to VariantManager once we don't have a screenshot test specific version
-    internal fun createUnitTestComponentDslInfo(
-        isCodeCoverageEnabled: Boolean,
-    ): HostTestComponentDslInfo {
-        return UnitTestComponentDslInfoImpl(
+    internal fun createHostTestComponentDslInfo(): HostTestComponentDslInfoImpl {
+        return HostTestComponentDslInfoImpl(
             componentIdentity = createComponentIdentity(),
             componentType = componentType,
             defaultConfig = defaultConfig,
@@ -265,23 +261,7 @@
         )
     }
 
-    internal fun createScreenshotTestComponentDslInfo(
-        isCodeCoverageEnabled: Boolean,
-    ): HostTestComponentDslInfoImpl {
-        return ScreenshotTestComponentDslInfoImpl(
-            componentIdentity = createComponentIdentity(),
-            componentType = componentType,
-            defaultConfig = defaultConfig,
-            buildTypeObj = buildType,
-            productFlavorList = flavors.map { it.first },
-            services = variantServices,
-            buildDirectory = buildDirectory,
-            mainVariantDslInfo = productionVariant!!,
-            extension = extension as InternalTestedExtension<*, *, *, *, *, *>
-        )
-    }
-
-    private fun createAndroidTestComponentDslInfo(): AndroidTestComponentDslInfo {
+    internal fun createAndroidTestComponentDslInfo(): AndroidTestComponentDslInfo {
         return AndroidTestComponentDslInfoImpl(
             componentIdentity = createComponentIdentity(),
             componentType = componentType,
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/HostTestComponentDslInfoImpl.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/HostTestComponentDslInfoImpl.kt
index 5dbe80f..df775b5 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/HostTestComponentDslInfoImpl.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/HostTestComponentDslInfoImpl.kt
@@ -30,7 +30,7 @@
 import org.gradle.api.provider.Property
 import org.gradle.api.provider.Provider
 
-internal abstract class HostTestComponentDslInfoImpl(
+internal open class HostTestComponentDslInfoImpl(
     componentIdentity: ComponentIdentity,
     componentType: ComponentType,
     defaultConfig: DefaultConfig,
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/ScreenshotTestComponentDslInfoImpl.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/ScreenshotTestComponentDslInfoImpl.kt
deleted file mode 100644
index 3fdf78b..0000000
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/ScreenshotTestComponentDslInfoImpl.kt
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * 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 com.android.build.gradle.internal.core.dsl.impl
-
-import com.android.build.api.dsl.BuildType
-import com.android.build.api.dsl.ProductFlavor
-import com.android.build.api.variant.ComponentIdentity
-import com.android.build.api.variant.impl.MutableAndroidVersion
-import com.android.build.gradle.internal.core.dsl.TestedVariantDslInfo
-import com.android.build.gradle.internal.core.dsl.HostTestComponentDslInfo
-import com.android.build.gradle.internal.dsl.DefaultConfig
-import com.android.build.gradle.internal.dsl.InternalTestedExtension
-import com.android.build.gradle.internal.services.VariantServices
-import com.android.builder.core.ComponentType
-import org.gradle.api.file.DirectoryProperty
-import org.gradle.api.provider.Property
-import org.gradle.api.provider.Provider
-
-internal class ScreenshotTestComponentDslInfoImpl(
-    componentIdentity: ComponentIdentity,
-    componentType: ComponentType,
-    defaultConfig: DefaultConfig,
-    buildTypeObj: BuildType,
-    productFlavorList: List<ProductFlavor>,
-    services: VariantServices,
-    buildDirectory: DirectoryProperty,
-    mainVariantDslInfo: TestedVariantDslInfo,
-    extension: InternalTestedExtension<*, *, *, *, *, *>,
-) : HostTestComponentDslInfoImpl(
-    componentIdentity,
-    componentType,
-    defaultConfig,
-    buildTypeObj,
-    productFlavorList,
-    services,
-    buildDirectory,
-    mainVariantDslInfo,
-    extension,
-), HostTestComponentDslInfo {
-
-    override val namespace: Provider<String> by lazy {
-        getTestComponentNamespace(extension, services)
-    }
-
-    override val applicationId: Property<String> =
-        services.newPropertyBackingDeprecatedApi(
-            String::class.java,
-            initTestApplicationId(productFlavorList, defaultConfig, services)
-        )
-
-    override val minSdkVersion: MutableAndroidVersion
-        get() = mainVariantDslInfo.minSdkVersion
-
-}
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/UnitTestComponentDslInfoImpl.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/UnitTestComponentDslInfoImpl.kt
deleted file mode 100644
index ee28895..0000000
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/core/dsl/impl/UnitTestComponentDslInfoImpl.kt
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * 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 com.android.build.gradle.internal.core.dsl.impl
-
-import com.android.build.api.dsl.BuildType
-import com.android.build.api.dsl.ProductFlavor
-import com.android.build.api.variant.ComponentIdentity
-import com.android.build.api.variant.impl.MutableAndroidVersion
-import com.android.build.gradle.internal.core.dsl.TestedVariantDslInfo
-import com.android.build.gradle.internal.core.dsl.HostTestComponentDslInfo
-import com.android.build.gradle.internal.dsl.DefaultConfig
-import com.android.build.gradle.internal.dsl.InternalTestedExtension
-import com.android.build.gradle.internal.services.VariantServices
-import com.android.builder.core.ComponentType
-import org.gradle.api.file.DirectoryProperty
-import org.gradle.api.provider.Property
-import org.gradle.api.provider.Provider
-
-internal class UnitTestComponentDslInfoImpl(
-    componentIdentity: ComponentIdentity,
-    componentType: ComponentType,
-    defaultConfig: DefaultConfig,
-    buildTypeObj: BuildType,
-    productFlavorList: List<ProductFlavor>,
-    services: VariantServices,
-    buildDirectory: DirectoryProperty,
-    mainVariantDslInfo: TestedVariantDslInfo,
-    extension: InternalTestedExtension<*, *, *, *, *, *>
-) : HostTestComponentDslInfoImpl(
-    componentIdentity,
-    componentType,
-    defaultConfig,
-    buildTypeObj,
-    productFlavorList,
-    services,
-    buildDirectory,
-    mainVariantDslInfo,
-    extension
-), HostTestComponentDslInfo {
-
-    override val namespace: Provider<String> by lazy {
-        getTestComponentNamespace(extension, services)
-    }
-
-    override val applicationId: Property<String> =
-        services.newPropertyBackingDeprecatedApi(
-            String::class.java,
-            initTestApplicationId(productFlavorList, defaultConfig, services)
-        )
-
-    override val minSdkVersion: MutableAndroidVersion
-        get() = mainVariantDslInfo.minSdkVersion
-
-}
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/BaseVariantFactory.java b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/BaseVariantFactory.java
index 3bdf9d0..cd3e62e 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/BaseVariantFactory.java
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/BaseVariantFactory.java
@@ -23,7 +23,6 @@
 import com.android.build.api.component.impl.DeviceTestImpl;
 import com.android.build.api.component.impl.HostTestImpl;
 import com.android.build.api.component.impl.TestFixturesImpl;
-import com.android.build.api.component.impl.UnitTestImpl;
 import com.android.build.api.dsl.CommonExtension;
 import com.android.build.api.variant.ComponentIdentity;
 import com.android.build.api.variant.VariantBuilder;
@@ -124,7 +123,7 @@
             @NonNull GlobalTaskCreationConfig globalConfig,
             @NonNull HostTestBuilderImpl hostTestBuilder) {
         return dslServices.newInstance(
-                UnitTestImpl.class,
+                HostTestImpl.class,
                 componentIdentity,
                 createUnitTestBuildFeatures(buildFeatures),
                 dslInfo,
@@ -157,9 +156,7 @@
             @NonNull VariantServices variantServices,
             @NonNull TaskCreationServices taskCreationServices,
             @NonNull GlobalTaskCreationConfig globalConfig,
-            @NonNull HostTestBuilderImpl hostTestBuilder,
-            @NonNull String hostTestName,
-            boolean useBuiltInKotlinSupport) {
+            @NonNull HostTestBuilderImpl hostTestBuilder) {
         return dslServices.newInstance(
                 HostTestImpl.class,
                 componentIdentity,
@@ -175,9 +172,7 @@
                 variantServices,
                 taskCreationServices,
                 globalConfig,
-                hostTestBuilder,
-                hostTestName,
-                useBuiltInKotlinSupport);
+                hostTestBuilder);
     }
 
     @NonNull
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/TestVariantFactory.java b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/TestVariantFactory.java
index c0943bb..0f3e45a 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/TestVariantFactory.java
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/TestVariantFactory.java
@@ -233,9 +233,7 @@
             @NonNull VariantServices variantServices,
             @NonNull TaskCreationServices taskCreationServices,
             @NonNull GlobalTaskCreationConfig globalConfig,
-            @NonNull HostTestBuilderImpl hostTestBuilder,
-            @NonNull String hostTestType,
-            boolean useBuiltInKotlinSupport) {
+            @NonNull HostTestBuilderImpl hostTestBuilder) {
         throw new RuntimeException("cannot instantiate screenshot-test properties in test plugin");
     }
 
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/VariantFactory.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/VariantFactory.kt
index 7204bcc..b303c3f 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/VariantFactory.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/VariantFactory.kt
@@ -20,7 +20,6 @@
 import com.android.build.api.dsl.CommonExtension
 import com.android.build.api.dsl.DataBinding
 import com.android.build.api.variant.ComponentIdentity
-import com.android.build.api.variant.HostTestBuilder
 import com.android.build.api.variant.VariantBuilder
 import com.android.build.api.variant.impl.DeviceTestBuilderImpl
 import com.android.build.api.variant.impl.GlobalVariantBuilderConfig
@@ -132,8 +131,6 @@
             taskCreationServices: TaskCreationServices,
             globalConfig: GlobalTaskCreationConfig,
             hostTestBuilder: HostTestBuilderImpl,
-            hostTestName: String,
-            useBuiltInKotlinSupport: Boolean,
         ): HostTestCreationConfig
 
     fun createAndroidTest(