Only allow single publish setting for KMP libraries and publish all declared targets when publish is configured

Bug: 235594579
Test: Existing builds continue to work and produce correct artifacts
Change-Id: Ieca07201b198b084267c0c5645714f7e6420b6ec
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXExtension.kt b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXExtension.kt
index 3babb93..ac01224 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXExtension.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXExtension.kt
@@ -171,7 +171,7 @@
         if (publish != Publish.UNSET) {
             publish.shouldPublish()
         } else if (type != LibraryType.UNSET) {
-            type.publishExtension.shouldPublishAny()
+            type.publish.shouldPublish()
         } else {
             false
         }
@@ -180,14 +180,14 @@
         if (publish != Publish.UNSET) {
             publish.shouldRelease()
         } else if (type != LibraryType.UNSET) {
-            type.publishExtension.shouldReleaseAny()
+            type.publish.shouldRelease()
         } else {
             false
         }
 
     internal fun isPublishConfigured(): Boolean = (
             publish != Publish.UNSET ||
-            type.publishExtension.isPublishConfigured()
+            type.publish != Publish.UNSET
         )
 
     /**
@@ -202,7 +202,7 @@
         set(value) {
             // don't disable multiplatform if it's already enabled, because sometimes it's enabled
             // through flags and we don't want setting `type =` to disable it accidentally.
-            if (value.publishExtension.shouldEnableMultiplatform()) {
+            if (value.shouldEnableMultiplatform()) {
                 multiplatform = true
             }
             field = value
@@ -216,13 +216,6 @@
     var bypassCoordinateValidation = false
 
     /**
-     * Which KMP platforms are published by this project, as a list of artifact suffixes or an empty
-     * list for non-KMP projects.
-     */
-    val publishPlatforms: List<String>
-        get() = type.publishExtension.publishPlatforms
-
-    /**
      * Whether this project uses KMP.
      */
     private var multiplatform: Boolean = false
@@ -255,3 +248,5 @@
     var name: String? = null
     var url: String? = null
 }
+
+private fun LibraryType.shouldEnableMultiplatform() = this is LibraryType.KmpLibrary
\ No newline at end of file