use of com.taobao.android.builder.dependency.diff.DependencyDiff in project atlas by alibaba.
the class AppVariantContext method getDependencyDiff.
public DependencyDiff getDependencyDiff() throws IOException {
if (null != this.dependencyDiff) {
return this.dependencyDiff;
}
if (null != this.apContext.getApExploredFolder() && this.apContext.getApExploredFolder().exists()) {
DependencyJson dependencyJson = AtlasBuildContext.androidDependencyTrees.get(this.getVariantData().getName()).getDependencyJson();
File baseDependencyFile = new File(this.apContext.getApExploredFolder(), "dependencies.txt");
if (baseDependencyFile.exists()) {
DependencyDiff dependencyDiff = DependencyCompareUtils.diff(baseDependencyFile, dependencyJson);
this.dependencyDiff = dependencyDiff;
return dependencyDiff;
}
}
return null;
}
use of com.taobao.android.builder.dependency.diff.DependencyDiff in project atlas by alibaba.
the class ApkInjectInfoCreator method creteInjectParam.
public InjectParam creteInjectParam(AppVariantContext appVariantContext) throws Exception {
InjectParam injectParam = new InjectParam();
injectParam.removePreverify = !appVariantContext.getAtlasExtension().getTBuildConfig().getDoPreverify();
injectParam.version = appVariantContext.getVariantConfiguration().getVersionName();
AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(appVariantContext.getScope().getVariantConfiguration().getFullName());
List<BasicBundleInfo> basicBundleInfos = new ArrayList<BasicBundleInfo>();
Map<String, BasicBundleInfo> basicBundleInfoMap = new HashMap<>();
List<String> mainDexDependencies = atlasDependencyTree.getMainBundle().getAllDependencies();
Collections.sort(mainDexDependencies, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.compareTo(o2);
}
});
String mainMd532 = MD5Util.getMD5(StringUtils.join(mainDexDependencies));
String md5base36 = new BigInteger(mainMd532.substring(8, 24), 16).toString(36);
injectParam.unit_tag = md5base36;
appVariantContext.unit_tag = md5base36;
// Depends on whether the change is sent
DependencyDiff dependencyDiff = appVariantContext.getDependencyDiff();
Map<String, String> baseTagMap = appVariantContext.getBaseUnitTagMap();
for (AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
// if (awbBundle.isMBundle){
// continue;
// }
BundleInfo bundleInfo = awbBundle.bundleInfo;
BasicBundleInfo basicBundleInfo = new BasicBundleInfo();
basicBundleInfo.setApplicationName(bundleInfo.getApplicationName());
basicBundleInfo.setVersion(bundleInfo.getVersion());
basicBundleInfo.setPkgName(bundleInfo.getPkgName());
// set unique_tag
String bundleDependencyMd532 = MD5Util.getMD5(StringUtils.join(awbBundle.getAllDependencies()));
String bundleUnitTag = "";
if (null != dependencyDiff && !dependencyDiff.isDiffBundle(awbBundle)) {
bundleUnitTag = baseTagMap.get(awbBundle.getPackageName());
}
if (StringUtils.isEmpty(bundleUnitTag)) {
String bundleMd532 = MD5Util.getMD5(mainMd532 + bundleDependencyMd532);
bundleUnitTag = new BigInteger(bundleMd532.substring(8, 24), 16).toString(36);
}
basicBundleInfo.setUnique_tag(bundleUnitTag);
bundleInfo.setUnique_tag(bundleUnitTag);
if (!bundleInfo.getIsInternal()) {
basicBundleInfo.setIsInternal(false);
}
if (awbBundle.isMBundle) {
basicBundleInfo.setIsMBundle(true);
}
if (!bundleInfo.getActivities().isEmpty()) {
basicBundleInfo.setActivities(bundleInfo.getActivities());
}
if (!bundleInfo.getContentProviders().isEmpty()) {
basicBundleInfo.setContentProviders(bundleInfo.getContentProviders());
}
if (!bundleInfo.getDependency().isEmpty()) {
basicBundleInfo.setDependency(bundleInfo.getDependency());
}
if (!bundleInfo.getReceivers().isEmpty()) {
basicBundleInfo.setReceivers(bundleInfo.getReceivers());
}
if (!bundleInfo.getServices().isEmpty()) {
basicBundleInfo.setServices(bundleInfo.getServices());
}
if (!bundleInfo.getRemoteFragments().isEmpty()) {
basicBundleInfo.setRemoteFragments(bundleInfo.getRemoteFragments());
}
if (!bundleInfo.getRemoteViews().isEmpty()) {
basicBundleInfo.setRemoteViews(bundleInfo.getRemoteViews());
}
if (!bundleInfo.getRemoteTransactors().isEmpty()) {
basicBundleInfo.setRemoteTransactors(bundleInfo.getRemoteTransactors());
}
basicBundleInfos.add(basicBundleInfo);
basicBundleInfoMap.put(bundleInfo.getPkgName(), basicBundleInfo);
}
// Collections.sort(basicBundleInfos, (o1, o2) -> {
// if (o1.getDependency().contains(o2.getPkgName())){
// return -1;
// }else {
// return 1;
// }
// });
basicBundleInfos.forEach(basicBundleInfo -> checkDependency(basicBundleInfo, atlasDependencyTree.getAwbBundles()));
injectParam.bundleInfo = JSON.toJSONString(basicBundleInfos);
// FIXME MOVE TO MTL-PLUGIN
// List<String> autoStartBundles = new ArrayList<String>(appVariantContext.getAtlasExtension().getTBuildConfig
// ().getAutoStartBundles());
//
// UpdateConfig updateConfig = appVariantContext.getAtlasExtension().getUpdateConfig();
// if (updateConfig.enabled) {
// injectParam.group = updateConfig.getProductName();
// injectParam.outApp = updateConfig.isOutApp();
// autoStartBundles.add(0, updateConfig.getSdkPkgName());
// }
//
injectParam.group = appVariantContext.getAtlasExtension().getTBuildConfig().getGroup();
injectParam.autoStartBundles = StringUtils.join(appVariantContext.getAtlasExtension().getTBuildConfig().getAutoStartBundles(), ",");
injectParam.preLaunch = appVariantContext.getAtlasExtension().getTBuildConfig().getPreLaunch();
mergeBundleInfos(appVariantContext, injectParam, basicBundleInfos, basicBundleInfoMap);
return injectParam;
}
Aggregations