[go: nahoru, domu]

getProjectPathsInSameGroup -> getOtherProjectsInSameGroup

So we can more easily identify the filepath of the projects in the same group

In preparation for parsing the build.gradle files of those projects

Bug: 271282538

Change-Id: I3764031e40a980e13c905b45aeead4ac077f8298
(cherry picked from commit b34138e057aaf041d7218ba0d8dc49f37af94456)
Merged-In: I3764031e40a980e13c905b45aeead4ac077f8298
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXExtension.kt b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXExtension.kt
index cd96eac..3b4f41f 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXExtension.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXExtension.kt
@@ -123,15 +123,19 @@
             chooseProjectVersion()
         }
 
-    fun getAllProjectPathsInSameGroup(): List<String> {
-        val allProjectPaths = listProjectsService.get().allPossibleProjectPaths
+    fun getOtherProjectsInSameGroup(): List<SettingsParser.IncludedProject> {
+        val allProjects = listProjectsService.get().allPossibleProjects
         val ourGroup = chooseLibraryGroup()
         if (ourGroup == null)
-            return listOf(project.path)
-        val projectPathsInSameGroup = allProjectPaths.filter { otherPath ->
-            getLibraryGroupFromProjectPath(otherPath) == ourGroup
+            return listOf()
+        val otherProjectsInSameGroup = allProjects.filter { otherProject ->
+            if (otherProject.gradlePath == project.path) {
+                false
+            } else {
+                getLibraryGroupFromProjectPath(otherProject.gradlePath) == ourGroup
+            }
         }
-        return projectPathsInSameGroup
+        return otherProjectsInSameGroup
     }
 
     /**
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt
index 53b3ae3..4d3048d 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt
@@ -900,13 +900,13 @@
                     configuration.extendsFrom(constraintConfiguration)
             }
 
-            val otherProjectPathsInSameGroup = extension.getAllProjectPathsInSameGroup()
+            val otherProjectsInSameGroup = extension.getOtherProjectsInSameGroup()
+            val otherProjectPathsInSameGroup = otherProjectsInSameGroup.map { otherProject ->
+                otherProject.gradlePath
+            }
             val constraints = project.dependencies.constraints
             val allProjectsExist = buildContainsAllStandardProjects()
             for (otherPath in otherProjectPathsInSameGroup) {
-                // don't need a constraint pointing at self
-                if (otherPath == project.path)
-                    continue
                 // We only enable constraints for builds that we intend to be able to publish from.
                 //   If a project isn't included in a build we intend to be able to publish from,
                 //   the project isn't going to be published.
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/ListProjectsService.kt b/buildSrc/private/src/main/kotlin/androidx/build/ListProjectsService.kt
index e63c5a3..d84efcb6 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/ListProjectsService.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/ListProjectsService.kt
@@ -32,9 +32,7 @@
     // Note that this might be more than the full list of projects configured in this build:
     // a) Configuration-on-demand can disable projects mentioned in settings.gradle
     // B) Playground builds use their own settings.gradle files
-    val allPossibleProjectPaths: List<String> by lazy {
-        val allProjects = SettingsParser.findProjects(parameters.settingsFile.get())
-        val projectPaths = allProjects.map { project -> project.gradlePath }
-        projectPaths
+    val allPossibleProjects: List<SettingsParser.IncludedProject> by lazy {
+        SettingsParser.findProjects(parameters.settingsFile.get())
     }
 }