Merge "Merge cherrypicks of [1088556, 1088558, 1088561] into androidx-loader-release" into androidx-loader-release
diff --git a/buildSrc/jetpad-integration/src/main/java/androidx/build/jetpad/LibraryBuildInfoFile.java b/buildSrc/jetpad-integration/src/main/java/androidx/build/jetpad/LibraryBuildInfoFile.java
index e23bf0f..eebb259 100644
--- a/buildSrc/jetpad-integration/src/main/java/androidx/build/jetpad/LibraryBuildInfoFile.java
+++ b/buildSrc/jetpad-integration/src/main/java/androidx/build/jetpad/LibraryBuildInfoFile.java
@@ -29,6 +29,8 @@
   public String groupId;
   public String artifactId;
   public String version;
+  public String path;
+  public Boolean groupIdRequiresSameVersion;
   public ArrayList<Dependency> dependencies;
   public ArrayList<Check> checks;
 
diff --git a/buildSrc/src/main/kotlin/androidx/build/CreateLibraryBuildInfoFileTask.kt b/buildSrc/src/main/kotlin/androidx/build/CreateLibraryBuildInfoFileTask.kt
index 0e12bcd..f4b47a4 100644
--- a/buildSrc/src/main/kotlin/androidx/build/CreateLibraryBuildInfoFileTask.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/CreateLibraryBuildInfoFileTask.kt
@@ -45,6 +45,20 @@
         return "${project.group}_${project.name}_build_info.txt"
     }
 
+    /* Returns the local project directory without the full framework/support root directory path */
+    private fun getProjectSpecificDirectory(): String {
+        return project.projectDir.toString().removePrefix(project.rootDir.toString())
+    }
+
+    /* Returns whether or not the groupId of the project requires the same version for all
+     * artifactIds.  See CheckSameVersionLibraryGroupsTask.kt
+     */
+    private fun requiresSameVersion(): Boolean {
+        val library =
+            project.extensions.findByType(AndroidXExtension::class.java)
+        return library?.mavenGroup?.requireSameVersion ?: false
+    }
+
     private fun writeJsonToFile(info: LibraryBuildInfoFile) {
         if (!project.getBuildInfoDirectory().exists()) {
             if (!project.getBuildInfoDirectory().mkdirs()) {
@@ -71,28 +85,37 @@
         libraryBuildInfoFile.artifactId = project.name.toString()
         libraryBuildInfoFile.groupId = project.group.toString()
         libraryBuildInfoFile.version = project.version.toString()
+        libraryBuildInfoFile.path = getProjectSpecificDirectory()
+        libraryBuildInfoFile.groupIdRequiresSameVersion = requiresSameVersion()
         val libraryDependencies = ArrayList<LibraryBuildInfoFile.Dependency>()
         val checks = ArrayList<LibraryBuildInfoFile.Check>()
         libraryBuildInfoFile.checks = checks
         val publishedProjects = project.getProjectsMap()
-        project.configurations.all { configuration ->
+        project.configurations.filter {
+            /* Ignore test configuration dependencies */
+            !it.name.contains("test", ignoreCase = true)
+        }.forEach { configuration ->
             configuration.allDependencies.forEach { dep ->
                 // Only consider androidx dependencies
                 if (dep.group != null &&
                     dep.group.toString().startsWith("androidx.") &&
-                    !dep.group.toString().startsWith("androidx.test")) {
-                        if ((dep is ProjectDependency && publishedProjects
-                                .containsKey("${dep.group}:${dep.name}")) ||
-                                dep is ExternalModuleDependency) {
-                            val androidXPublishedDependency = LibraryBuildInfoFile().Dependency()
-                            androidXPublishedDependency.artifactId = dep.name.toString()
-                            androidXPublishedDependency.groupId = dep.group.toString()
-                            androidXPublishedDependency.version = dep.version.toString()
-                            androidXPublishedDependency.isTipOfTree = dep is ProjectDependency
-                            addDependencyToListIfNotAlreadyAdded(libraryDependencies,
-                                androidXPublishedDependency)
-                        }
+                    !dep.group.toString().startsWith("androidx.test")
+                ) {
+                    if ((dep is ProjectDependency && publishedProjects
+                            .containsKey("${dep.group}:${dep.name}")) ||
+                        dep is ExternalModuleDependency
+                    ) {
+                        val androidXPublishedDependency = LibraryBuildInfoFile().Dependency()
+                        androidXPublishedDependency.artifactId = dep.name.toString()
+                        androidXPublishedDependency.groupId = dep.group.toString()
+                        androidXPublishedDependency.version = dep.version.toString()
+                        androidXPublishedDependency.isTipOfTree = dep is ProjectDependency
+                        addDependencyToListIfNotAlreadyAdded(
+                            libraryDependencies,
+                            androidXPublishedDependency
+                        )
                     }
+                }
             }
         }
         libraryBuildInfoFile.dependencies = libraryDependencies