From 3b760aff0f617607af1b2c0672ad89bc37e96421 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 1 Feb 2018 15:19:31 -0800 Subject: PiperOrigin-RevId: 184203570 --- .../lib/rules/android/ResourceDependencies.java | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java') diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java index ab9cefb844..9226d3376d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java @@ -104,8 +104,8 @@ public final class ResourceDependencies { if (!attributes.has(attr, BuildType.LABEL_LIST) && !attributes.has(attr, BuildType.LABEL)) { continue; } - for (AndroidResourcesProvider resources : - ruleContext.getPrerequisites(attr, Mode.TARGET, AndroidResourcesProvider.class)) { + for (AndroidResourcesInfo resources : + ruleContext.getPrerequisites(attr, Mode.TARGET, AndroidResourcesInfo.PROVIDER)) { transitiveDependencies.addTransitive(resources.getTransitiveAndroidResources()); directDependencies.addTransitive(resources.getDirectAndroidResources()); transitiveResources.addTransitive(resources.getTransitiveResources()); @@ -233,23 +233,22 @@ public final class ResourceDependencies { } /** - * Creates a new AndroidResourcesProvider with the supplied ResourceContainer as the direct dep. + * Creates a new AndroidResourcesInfo with the supplied ResourceContainer as the direct dep. * - *

When a library produces a new resource container the AndroidResourcesProvider should use - * that container as a the direct dependency for that library. This makes the consuming rule to + *

When a library produces a new resource container the AndroidResourcesInfo should use that + * container as a the direct dependency for that library. This makes the consuming rule to * identify the new container and merge appropriately. The previous direct dependencies are then * added to the transitive dependencies. * * @param label The label of the library exporting this provider. - * @param newDirectResource The new direct dependency for AndroidResourcesProvider + * @param newDirectResource The new direct dependency for AndroidResourcesInfo * @return A provider with the current resources and label. */ - public AndroidResourcesProvider toProvider( - Label label, ResourceContainer newDirectResource) { + public AndroidResourcesInfo toInfo(Label label, ResourceContainer newDirectResource) { if (neverlink) { - return ResourceDependencies.empty().toProvider(label); + return ResourceDependencies.empty().toInfo(label); } - return AndroidResourcesProvider.create( + return new AndroidResourcesInfo( label, NestedSetBuilder.naiveLinkOrder() .addTransitive(transitiveResourceContainers) @@ -272,19 +271,8 @@ public final class ResourceDependencies { withDirectAndTransitive(newDirectResource.getRTxt(), transitiveRTxt)); } - private static NestedSet withDirectAndTransitive( - @Nullable Artifact direct, NestedSet transitive) { - NestedSetBuilder builder = NestedSetBuilder.naiveLinkOrder(); - builder.addTransitive(transitive); - if (direct != null) { - builder.add(direct); - } - - return builder.build(); - } - /** - * Create a new AndroidResourcesProvider from the dependencies of this library. + * Create a new AndroidResourcesInfo from the dependencies of this library. * *

When a library doesn't export resources it should simply forward the current transitive and * direct resources to the consuming rule. This allows the consuming rule to make decisions about @@ -293,11 +281,11 @@ public final class ResourceDependencies { * @param label The label of the library exporting this provider. * @return A provider with the current resources and label. */ - public AndroidResourcesProvider toProvider(Label label) { + public AndroidResourcesInfo toInfo(Label label) { if (neverlink) { - return ResourceDependencies.empty().toProvider(label); + return ResourceDependencies.empty().toInfo(label); } - return AndroidResourcesProvider.create( + return new AndroidResourcesInfo( label, transitiveResourceContainers, directResourceContainers, @@ -311,6 +299,17 @@ public final class ResourceDependencies { transitiveRTxt); } + private static NestedSet withDirectAndTransitive( + @Nullable Artifact direct, NestedSet transitive) { + NestedSetBuilder builder = NestedSetBuilder.naiveLinkOrder(); + builder.addTransitive(transitive); + if (direct != null) { + builder.add(direct); + } + + return builder.build(); + } + /** * Provides an NestedSet of the direct and transitive resources. * -- cgit v1.2.3