/** Builds a map of module dependencies. */ private static ImmutableMultimap<String, String> buildAdjacencyMap(Variant variant) { ImmutableMultimap.Builder<String, String> moduleDependenciesMap = ImmutableMultimap.builder(); variant .getApkSetList() .stream() .map(ApkSet::getModuleMetadata) .forEach( moduleMetadata -> { moduleDependenciesMap.putAll( moduleMetadata.getName(), moduleMetadata.getDependenciesList()); moduleDependenciesMap.put(moduleMetadata.getName(), "base"); }); return moduleDependenciesMap.build(); }
assertThat(baseSplits.getModuleMetadata().getDependenciesList()).isEmpty(); assertThat(feature1Splits.getModuleMetadata().getDependenciesList()).isEmpty(); assertThat(feature2Splits.getModuleMetadata().getDependenciesList()) .containsExactly("feature1"); assertThat(feature3Splits.getModuleMetadata().getDependenciesList()) .containsExactly("feature1", "feature2"); List<ApkSet> apkSetList = standaloneApkVariants(result).get(0).getApkSetList(); assertThat(apkSetList).hasSize(1); assertThat(apkSetList.get(0).getModuleMetadata().getDependenciesList()).isEmpty();
@Test public void getModuleMetadata_dependencies_parsedAndReturned() throws Exception { BundleModule bundleModule = createMinimalModuleBuilder() .setAndroidManifestProto( androidManifest("com.test.app", withUsesSplit("feature1", "feature2"))) .build(); assertThat(bundleModule.getModuleMetadata().getDependenciesList()) .containsExactly("feature1", "feature2"); }