aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar ajmichael <ajmichael@google.com>2017-08-29 00:41:40 +0200
committerGravatar Vladimir Moskva <vladmos@google.com>2017-08-29 13:33:04 +0200
commit69ef625b464093aaefd3d8af9e947832d4385211 (patch)
treecbc8f4c3a8cfce9adc0f89e9269720076a5e7921 /src/test/java/com/google/devtools
parenta4c0e1a84029b2bad2310f7259ba6757fe706ac2 (diff)
aar_import creates res/values/empty.xml if it contains no resources.
To do this, add a new tool that is used instead of zipper to get the resources out of the AAR. This tool creates res/values/empty.xml if there are no resources in the AAR. Also, some general cleaning of the code. RELNOTES: None PiperOrigin-RevId: 166768607
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java27
2 files changed, 28 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java
index bd6ce313a4..f3525b3e4c 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java
@@ -247,7 +247,7 @@ public final class BazelAnalysisMock extends AnalysisMock {
.add("java_binary(name = 'IdlClass',")
.add(" runtime_deps = [ ':idlclass_import' ],")
.add(" main_class = 'com.google.devtools.build.android.idlclass.IdlClass')")
- .add("sh_binary(name = 'zip_manifest_creator', srcs = ['empty.sh'])")
+ .add("sh_binary(name = 'aar_resources_extractor', srcs = ['empty.sh'])")
.add("sh_binary(name = 'aar_embedded_jars_extractor', srcs = ['empty.sh'])")
.add("java_import(name = 'idlclass_import',")
.add(" jars = [ 'idlclass.jar' ])")
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java
index 245698d347..bb52347a22 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.rules.android;
+import static com.google.common.collect.Streams.stream;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Predicates;
@@ -21,6 +22,7 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.FileConfiguredTarget;
+import com.google.devtools.build.lib.analysis.FilesToRunProvider;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
@@ -86,6 +88,31 @@ public class AarImportTest extends BuildViewTestCase {
}
@Test
+ public void testResourcesExtractor() throws Exception {
+ AndroidResourcesProvider resourcesProvider =
+ getConfiguredTarget("//a:foo").getProvider(AndroidResourcesProvider.class);
+
+ Artifact resourceTreeArtifact =
+ stream(resourcesProvider.getDirectAndroidResources())
+ .flatMap(resourceContainer -> resourceContainer.getResources().stream())
+ .findFirst()
+ .get();
+ Artifact aarResourcesExtractor =
+ getHostConfiguredTarget(
+ ruleClassProvider.getToolsRepository() + "//tools/android:aar_resources_extractor")
+ .getProvider(FilesToRunProvider.class)
+ .getExecutable();
+
+ assertThat(getGeneratingSpawnAction(resourceTreeArtifact).getArguments())
+ .containsExactly(
+ aarResourcesExtractor.getExecPathString(),
+ "--input_aar",
+ "a/foo.aar",
+ "--output_res_dir",
+ resourceTreeArtifact.getExecPathString());
+ }
+
+ @Test
public void testNativeLibsProvided() throws Exception {
ConfiguredTarget androidLibraryTarget = getConfiguredTarget("//java:lib");