aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java17
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java9
2 files changed, 23 insertions, 3 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 6b48275d3f..e4b8c4d845 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
@@ -670,6 +670,17 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
)
public boolean inheritResourcesInTests;
+ @Option(
+ name = "android_fixed_resource_neverlinking",
+ defaultValue = "false",
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
+ effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
+ help = "If true, resources will properly not get propagated through neverlinked libraries."
+ + " Otherwise, the old behavior of propagating those resources if no resource-related"
+ + " attributes are specified in the neverlink library will be preserved."
+ )
+ public boolean fixedResourceNeverlinking;
+
@Override
public FragmentOptions getHost() {
Options host = (Options) super.getHost();
@@ -753,6 +764,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
private final boolean allowResourcesAttr;
private final boolean inheritResourcesInTests;
private final boolean skipParsingAction;
+ private final boolean fixedResourceNeverlinking;
AndroidConfiguration(Options options) throws InvalidConfigurationException {
@@ -791,6 +803,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
this.allowResourcesAttr = options.allowResourcesAttr;
this.inheritResourcesInTests = options.inheritResourcesInTests;
this.skipParsingAction = options.skipParsingAction;
+ this.fixedResourceNeverlinking = options.fixedResourceNeverlinking;
if (!dexoptsSupportedInIncrementalDexing.contains("--no-locals")) {
// TODO(bazel-team): Still needed? See DexArchiveAspect
@@ -954,6 +967,10 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
return this.skipParsingAction;
}
+ public boolean fixedResourceNeverlinking() {
+ return this.fixedResourceNeverlinking;
+ }
+
@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/AndroidLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
index 4a4ce729ce..d5bd4cb0b6 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
@@ -218,11 +218,14 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
return null;
}
} else {
- resourceApk = ResourceApk.fromTransitiveResources(
- ResourceDependencies.fromRuleResourceAndDeps(ruleContext, false /* neverlink */));
+ resourceApk =
+ ResourceApk.fromTransitiveResources(
+ ResourceDependencies.fromRuleResourceAndDeps(
+ ruleContext,
+ ruleContext.getFragment(AndroidConfiguration.class).fixedResourceNeverlinking()
+ && JavaCommon.isNeverLink(ruleContext)));
}
-
JavaTargetAttributes javaTargetAttributes = androidCommon.init(
javaSemantics,
androidSemantics,