diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2019-07-20 00:07:41 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-07-20 00:07:41 +0000 |
commit | 2f4798ac3386ba1c37d67391350a5a152d027595 (patch) | |
tree | 2b25be0d9f68edd56b5b56a41b771245d58ea875 | |
parent | 16d79836d845cec6f471f1d916cd94e56c75ab17 (diff) | |
parent | acbd2e79483931c2d86eba7e755ecc744a338570 (diff) | |
download | support-snap-temp-L82300000674275745.tar.gz |
Merge "Merge cherrypicks of [1087502, 1087505, 1087507] into androidx-collection-release" into androidx-collection-releasesnap-temp-L82300000674275745snap-temp-L71800000674719438snap-temp-L32500000731022494snap-temp-L19900000674731962snap-temp-L19800000675459869
-rw-r--r-- | buildSrc/jetpad-integration/src/main/java/androidx/build/jetpad/LibraryBuildInfoFile.java | 2 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/androidx/build/CreateLibraryBuildInfoFileTask.kt | 49 |
2 files changed, 38 insertions, 13 deletions
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 e23bf0f98cb..eebb2591d0c 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 class LibraryBuildInfoFile { 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 0e12bcd3522..f4b47a40803 100644 --- a/buildSrc/src/main/kotlin/androidx/build/CreateLibraryBuildInfoFileTask.kt +++ b/buildSrc/src/main/kotlin/androidx/build/CreateLibraryBuildInfoFileTask.kt @@ -45,6 +45,20 @@ open class CreateLibraryBuildInfoFileTask : DefaultTask() { 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 @@ open class CreateLibraryBuildInfoFileTask : DefaultTask() { 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 |