Search in sources :

Example 1 with ResourceContainer

use of com.google.devtools.build.lib.rules.android.ResourceContainer in project bazel by bazelbuild.

the class AarImportTest method testNoCustomJavaPackage.

@Test
public void testNoCustomJavaPackage() throws Exception {
    ResourceContainer resourceContainer = getConfiguredTarget("//a:foo").getProvider(AndroidResourcesProvider.class).getDirectAndroidResources().iterator().next();
    // aar_import should not set a custom java package. Instead aapt will read the
    // java package from the manifest.
    assertThat(resourceContainer.getJavaPackage()).isNull();
}
Also used : AndroidResourcesProvider(com.google.devtools.build.lib.rules.android.AndroidResourcesProvider) ResourceContainer(com.google.devtools.build.lib.rules.android.ResourceContainer) Test(org.junit.Test)

Example 2 with ResourceContainer

use of com.google.devtools.build.lib.rules.android.ResourceContainer in project bazel by bazelbuild.

the class AarImportTest method testResourcesProvided.

@Test
public void testResourcesProvided() throws Exception {
    ConfiguredTarget aarImportTarget = getConfiguredTarget("//a:foo");
    NestedSet<ResourceContainer> directResources = aarImportTarget.getProvider(AndroidResourcesProvider.class).getDirectAndroidResources();
    assertThat(directResources).hasSize(1);
    ResourceContainer resourceContainer = directResources.iterator().next();
    assertThat(resourceContainer.getManifest()).isNotNull();
    Iterable<Artifact> resourceArtifacts = resourceContainer.getArtifacts();
    assertThat(resourceArtifacts).hasSize(1);
    Artifact resourceTreeArtifact = resourceArtifacts.iterator().next();
    assertThat(resourceTreeArtifact.isTreeArtifact()).isTrue();
    assertThat(resourceTreeArtifact.getExecPathString()).endsWith("_aar/unzipped/resources/foo");
}
Also used : AndroidResourcesProvider(com.google.devtools.build.lib.rules.android.AndroidResourcesProvider) ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) FileConfiguredTarget(com.google.devtools.build.lib.analysis.FileConfiguredTarget) Artifact(com.google.devtools.build.lib.actions.Artifact) ResourceContainer(com.google.devtools.build.lib.rules.android.ResourceContainer) Test(org.junit.Test)

Aggregations

AndroidResourcesProvider (com.google.devtools.build.lib.rules.android.AndroidResourcesProvider)2 ResourceContainer (com.google.devtools.build.lib.rules.android.ResourceContainer)2 Test (org.junit.Test)2 Artifact (com.google.devtools.build.lib.actions.Artifact)1 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)1 FileConfiguredTarget (com.google.devtools.build.lib.analysis.FileConfiguredTarget)1