variantConfig.setMultiFlavorSourceProvider(multiFlavorSourceSet);
// TODO: hmm this won't work
//variantProviders.add(new ConfigurationProviderImpl(project, multiFlavorSourceSet))
}
VariantDependencies variantDep = VariantDependencies.compute(
project, variantConfig.getFullName(),
isVariantPublished(),
variantFactory.isLibrary(),
variantProviders.toArray(new ConfigurationProvider[variantProviders.size()]));
variantData.setVariantDependency(variantDep);
localVariantDataList.add(variantData);
if (buildTypeData == testData) {
testedVariantData = variantData;
}
basePlugin.resolveDependencies(variantDep);
variantConfig.setDependencies(variantDep);
basePlugin.getVariantDataList().add(variantData);
variantFactory.createTasks(variantData, null);
// setup the task dependencies
// build type
buildTypeData.getAssembleTask().dependsOn(variantData.assembleVariantTask);
// each flavor
for (ProductFlavorData data : flavorDataList) {
data.getAssembleTask().dependsOn(variantData.assembleVariantTask);
}
// flavor combo
if (assembleTask != null) {
assembleTask.dependsOn(variantData.assembleVariantTask);
}
}
}
if (testedVariantData != null) {
VariantConfiguration testedConfig = testedVariantData.getVariantConfiguration();
// handle test variant
VariantConfiguration testVariantConfig = new VariantConfiguration(
defaultConfig,
defaultConfigData.getTestSourceSet(),
testData.getBuildType(),
null,
VariantConfiguration.Type.TEST,
testedVariantData.getVariantConfiguration(),
signingOverride);
/// add the container of dependencies
// the order of the libraries is important. In descending order:
// flavors, defaultConfig. No build type for tests
List<ConfigurationProvider> testVariantProviders = Lists.newArrayListWithExpectedSize(1 + flavorDataList.length);
for (ProductFlavorData data : flavorDataList) {
String dimensionName = "";
DefaultProductFlavor productFlavor = data.getProductFlavor();
if (productFlavor instanceof GroupableProductFlavorDsl) {
dimensionName = ((GroupableProductFlavorDsl) productFlavor).getFlavorDimension();
}
testVariantConfig.addProductFlavor(
productFlavor,
data.getTestSourceSet(),
dimensionName);
testVariantProviders.add(data.getTestProvider());
}
// now add the default config
testVariantProviders.add(basePlugin.getDefaultConfigData().getTestProvider());
// create the internal storage for this variant.
TestVariantData testVariantData = new TestVariantData(
basePlugin, testVariantConfig, (TestedVariantData) testedVariantData);
localVariantDataList.add(testVariantData);
// link the testVariant to the tested variant in the other direction
((TestedVariantData) testedVariantData).setTestVariantData(testVariantData);
if (testedConfig.getType() == VariantConfiguration.Type.LIBRARY) {
testVariantProviders.add(testedVariantData.getVariantDependency());
}
// dependencies for the test variant
VariantDependencies variantDep = VariantDependencies.compute(
project, testVariantData.getVariantConfiguration().getFullName(),
false /*publishVariant*/,
variantFactory.isLibrary(),
testVariantProviders.toArray(new ConfigurationProvider[testVariantProviders.size()]));
testVariantData.setVariantDependency(variantDep);