Remove usages of AGP non-API artifact

Test: ./gradlew stableaidl:stableaidl-gradle-plugin:test
Change-Id: Idf569f4b16a525f8feda81d10731f8a8729b6a91
diff --git a/stableaidl/stableaidl-gradle-plugin/build.gradle b/stableaidl/stableaidl-gradle-plugin/build.gradle
index efce547..13fded7 100644
--- a/stableaidl/stableaidl-gradle-plugin/build.gradle
+++ b/stableaidl/stableaidl-gradle-plugin/build.gradle
@@ -31,11 +31,18 @@
 
 apply from: "../../buildSrc/kotlin-dsl-dependency.gradle"
 
+configurations {
+    // Config for plugin classpath to be used during tests
+    testPlugin {
+        canBeConsumed = false
+        canBeResolved = true
+    }
+}
+
 dependencies {
     implementation(findGradleKotlinDsl())
     implementation(gradleApi())
     implementation(libs.androidGradlePluginApi)
-    implementation(libs.androidGradlePluginz) // Needed for BaseExtension, see b/268237729.
     implementation(libs.androidToolsCommon)
     implementation(libs.androidToolsRepository)
     implementation(libs.androidToolsSdkCommon)
@@ -44,6 +51,9 @@
     implementation(libs.guava)
     implementation(libs.kotlinStdlib)
 
+    testPlugin(libs.androidGradlePluginz)
+
+    testImplementation(libs.androidGradlePluginz)
     testImplementation(gradleTestKit())
     testImplementation(project(":internal-testutils-gradle-plugin"))
     testImplementation(libs.androidToolsAnalyticsProtos)
@@ -53,6 +63,10 @@
     testImplementation(libs.truth)
 }
 
+tasks.withType(PluginUnderTestMetadata.class).named("pluginUnderTestMetadata").configure {
+    it.pluginClasspath.from(configurations.testPlugin)
+}
+
 gradlePlugin {
     plugins {
         stableAidl {