use of com.android.builder.model.TestedTargetVariant in project android by JetBrains.
the class GradleApkProvider method getTargetedApks.
/**
* Gets the list of targeted apks for the specified variant.
*
* <p>This is used for test-only modules when specifying the tested apk
* using the targetProjectPath and targetVariant properties in the build file.
*/
@NotNull
private List<ApkInfo> getTargetedApks(@NotNull Variant selectedVariant, @NotNull IDevice device) throws ApkProvisionException {
List<ApkInfo> targetedApks = Lists.newArrayList();
for (TestedTargetVariant testedVariant : getTestedTargetVariants(selectedVariant)) {
Module targetModule = ApplicationManager.getApplication().runReadAction((Computable<Module>) () -> GradleUtil.findModuleByGradlePath(myFacet.getModule().getProject(), testedVariant.getTargetProjectPath()));
// target module has to exist, otherwise we would not be able to build test apk
assert targetModule != null;
AndroidFacet targetFacet = AndroidFacet.getInstance(targetModule);
if (targetFacet == null) {
LOG.warn("Please install tested apk manually.");
continue;
}
AndroidModuleModel targetAndroidModel = AndroidModuleModel.get(targetFacet);
if (targetAndroidModel == null) {
LOG.warn("Android model for tested module is null. Sync might have failed.");
continue;
}
Variant targetVariant = targetAndroidModel.findVariantByName(testedVariant.getTargetVariant());
if (targetVariant == null) {
LOG.warn("Tested variant not found. Sync might have failed.");
continue;
}
File targetApk = getApk(targetVariant, device);
targetedApks.add(new ApkInfo(targetApk, targetVariant.getMergedFlavor().getApplicationId()));
}
return targetedApks;
}
Aggregations