use of com.taobao.android.inputs.DexPatchInput in project atlas by alibaba.
the class TPatchTask method createInput.
private BaseInput createInput(ApkBO apkBO, ApkBO newApkBO, boolean retainMainBundleRes) throws IOException {
TpatchInput tpatchInput = null;
if (getProject().hasProperty("hotfix")) {
tpatchInput = new HotPatchInput();
} else {
tpatchInput = new DexPatchInput();
}
tpatchInput.baseApkBo = apkBO;
tpatchInput.newApkBo = newApkBO;
tpatchInput.baseApkFileList = patchContext.getBaseApkFiles();
tpatchInput.newApkFileList = patchContext.getNewApkFiles(appVariantContext);
tpatchInput.outPatchDir = outPatchFolder;
tpatchInput.productName = patchContext.appSignName;
tpatchInput.outPutJson = new File(getOutPatchFolder(), "patchs.json");
tpatchInput.artifactBundleInfos = patchContext.artifactBundleInfos;
tpatchInput.diffBundleDex = true;
tpatchInput.newPatch = patchContext.newPatch;
tpatchInput.mainBundleName = patchContext.mainBundleName;
tpatchInput.retainMainBundleRes = retainMainBundleRes;
if (StringUtils.isNotBlank(patchContext.excludeFiles)) {
tpatchInput.notIncludeFiles = (patchContext.excludeFiles.split(","));
}
if (apkBO.getVersionName().equals(newApkBO.getVersionName())) {
if (tpatchInput instanceof HotPatchInput) {
((HotPatchInput) tpatchInput).hotClassListFile = patchContext.hotClassListFile;
((HotPatchInput) tpatchInput).patchType = PatchType.HOTFIX;
((HotPatchInput) tpatchInput).excludeClasses = patchContext.excludeClasses;
} else {
tpatchInput.patchType = PatchType.DEXPATCH;
((DexPatchInput) tpatchInput).patchClasses = patchContext.patchClasses;
((DexPatchInput) tpatchInput).excludeClasses = patchContext.excludeClasses;
}
tpatchInput.mainBundleName = "com.taobao.maindex";
} else {
tpatchInput.patchType = PatchType.TPATCH;
tpatchInput.createHisPatch = true;
tpatchInput.diffNativeSo = patchContext.diffNativeSo;
tpatchInput.diffBundleSo = patchContext.diffBundleSo;
tpatchInput.bundleWhiteList = appVariantContext.bundleListCfg;
tpatchInput.createAll = StringUtils.isEmpty(patchContext.tpatchHistoryUrl);
tpatchInput.LAST_PATCH_URL = patchContext.LAST_PATCH_URL;
tpatchInput.hisPatchUrl = patchContext.tpatchHistoryUrl;
if (null != patchContext.patchVersions) {
tpatchInput.versionList = patchContext.patchVersions;
}
}
List<Pair<BundleBO, BundleBO>> remoteBundles = new ArrayList<>();
// Get the remote bundle
for (AwbBundle awbBundle : AtlasBuildContext.awbBundleMap.values()) {
if (awbBundle.isRemote) {
File bundleFile = awbBundle.outputBundleFile;
getProject().getLogger().error("add bundle compare " + bundleFile.getAbsolutePath());
BundleBO newBundleBO = new BundleBO(awbBundle.getResolvedCoordinates().getArtifactId(), bundleFile, "");
File baseBundleFile = new File(patchContext.apExplodeFolder, "remotebundles/" + bundleFile.getName());
getProject().getLogger().error("add bundle compare base : " + baseBundleFile.getAbsolutePath());
BundleBO baseBundleBO = null;
if (baseBundleFile.exists()) {
getProject().getLogger().error("add bundle compare " + baseBundleFile.getAbsolutePath() + "->" + bundleFile.getAbsolutePath());
baseBundleBO = new BundleBO(awbBundle.getResolvedCoordinates().getArtifactId(), baseBundleFile, "");
}
remoteBundles.add(Pair.of(baseBundleBO, newBundleBO));
}
}
if (remoteBundles.size() > 0) {
tpatchInput.splitDiffBundle = remoteBundles;
}
return tpatchInput;
}
Aggregations