diff options
author | Jerome Dochez <jedo@google.com> | 2015-04-28 11:48:02 -0700 |
---|---|---|
committer | Jerome Dochez <jedo@google.com> | 2015-04-29 08:53:06 -0700 |
commit | 903a665939dabb8909ce85e3e89b8d3d87e60d41 (patch) | |
tree | 3075238f6266414614820fa11c7453de25f3f1dc | |
parent | b94ae4de8cd6923a7a2d0465ac15c8a7dcf62e8f (diff) | |
download | buildSrc-903a665939dabb8909ce85e3e89b8d3d87e60d41.tar.gz |
updated logic to deal with cyclic dependencies.
project can have testCompile dependencies that depends itself on
the project, we should handle this.
Change-Id: I1815c0b2c6486cde9d5b7ec5783d5bd2ab177b30
-rw-r--r-- | src/main/groovy/com/android/tools/internal/artifacts/ArtifactDownloader.groovy | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/groovy/com/android/tools/internal/artifacts/ArtifactDownloader.groovy b/src/main/groovy/com/android/tools/internal/artifacts/ArtifactDownloader.groovy index 5debf09..759bdfb 100644 --- a/src/main/groovy/com/android/tools/internal/artifacts/ArtifactDownloader.groovy +++ b/src/main/groovy/com/android/tools/internal/artifacts/ArtifactDownloader.groovy @@ -28,6 +28,7 @@ import org.apache.commons.io.FileUtils import org.gradle.api.Project import org.gradle.api.UnknownDomainObjectException import org.gradle.api.artifacts.ModuleVersionIdentifier +import org.gradle.api.artifacts.component.ComponentIdentifier import org.gradle.api.artifacts.result.DependencyResult import org.gradle.api.artifacts.result.ResolutionResult import org.gradle.api.artifacts.result.ResolvedComponentResult @@ -145,6 +146,17 @@ class ArtifactDownloader { protected void buildArtifactList(ResolvedComponentResult module, Set<ModuleVersionIdentifier> list) { + buildRecursivelyArtifactList(module, list, new HashSet<ComponentIdentifier>()) + } + + private void buildRecursivelyArtifactList(ResolvedComponentResult module, + Set<ModuleVersionIdentifier> list, + Set<ComponentIdentifier> parsedArtifacts) { + + if (parsedArtifacts.contains(module.getId())) { + return + } + parsedArtifacts.add(module.getId()) list.add(module.moduleVersion) for (DependencyResult d : module.getDependencies()) { @@ -155,7 +167,8 @@ class ArtifactDownloader { // attempted.getGroup(), attempted.getName(), attempted.getVersion()) // list.add(id) } else { - buildArtifactList(((ResolvedDependencyResult) d).getSelected(), list) + buildRecursivelyArtifactList( + ((ResolvedDependencyResult) d).getSelected(), list, parsedArtifacts) } } } |