From b9a2e9ded67bdf6fff0a611d174096269f68a981 Mon Sep 17 00:00:00 2001 From: ajmichael Date: Mon, 17 Apr 2017 20:37:14 +0200 Subject: Add /sdk/extras/m2repository the list of Android SDK embedded Maven repositories. Fixes https://github.com/bazelbuild/bazel/issues/2830 RELNOTES: None PiperOrigin-RevId: 153367521 --- .../rules/android/AndroidSdkRepositoryFunction.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/google') diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java index 14b05372df..8b3c32b42d 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Maps.EntryTransformer; import com.google.devtools.build.lib.analysis.BlazeDirectories; @@ -62,6 +63,11 @@ public class AndroidSdkRepositoryFunction extends RepositoryFunction { private static final Revision MIN_BUILD_TOOLS_REVISION = new Revision(24, 0, 3); private static final String PATH_ENV_VAR = "ANDROID_HOME"; private static final ImmutableList PATH_ENV_VAR_AS_LIST = ImmutableList.of(PATH_ENV_VAR); + private static final ImmutableList LOCAL_MAVEN_REPOSITORIES = + ImmutableList.of( + "extras/android/m2repository", + "extras/google/m2repository", + "extras/m2repository"); @Override public boolean isLocal(Rule rule) { @@ -79,7 +85,7 @@ public class AndroidSdkRepositoryFunction extends RepositoryFunction { } @Override - public RepositoryDirectoryValue.Builder fetch(Rule rule, Path outputDirectory, + public RepositoryDirectoryValue.Builder fetch(Rule rule, final Path outputDirectory, BlazeDirectories directories, Environment env, Map markerData) throws SkyFunctionException, InterruptedException { Map environ = @@ -221,9 +227,15 @@ public class AndroidSdkRepositoryFunction extends RepositoryFunction { // All local maven repositories that are shipped in the Android SDK. // TODO(ajmichael): Create SkyKeys so that if the SDK changes, this function will get rerun. - Iterable localMavenRepositories = ImmutableList.of( - outputDirectory.getRelative("extras/android/m2repository"), - outputDirectory.getRelative("extras/google/m2repository")); + Iterable localMavenRepositories = + Lists.transform( + LOCAL_MAVEN_REPOSITORIES, + new Function() { + @Override + public Path apply(String pathFragment) { + return outputDirectory.getRelative(pathFragment); + } + }); try { SdkMavenRepository sdkExtrasRepository = SdkMavenRepository.create(Iterables.filter(localMavenRepositories, new Predicate() { -- cgit v1.2.3