aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar asteinb <asteinb@google.com>2018-08-08 09:52:27 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-08 09:54:22 -0700
commit25f112e0eba147f14ac51736c41ced3d6b284b57 (patch)
tree4845449ba4f7be6b6ad5f74340e82ecfcf2fc336 /src/main
parent30c601dc13d9e1b40a57434c022c888c7578cc56 (diff)
Remove ValidatedAndroidData interface
Now that ValidatedAndroidResources is the only implementation, we can just use that instead. RELNOTES: none PiperOrigin-RevId: 207900844
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesInfo.java21
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java44
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkData.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/MergedAndroidResources.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java26
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ResourceDependencies.java31
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ResourceFilter.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java14
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java28
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidData.java70
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java14
15 files changed, 113 insertions, 185 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
index 5cede5999f..3c723466f0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
@@ -834,7 +834,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
static Optional<Artifact> maybeShrinkResources(
AndroidDataContext dataContext,
- ValidatedAndroidData validatedResources,
+ ValidatedAndroidResources validatedResources,
ResourceDependencies resourceDeps,
ImmutableList<Artifact> proguardSpecs,
Artifact proguardOutputJar,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesInfo.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesInfo.java
index 919c42b10a..d374239a55 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesInfo.java
@@ -27,7 +27,8 @@ import com.google.devtools.build.lib.syntax.SkylarkNestedSet;
/** A provider that supplies ResourceContainers from its transitive closure. */
@Immutable
public class AndroidResourcesInfo extends NativeInfo
- implements AndroidResourcesInfoApi<Artifact, ValidatedAndroidData, ProcessedAndroidManifest> {
+ implements AndroidResourcesInfoApi<
+ Artifact, ValidatedAndroidResources, ProcessedAndroidManifest> {
public static final String PROVIDER_NAME = "AndroidResourcesInfo";
public static final Provider PROVIDER = new Provider();
@@ -52,8 +53,8 @@ public class AndroidResourcesInfo extends NativeInfo
* Transitive information used for resource processing
*/
- private final NestedSet<ValidatedAndroidData> transitiveAndroidResources;
- private final NestedSet<ValidatedAndroidData> directAndroidResources;
+ private final NestedSet<ValidatedAndroidResources> transitiveAndroidResources;
+ private final NestedSet<ValidatedAndroidResources> directAndroidResources;
private final NestedSet<Artifact> transitiveResources;
private final NestedSet<Artifact> transitiveAssets;
private final NestedSet<Artifact> transitiveManifests;
@@ -67,8 +68,8 @@ public class AndroidResourcesInfo extends NativeInfo
Label label,
ProcessedAndroidManifest manifest,
Artifact rTxt,
- NestedSet<ValidatedAndroidData> transitiveAndroidResources,
- NestedSet<ValidatedAndroidData> directAndroidResources,
+ NestedSet<ValidatedAndroidResources> transitiveAndroidResources,
+ NestedSet<ValidatedAndroidResources> directAndroidResources,
NestedSet<Artifact> transitiveResources,
NestedSet<Artifact> transitiveAssets,
NestedSet<Artifact> transitiveManifests,
@@ -109,12 +110,12 @@ public class AndroidResourcesInfo extends NativeInfo
}
@Override
- public NestedSet<ValidatedAndroidData> getTransitiveAndroidResources() {
+ public NestedSet<ValidatedAndroidResources> getTransitiveAndroidResources() {
return transitiveAndroidResources;
}
@Override
- public NestedSet<ValidatedAndroidData> getDirectAndroidResources() {
+ public NestedSet<ValidatedAndroidResources> getDirectAndroidResources() {
return directAndroidResources;
}
@@ -162,7 +163,7 @@ public class AndroidResourcesInfo extends NativeInfo
/** Provider for {@link AndroidResourcesInfo}. */
public static class Provider extends BuiltinProvider<AndroidResourcesInfo>
implements AndroidResourcesInfoApi.AndroidResourcesInfoApiProvider<
- Artifact, ValidatedAndroidData, ProcessedAndroidManifest> {
+ Artifact, ValidatedAndroidResources, ProcessedAndroidManifest> {
private Provider() {
super(PROVIDER_NAME, AndroidResourcesInfo.class);
@@ -188,8 +189,8 @@ public class AndroidResourcesInfo extends NativeInfo
label,
manifest,
rTxt,
- nestedSet(transitiveAndroidResources, ValidatedAndroidData.class),
- nestedSet(directAndroidResources, ValidatedAndroidData.class),
+ nestedSet(transitiveAndroidResources, ValidatedAndroidResources.class),
+ nestedSet(directAndroidResources, ValidatedAndroidResources.class),
nestedSet(transitiveResources, Artifact.class),
nestedSet(transitiveAssets, Artifact.class),
nestedSet(transitiveManifests, Artifact.class),
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
index 10b5f1ae05..6f7bb122e5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
@@ -46,34 +46,34 @@ public class AndroidResourcesProcessorBuilder {
.build();
@AutoCodec @VisibleForSerialization
- static final AndroidDataConverter<ValidatedAndroidData> AAPT2_RESOURCE_DEP_TO_ARG =
- AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA)
- .withRoots(ValidatedAndroidData::getResourceRoots)
- .withRoots(ValidatedAndroidData::getAssetRoots)
- .withArtifact(ValidatedAndroidData::getManifest)
- .maybeWithArtifact(ValidatedAndroidData::getAapt2RTxt)
- .maybeWithArtifact(ValidatedAndroidData::getCompiledSymbols)
- .maybeWithArtifact(ValidatedAndroidData::getSymbols)
+ static final AndroidDataConverter<ValidatedAndroidResources> AAPT2_RESOURCE_DEP_TO_ARG =
+ AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
+ .withRoots(ValidatedAndroidResources::getResourceRoots)
+ .withRoots(ValidatedAndroidResources::getAssetRoots)
+ .withArtifact(ValidatedAndroidResources::getManifest)
+ .maybeWithArtifact(ValidatedAndroidResources::getAapt2RTxt)
+ .maybeWithArtifact(ValidatedAndroidResources::getCompiledSymbols)
+ .maybeWithArtifact(ValidatedAndroidResources::getSymbols)
.build();
@AutoCodec @VisibleForSerialization
- static final AndroidDataConverter<ValidatedAndroidData> AAPT2_RESOURCE_DEP_TO_ARG_NO_PARSE =
- AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA)
- .withRoots(ValidatedAndroidData::getResourceRoots)
- .withRoots(ValidatedAndroidData::getAssetRoots)
- .withArtifact(ValidatedAndroidData::getManifest)
- .maybeWithArtifact(ValidatedAndroidData::getAapt2RTxt)
- .maybeWithArtifact(ValidatedAndroidData::getCompiledSymbols)
+ static final AndroidDataConverter<ValidatedAndroidResources> AAPT2_RESOURCE_DEP_TO_ARG_NO_PARSE =
+ AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
+ .withRoots(ValidatedAndroidResources::getResourceRoots)
+ .withRoots(ValidatedAndroidResources::getAssetRoots)
+ .withArtifact(ValidatedAndroidResources::getManifest)
+ .maybeWithArtifact(ValidatedAndroidResources::getAapt2RTxt)
+ .maybeWithArtifact(ValidatedAndroidResources::getCompiledSymbols)
.build();
@AutoCodec @VisibleForSerialization
- static final AndroidDataConverter<ValidatedAndroidData> RESOURCE_DEP_TO_ARG =
- AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA)
- .withRoots(ValidatedAndroidData::getResourceRoots)
- .withRoots(ValidatedAndroidData::getAssetRoots)
- .withArtifact(ValidatedAndroidData::getManifest)
- .maybeWithArtifact(ValidatedAndroidData::getRTxt)
- .maybeWithArtifact(ValidatedAndroidData::getSymbols)
+ static final AndroidDataConverter<ValidatedAndroidResources> RESOURCE_DEP_TO_ARG =
+ AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
+ .withRoots(ValidatedAndroidResources::getResourceRoots)
+ .withRoots(ValidatedAndroidResources::getAssetRoots)
+ .withArtifact(ValidatedAndroidResources::getManifest)
+ .maybeWithArtifact(ValidatedAndroidResources::getRTxt)
+ .maybeWithArtifact(ValidatedAndroidResources::getSymbols)
.build();
private ResourceDependencies resourceDependencies = ResourceDependencies.empty();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java
index 190f987a51..b07584439e 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkApiProvider.java
@@ -97,7 +97,7 @@ public class AndroidSkylarkApiProvider extends SkylarkApiProvider
@Override
public NestedSet<Artifact> getResources() {
- return collectDirectArtifacts(ValidatedAndroidData::getResources);
+ return collectDirectArtifacts(ValidatedAndroidResources::getResources);
}
@Override
@@ -112,12 +112,13 @@ public class AndroidSkylarkApiProvider extends SkylarkApiProvider
}
private NestedSet<Artifact> collectDirectArtifacts(
- final Function<ValidatedAndroidData, Iterable<Artifact>> artifactFunction) {
+ final Function<ValidatedAndroidResources, Iterable<Artifact>> artifactFunction) {
if (resourceInfo == null) {
return NestedSetBuilder.emptySet(Order.STABLE_ORDER);
}
// This will iterate over all (direct) resources. If this turns out to be a performance
- // problem, {@link ValidatedAndroidData#getArtifacts()} can be changed to return NestedSets.
+ // problem, {@link ValidatedAndroidResources#getArtifacts()} can be changed to return
+ // NestedSets.
return NestedSetBuilder.wrap(
Order.STABLE_ORDER,
Iterables.concat(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkData.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkData.java
index 02f9808292..e23d77156e 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkData.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkData.java
@@ -216,16 +216,10 @@ public abstract class AndroidSkylarkData
boolean definesLocalResources = resourcesInfo.getDirectAndroidResources().isSingleton();
AndroidResources resources = AndroidResources.empty();
if (definesLocalResources) {
- ValidatedAndroidData validatedAndroidData =
+ ValidatedAndroidResources validatedAndroidResources =
resourcesInfo.getDirectAndroidResources().toList().get(0);
- if (validatedAndroidData.getLabel().equals(ctx.getLabel())) {
- // TODO(b/77574966): Remove this cast once we get rid of ResourceContainer and can guarantee
- // that only properly processed resources are passed into this object.
- if (!(validatedAndroidData instanceof ValidatedAndroidResources)) {
- throw new EvalException(
- Location.BUILTIN, "Old data processing pipeline does not support the Skylark API");
- }
- resources = (ValidatedAndroidResources) validatedAndroidData;
+ if (validatedAndroidResources.getLabel().equals(ctx.getLabel())) {
+ resources = validatedAndroidResources;
} else {
definesLocalResources = false;
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java b/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java
index 7268da113f..3b4f239a1a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java
@@ -242,10 +242,10 @@ public final class ApplicationManifest {
}
private static Map<Artifact, Label> getMergeeManifests(
- Iterable<ValidatedAndroidData> transitiveData) {
+ Iterable<ValidatedAndroidResources> transitiveData) {
ImmutableSortedMap.Builder<Artifact, Label> builder =
ImmutableSortedMap.orderedBy(Artifact.EXEC_PATH_COMPARATOR);
- for (ValidatedAndroidData d : transitiveData) {
+ for (ValidatedAndroidResources d : transitiveData) {
if (d.isManifestExported()) {
builder.put(d.getManifest(), d.getLabel());
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/MergedAndroidResources.java b/src/main/java/com/google/devtools/build/lib/rules/android/MergedAndroidResources.java
index 3ebefa4383..8c935be556 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/MergedAndroidResources.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/MergedAndroidResources.java
@@ -107,6 +107,15 @@ public class MergedAndroidResources extends ParsedAndroidResources {
this.manifest = manifest;
}
+ /**
+ * Gets an Artifact containing a zip of merged resources.
+ *
+ * <p>If assets were processed together with resources, the zip will also contain merged assets.
+ *
+ * @deprecated This artifact is produced by an often-expensive action and should not be used if
+ * another option is available. Furthermore, it will be replaced by flat files once we
+ * completely move to aapt2.
+ */
@Deprecated
public Artifact getMergedResources() {
return mergedResources;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java
index fe354b8824..379b0d4874 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java
@@ -18,21 +18,20 @@ import com.google.devtools.build.lib.rules.android.AndroidConfiguration.AndroidA
import com.google.devtools.build.lib.rules.android.AndroidDataConverter.JoinerType;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
-import java.io.Serializable;
import java.util.function.Function;
/** Builds up the spawn action for $android_rclass_generator. */
public class RClassGeneratorActionBuilder {
@AutoCodec @VisibleForSerialization
- static final AndroidDataConverter<ValidatedAndroidData> AAPT_CONVERTER =
- AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA)
+ static final AndroidDataConverter<ValidatedAndroidResources> AAPT_CONVERTER =
+ AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
.with(chooseDepsToArg(AndroidAaptVersion.AAPT))
.build();
@AutoCodec @VisibleForSerialization
- static final AndroidDataConverter<ValidatedAndroidData> AAPT2_CONVERTER =
- AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA)
+ static final AndroidDataConverter<ValidatedAndroidResources> AAPT2_CONVERTER =
+ AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
.with(chooseDepsToArg(AndroidAaptVersion.AAPT2))
.build();
@@ -90,15 +89,14 @@ public class RClassGeneratorActionBuilder {
.buildAndRegister("Generating R Classes", "RClassGenerator");
}
- private static Function<ValidatedAndroidData, String> chooseDepsToArg(
+ private static Function<ValidatedAndroidResources, String> chooseDepsToArg(
final AndroidAaptVersion version) {
- return (Function<ValidatedAndroidData, String> & Serializable)
- container -> {
- Artifact rTxt =
- version == AndroidAaptVersion.AAPT2 ? container.getAapt2RTxt() : container.getRTxt();
- return (rTxt != null ? rTxt.getExecPath() : "")
- + ","
- + (container.getManifest() != null ? container.getManifest().getExecPath() : "");
- };
+ return container -> {
+ Artifact rTxt =
+ version == AndroidAaptVersion.AAPT2 ? container.getAapt2RTxt() : container.getRTxt();
+ return (rTxt != null ? rTxt.getExecPath() : "")
+ + ","
+ + (container.getManifest() != null ? container.getManifest().getExecPath() : "");
+ };
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java
index 03e192bb2e..bfba2218bf 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceApk.java
@@ -38,9 +38,9 @@ public final class ResourceApk {
private final AssetDependencies assetDeps;
/**
* Validated Android resource information. Will be null when this class is built from transitive
- * resources only, and will be a superset of primaryResources otherwise.
+ * resources only, and will be equal to primaryResources otherwise.
*/
- @Nullable private final ValidatedAndroidData validatedResources;
+ @Nullable private final ValidatedAndroidResources validatedResources;
private final AndroidResources primaryResources;
private final AndroidAssets primaryAssets;
@@ -79,7 +79,7 @@ public final class ResourceApk {
@Nullable Artifact resourceJavaClassJar,
ResourceDependencies resourceDeps,
AssetDependencies assetDeps,
- @Nullable ValidatedAndroidData validatedResources,
+ @Nullable ValidatedAndroidResources validatedResources,
AndroidResources primaryResources,
AndroidAssets primaryAssets,
ProcessedAndroidManifest manifest,
@@ -124,7 +124,7 @@ public final class ResourceApk {
}
@Nullable
- public ValidatedAndroidData getValidatedResources() {
+ public ValidatedAndroidResources getValidatedResources() {
return validatedResources;
}
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 ac0fbc652b..01effdaab9 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
@@ -50,7 +50,7 @@ public final class ResourceDependencies {
* This should allow greater efficiency since we don't need to unroll this NestedSet to get a
* particular input. TODO (b/67996945): Complete this migration.
*/
- @Deprecated private final NestedSet<ValidatedAndroidData> transitiveResourceContainers;
+ @Deprecated private final NestedSet<ValidatedAndroidResources> transitiveResourceContainers;
/**
* Contains all the direct dependencies of the current target. Since a given direct dependency can
@@ -61,7 +61,7 @@ public final class ResourceDependencies {
* @deprecated Similarly to {@link #transitiveResourceContainers}, we are moving away from storing
* ResourceContainer objects here. TODO (b/67996945): Complete this migration.
*/
- @Deprecated private final NestedSet<ValidatedAndroidData> directResourceContainers;
+ @Deprecated private final NestedSet<ValidatedAndroidResources> directResourceContainers;
/**
* Transitive resource files for this target.
@@ -97,9 +97,10 @@ public final class ResourceDependencies {
public static ResourceDependencies fromProviders(
Iterable<AndroidResourcesInfo> providers, boolean neverlink) {
- NestedSetBuilder<ValidatedAndroidData> transitiveDependencies =
+ NestedSetBuilder<ValidatedAndroidResources> transitiveDependencies =
+ NestedSetBuilder.naiveLinkOrder();
+ NestedSetBuilder<ValidatedAndroidResources> directDependencies =
NestedSetBuilder.naiveLinkOrder();
- NestedSetBuilder<ValidatedAndroidData> directDependencies = NestedSetBuilder.naiveLinkOrder();
NestedSetBuilder<Artifact> transitiveResources = NestedSetBuilder.naiveLinkOrder();
NestedSetBuilder<Artifact> transitiveAssets = NestedSetBuilder.naiveLinkOrder();
NestedSetBuilder<Artifact> transitiveManifests = NestedSetBuilder.naiveLinkOrder();
@@ -174,8 +175,8 @@ public final class ResourceDependencies {
private ResourceDependencies(
boolean neverlink,
- NestedSet<ValidatedAndroidData> transitiveResourceContainers,
- NestedSet<ValidatedAndroidData> directResourceContainers,
+ NestedSet<ValidatedAndroidResources> transitiveResourceContainers,
+ NestedSet<ValidatedAndroidResources> directResourceContainers,
NestedSet<Artifact> transitiveResources,
NestedSet<Artifact> transitiveAssets,
NestedSet<Artifact> transitiveManifests,
@@ -219,8 +220,8 @@ public final class ResourceDependencies {
@VisibleForTesting
ResourceDependencies withResources(
- NestedSet<ValidatedAndroidData> transitiveResourceContainers,
- NestedSet<ValidatedAndroidData> directResourceContainers,
+ NestedSet<ValidatedAndroidResources> transitiveResourceContainers,
+ NestedSet<ValidatedAndroidResources> directResourceContainers,
NestedSet<Artifact> transitiveResources) {
return new ResourceDependencies(
neverlink,
@@ -247,7 +248,7 @@ public final class ResourceDependencies {
* @param newDirectResource The new direct dependency for AndroidResourcesInfo
* @return A provider with the current resources and label.
*/
- public AndroidResourcesInfo toInfo(ValidatedAndroidData newDirectResource) {
+ public AndroidResourcesInfo toInfo(ValidatedAndroidResources newDirectResource) {
if (neverlink) {
return ResourceDependencies.empty()
.toInfo(
@@ -259,11 +260,11 @@ public final class ResourceDependencies {
newDirectResource.getLabel(),
newDirectResource.getProcessedManifest(),
newDirectResource.getRTxt(),
- NestedSetBuilder.<ValidatedAndroidData>naiveLinkOrder()
+ NestedSetBuilder.<ValidatedAndroidResources>naiveLinkOrder()
.addTransitive(transitiveResourceContainers)
.addTransitive(directResourceContainers)
.build(),
- NestedSetBuilder.<ValidatedAndroidData>naiveLinkOrder()
+ NestedSetBuilder.<ValidatedAndroidResources>naiveLinkOrder()
.add(newDirectResource.export())
.build(),
NestedSetBuilder.<Artifact>naiveLinkOrder()
@@ -331,8 +332,8 @@ public final class ResourceDependencies {
* get the specific Artifacts you need instead.
*/
@Deprecated
- public NestedSet<ValidatedAndroidData> getResourceContainers() {
- return NestedSetBuilder.<ValidatedAndroidData>naiveLinkOrder()
+ public NestedSet<ValidatedAndroidResources> getResourceContainers() {
+ return NestedSetBuilder.<ValidatedAndroidResources>naiveLinkOrder()
.addTransitive(directResourceContainers)
.addTransitive(transitiveResourceContainers)
.build();
@@ -343,7 +344,7 @@ public final class ResourceDependencies {
* get the specific Artifacts you need instead.
*/
@Deprecated
- public NestedSet<ValidatedAndroidData> getTransitiveResourceContainers() {
+ public NestedSet<ValidatedAndroidResources> getTransitiveResourceContainers() {
return transitiveResourceContainers;
}
@@ -352,7 +353,7 @@ public final class ResourceDependencies {
* get the specific Artifacts you need instead.
*/
@Deprecated
- public NestedSet<ValidatedAndroidData> getDirectResourceContainers() {
+ public NestedSet<ValidatedAndroidResources> getDirectResourceContainers() {
return directResourceContainers;
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceFilter.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceFilter.java
index 15ef00a243..51688cda12 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceFilter.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceFilter.java
@@ -65,17 +65,17 @@ public class ResourceFilter {
return Optional.of(NestedSetBuilder.wrap(artifacts.getOrder(), filtered));
}
- public NestedSet<ValidatedAndroidData> filterDependencyContainers(
- RuleErrorConsumer errorConsumer, NestedSet<ValidatedAndroidData> resourceContainers)
+ public NestedSet<ValidatedAndroidResources> filterDependencyContainers(
+ RuleErrorConsumer errorConsumer, NestedSet<ValidatedAndroidResources> resourceContainers)
throws RuleErrorException {
if (isEmpty) {
return resourceContainers;
}
- NestedSetBuilder<ValidatedAndroidData> builder =
+ NestedSetBuilder<ValidatedAndroidResources> builder =
new NestedSetBuilder<>(resourceContainers.getOrder());
- for (ValidatedAndroidData container : resourceContainers) {
+ for (ValidatedAndroidResources container : resourceContainers) {
builder.add(container.filter(errorConsumer, this, /* isDependency = */ true));
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java
index a327e4ac63..a95f27924a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java
@@ -27,7 +27,7 @@ public class ResourceShrinkerActionBuilder {
private Artifact resourceFilesZip;
private Artifact shrunkJar;
private Artifact proguardMapping;
- private ValidatedAndroidData primaryResources;
+ private ValidatedAndroidResources primaryResources;
private ResourceDependencies dependencyResources;
private Artifact resourceApkOut;
private Artifact shrunkResourcesOut;
@@ -68,10 +68,10 @@ public class ResourceShrinkerActionBuilder {
}
/**
- * @param primary The fully processed {@link ValidatedAndroidData} of the resources to be shrunk.
- * Must contain both an R.txt and merged manifest.
+ * @param primary The fully processed {@link ValidatedAndroidResources} of the resources to be
+ * shrunk. Must contain both an R.txt and merged manifest.
*/
- public ResourceShrinkerActionBuilder withPrimary(ValidatedAndroidData primary) {
+ public ResourceShrinkerActionBuilder withPrimary(ValidatedAndroidResources primary) {
checkNotNull(primary);
checkNotNull(primary.getManifest());
checkNotNull(primary.getRTxt());
@@ -150,7 +150,7 @@ public class ResourceShrinkerActionBuilder {
private ImmutableList<Artifact> getManifests(ResourceDependencies resourceDependencies) {
ImmutableList.Builder<Artifact> manifests = ImmutableList.builder();
- for (ValidatedAndroidData resources : resourceDependencies.getResourceContainers()) {
+ for (ValidatedAndroidResources resources : resourceDependencies.getResourceContainers()) {
if (resources.getManifest() != null) {
manifests.add(resources.getManifest());
}
@@ -159,10 +159,10 @@ public class ResourceShrinkerActionBuilder {
}
private ImmutableList<String> getResourcePackages(
- ValidatedAndroidData primaryResources, ResourceDependencies resourceDependencies) {
+ ValidatedAndroidResources primaryResources, ResourceDependencies resourceDependencies) {
ImmutableList.Builder<String> resourcePackages = ImmutableList.builder();
resourcePackages.add(primaryResources.getJavaPackage());
- for (ValidatedAndroidData resources : resourceDependencies.getResourceContainers()) {
+ for (ValidatedAndroidResources resources : resourceDependencies.getResourceContainers()) {
resourcePackages.add(resources.getJavaPackage());
}
return resourcePackages.build();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java
index 1fd1d2059a..dd9fb13b6c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java
@@ -30,23 +30,23 @@ import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.
public class RobolectricResourceSymbolsActionBuilder {
@AutoCodec @VisibleForSerialization
- static final AndroidDataConverter<ValidatedAndroidData> TO_ARG =
- AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA)
- .withRoots(ValidatedAndroidData::getResourceRoots)
- .withRoots(ValidatedAndroidData::getAssetRoots)
- .withArtifact(ValidatedAndroidData::getManifest)
- .maybeWithArtifact(ValidatedAndroidData::getRTxt)
- .maybeWithArtifact(ValidatedAndroidData::getSymbols)
+ static final AndroidDataConverter<ValidatedAndroidResources> TO_ARG =
+ AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
+ .withRoots(ValidatedAndroidResources::getResourceRoots)
+ .withRoots(ValidatedAndroidResources::getAssetRoots)
+ .withArtifact(ValidatedAndroidResources::getManifest)
+ .maybeWithArtifact(ValidatedAndroidResources::getRTxt)
+ .maybeWithArtifact(ValidatedAndroidResources::getSymbols)
.build();
@AutoCodec @VisibleForSerialization
- static final AndroidDataConverter<ValidatedAndroidData> TO_ARG_AAPT2 =
- AndroidDataConverter.<ValidatedAndroidData>builder(JoinerType.COLON_COMMA)
- .withRoots(ValidatedAndroidData::getResourceRoots)
- .withRoots(ValidatedAndroidData::getAssetRoots)
- .withArtifact(ValidatedAndroidData::getManifest)
- .maybeWithArtifact(ValidatedAndroidData::getAapt2RTxt)
- .maybeWithArtifact(ValidatedAndroidData::getSymbols)
+ static final AndroidDataConverter<ValidatedAndroidResources> TO_ARG_AAPT2 =
+ AndroidDataConverter.<ValidatedAndroidResources>builder(JoinerType.COLON_COMMA)
+ .withRoots(ValidatedAndroidResources::getResourceRoots)
+ .withRoots(ValidatedAndroidResources::getAssetRoots)
+ .withArtifact(ValidatedAndroidResources::getManifest)
+ .maybeWithArtifact(ValidatedAndroidResources::getAapt2RTxt)
+ .maybeWithArtifact(ValidatedAndroidResources::getSymbols)
.build();
private Artifact classJarOut;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidData.java b/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidData.java
deleted file mode 100644
index 81a5579fed..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidData.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2018 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.lib.rules.android;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
-import com.google.devtools.build.lib.packages.RuleErrorConsumer;
-import com.google.devtools.build.lib.skylarkbuildapi.android.ValidatedAndroidDataApi;
-
-/**
- * A {@link CompiledMergableAndroidData} that has been fully processed, validated, and packaged.
- *
- * <p>It contains resources and, depending on implementation, possibly assets and manifest.
- *
- * <p>TODO(b/76418178): Once resources and assets are completely decoupled and {@link
- * ResourceContainer} is removed, this interface can be replaced with {@link
- * ValidatedAndroidResources}
- */
-public interface ValidatedAndroidData extends CompiledMergableAndroidData, ValidatedAndroidDataApi {
-
- Artifact getRTxt();
-
- Artifact getAapt2RTxt();
-
- Artifact getStaticLibrary();
-
- ValidatedAndroidData filter(
- RuleErrorConsumer errorConsumer, ResourceFilter resourceFilter, boolean isDependency)
- throws RuleErrorException;
-
- Artifact getJavaClassJar();
-
- String getJavaPackage();
-
- Artifact getJavaSourceJar();
-
- @VisibleForTesting
- Artifact getApk();
-
- /**
- * Gets an Artifact containing a zip of merged resources.
- *
- * <p>If assets were processed together with resources, the zip will also contain merged assets.
- *
- * @deprecated This artifact is produced by an often-expensive action and should not be used if
- * another option is available. Furthermore, it will be replaced by flat files once we
- * completely move to aapt2.
- */
- @Deprecated
- Artifact getMergedResources();
-
- ProcessedAndroidManifest getProcessedManifest();
-
- /** Exports an immutable version of this data. */
- default ValidatedAndroidData export() {
- return this;
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java b/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java
index 231221e912..77456e74fb 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java
@@ -17,13 +17,14 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
import com.google.devtools.build.lib.packages.RuleErrorConsumer;
import com.google.devtools.build.lib.rules.android.AndroidConfiguration.AndroidAaptVersion;
+import com.google.devtools.build.lib.skylarkbuildapi.android.ValidatedAndroidDataApi;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Nullable;
/** Wraps validated and packaged Android resource information */
-public class ValidatedAndroidResources extends MergedAndroidResources
- implements ValidatedAndroidData {
+public class ValidatedAndroidResources extends MergedAndroidResources implements
+ ValidatedAndroidDataApi {
private final Artifact rTxt;
private final Artifact sourceJar;
private final Artifact apk;
@@ -118,22 +119,18 @@ public class ValidatedAndroidResources extends MergedAndroidResources
return getResourceDependencies().toInfo(this);
}
- @Override
public Artifact getRTxt() {
return rTxt;
}
- @Override
public Artifact getJavaSourceJar() {
return sourceJar;
}
- @Override
public Artifact getApk() {
return apk;
}
- @Override
@Nullable
public Artifact getAapt2RTxt() {
return aapt2RTxt;
@@ -144,13 +141,11 @@ public class ValidatedAndroidResources extends MergedAndroidResources
return aapt2SourceJar;
}
- @Override
@Nullable
public Artifact getStaticLibrary() {
return staticLibrary;
}
- @Override
public ValidatedAndroidResources filter(
RuleErrorConsumer errorConsumer, ResourceFilter resourceFilter, boolean isDependency)
throws RuleErrorException {
@@ -189,8 +184,7 @@ public class ValidatedAndroidResources extends MergedAndroidResources
super.hashCode(), rTxt, sourceJar, apk, aapt2RTxt, aapt2SourceJar, staticLibrary);
}
- @Override
- public ValidatedAndroidData export() {
+ public ValidatedAndroidResources export() {
return new ValidatedAndroidResources(
new MergedAndroidResources(
new ParsedAndroidResources(