aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-10-15 16:21:25 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2015-10-16 07:39:08 +0000
commit65425810207c9fd6892abfaa95da65e25db5e515 (patch)
treeceb20dee92f422c533a8ed632b92d626f44bb9b6 /src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java
parentc1caffaabd028493188b7e3419bedf3a9506dfee (diff)
Change the resource dependency handling to separate between the transitive and direct resources from libraries.
This slightly increases the complexity of resource propagation. The initial algorithm was to simply merge all transitive ResourceContainers together with any new ResourceContainer and propagate them via the AndroidResourcesProvider. The new algorithm is encapsulated inside a new ResourceDependencies class which works as follows: 1. Collect resources from the deps into transitive and direct NestedSets 2. If a rule provides a ResourceContainer, merge the transitive and direct into a new transitive set 3. Export the provider This results having a rule without resources "forward" the merged sets of transitive and direct resources to the next rule. -- MOS_MIGRATED_REVID=105515074
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java
index e2fda51aba..24e3174a42 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProvider.java
@@ -28,43 +28,50 @@ import java.util.Objects;
import javax.annotation.Nullable;
/**
- * A provider that supplies Android resources from its transitive closure.
+ * A provider that supplies ResourceContainers from its transitive closure.
*/
@Immutable
public final class AndroidResourcesProvider implements TransitiveInfoProvider {
-
private final Label label;
private final NestedSet<ResourceContainer> transitiveAndroidResources;
+ private final NestedSet<ResourceContainer> directAndroidResources;
- public AndroidResourcesProvider(Label label,
- NestedSet<ResourceContainer> transitiveAndroidResources) {
+ public AndroidResourcesProvider(
+ Label label, NestedSet<ResourceContainer> transitiveAndroidResources,
+ NestedSet<ResourceContainer> directAndroidResources) {
this.label = label;
+ this.directAndroidResources = directAndroidResources;
this.transitiveAndroidResources = transitiveAndroidResources;
}
/**
* Returns the label that is associated with this piece of information.
- *
- * <p>
- * This is usually the label of the target that provides the information.
*/
public Label getLabel() {
return label;
}
/**
- * Returns transitive Android resources (APK, assets, etc.).
+ * Returns the transitive ResourceContainers for the label.
*/
public NestedSet<ResourceContainer> getTransitiveAndroidResources() {
return transitiveAndroidResources;
}
+ /**
+ * Returns the immediate ResourceContainers for the label.
+ */
+ public NestedSet<ResourceContainer> getDirectAndroidResources() {
+ return directAndroidResources;
+ }
+
/**
* The type of resource in question: either asset or a resource.
*/
public enum ResourceType {
- ASSETS("assets"), RESOURCES("resources");
+ ASSETS("assets"),
+ RESOURCES("resources");
private final String attribute;
@@ -83,7 +90,6 @@ public final class AndroidResourcesProvider implements TransitiveInfoProvider {
*/
@Immutable
public static final class ResourceContainer {
-
private final Label label;
private final String javaPackage;
private final String renameManifestPackage;
@@ -102,10 +108,8 @@ public final class AndroidResourcesProvider implements TransitiveInfoProvider {
public ResourceContainer(Label label,
String javaPackage,
@Nullable String renameManifestPackage,
- boolean constantsInlined,
- Artifact apk,
- Artifact manifest,
- Artifact javaSourceJar,
+ boolean constantsInlined, Artifact apk,
+ Artifact manifest, Artifact javaSourceJar,
ImmutableList<Artifact> assets,
ImmutableList<Artifact> resources,
ImmutableList<PathFragment> assetsRoots,
@@ -184,7 +188,7 @@ public final class AndroidResourcesProvider implements TransitiveInfoProvider {
@Override
public int hashCode() {
- return Objects.hashCode(label);
+ return Objects.hash(label, rTxt, symbolsTxt);
}
@Override
@@ -196,7 +200,20 @@ public final class AndroidResourcesProvider implements TransitiveInfoProvider {
return false;
}
ResourceContainer other = (ResourceContainer) obj;
- return label.equals(other.label);
+ return Objects.equals(label, other.label)
+ && Objects.equals(rTxt, other.rTxt)
+ && Objects.equals(symbolsTxt, other.symbolsTxt);
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "ResourceContainer [label=%s, javaPackage=%s, renameManifestPackage=%s,"
+ + " constantsInlined=%s, apk=%s, manifest=%s, assets=%s, resources=%s, assetsRoots=%s,"
+ + " resourcesRoots=%s, manifestExported=%s, javaSourceJar=%s, rTxt=%s, symbolsTxt=%s]",
+ label, javaPackage, renameManifestPackage, constantsInlined, apk, manifest, assets,
+ resources, assetsRoots, resourcesRoots, manifestExported, javaSourceJar, rTxt,
+ symbolsTxt);
}
}
}