diff options
author | Googler <noreply@google.com> | 2017-11-01 15:30:47 -0400 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-11-02 10:04:14 -0400 |
commit | b2894caa2d4fae015ef735264767b3bd9a4c6817 (patch) | |
tree | 95e99eb2c9e0b48b59e2fa8fa7de13dc8e304236 /src/main/java/com/google/devtools/build/lib | |
parent | a0e5b2f4c4312685284e9fbe9be5a4f991eb60b3 (diff) |
Roll forward support for test resource inheritance behind a flag
RELNOTES: None
PiperOrigin-RevId: 174219672
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java | 17 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java index 0e7f3d85ac..f4ec88e95b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java @@ -662,6 +662,17 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { ) public boolean allowResourcesAttr; + @Option( + name = "experimental_android_inherit_resources_in_tests", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, + help = "If true, local_resource_files indicates that resource files should be inherited" + + "from deps in android_test targets. Otherwise, resources will not be inherited from" + + " deps for those targets." + ) + public boolean inheritResourcesInTests; + @Override public FragmentOptions getHost() { Options host = (Options) super.getHost(); @@ -743,6 +754,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { private final boolean useManifestFromResourceApk; private final boolean allowAndroidResources; private final boolean allowResourcesAttr; + private final boolean inheritResourcesInTests; AndroidConfiguration(Options options) throws InvalidConfigurationException { @@ -780,6 +792,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { this.useManifestFromResourceApk = options.useManifestFromResourceApk; this.allowAndroidResources = options.allowAndroidResources; this.allowResourcesAttr = options.allowResourcesAttr; + this.inheritResourcesInTests = options.inheritResourcesInTests; if (!dexoptsSupportedInIncrementalDexing.contains("--no-locals")) { // TODO(bazel-team): Still needed? See DexArchiveAspect @@ -934,6 +947,10 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { return this.allowResourcesAttr; } + public boolean inheritResourcesInTests() { + return this.inheritResourcesInTests; + } + @Override public void addGlobalMakeVariables(ImmutableMap.Builder<String, String> globalMakeEnvBuilder) { globalMakeEnvBuilder.put("ANDROID_CPU", cpu); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java index f97812665a..ce218c3236 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainer.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.rules.android; import com.google.auto.value.AutoValue; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; @@ -72,7 +73,8 @@ public abstract class ResourceContainer { abstract ImmutableList<Artifact> getAssets(); - abstract ImmutableList<Artifact> getResources(); + @VisibleForTesting + public abstract ImmutableList<Artifact> getResources(); public ImmutableList<Artifact> getArtifacts(ResourceType resourceType) { return resourceType == ResourceType.ASSETS ? getAssets() : getResources(); |