Skip to content

Commit

Permalink
[atlas-graddle-plugin] concurrent for tpatch bundle task
Browse files Browse the repository at this point in the history
  • Loading branch information
jiawulu committed Jun 21, 2017
1 parent 6aa2489 commit 3078dfc
Show file tree
Hide file tree
Showing 10 changed files with 948 additions and 392 deletions.
20 changes: 10 additions & 10 deletions atlas-demo/AtlasDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ android {
}
}

// productFlavors {
// dev {
// minSdkVersion 14
// }
//
// beta {
// minSdkVersion 21
// }
// }
productFlavors {
dev {
minSdkVersion 14
}

beta {
minSdkVersion 21
}
}
}

atlas {
Expand Down Expand Up @@ -101,7 +101,7 @@ dependencies {
bundleCompile project(':secondbundle')
bundleCompile project(':remotebundle')
bundleCompile project(':publicbundle')
bundleCompile project(':databindbundle')
//bundleCompile project(':databindbundle')

compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
Expand Down
4 changes: 2 additions & 2 deletions atlas-gradle-plugin/atlas-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ dependencies {

compile "com.taobao.android:aapt:2.3.1.rc2"

compile "com.taobao.android:dex_patch:1.4.0.9-rc16"
compile "com.taobao.android:dex_patch:1.4.0.9-rc16-SNAPSHOT"

testCompile "junit:junit:4.11"
}

version = '2.3.3.beta1'
version = '2.3.3.beta1.fast_tpatch-SNAPSHOT'
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.zip.ZipEntry;

Expand All @@ -221,6 +220,8 @@
import com.android.build.gradle.internal.variant.BaseVariantOutputData;
import com.taobao.android.builder.extension.PatchConfig;
import com.taobao.android.builder.tasks.manager.MtlBaseTaskAction;
import com.taobao.android.builder.tools.Profiler;
import com.taobao.android.builder.tools.zip.BetterZip;
import com.taobao.android.builder.tools.zip.ZipUtils;
import org.apache.commons.io.FileUtils;
import org.gradle.api.tasks.InputFile;
Expand All @@ -243,6 +244,9 @@ public void doApkBuild() throws Exception {
apkFile = getApkFile();
diffAPkFile = getDiffAPkFile();

Profiler.start("build tpatch apk");

Profiler.enter("prepare dir");
File tmpWorkDir = new File(diffAPkFile.getParentFile(), "tmp-apk");
if (tmpWorkDir.exists()) {
FileUtils.deleteDirectory(tmpWorkDir);
Expand All @@ -251,8 +255,10 @@ public void doApkBuild() throws Exception {
tmpWorkDir.mkdirs();
}

Map zipEntityMap = new HashMap();
ZipUtils.unzip(apkFile, tmpWorkDir.getAbsolutePath(), "UTF-8", zipEntityMap, true);
BetterZip.unzipDirectory(apkFile,tmpWorkDir);

//Map zipEntityMap = new HashMap();
//ZipUtils.unzip(apkFile, tmpWorkDir.getAbsolutePath(), "UTF-8", zipEntityMap, true);

FileUtils.deleteDirectory(new File(tmpWorkDir, "assets"));
FileUtils.deleteDirectory(new File(tmpWorkDir, "res"));
Expand All @@ -264,12 +270,20 @@ public void doApkBuild() throws Exception {
ZipUtils.unzip(getResourceFile(), resdir.getAbsolutePath(), "UTF-8", new HashMap<String, ZipEntry>(), true);

FileUtils.copyDirectory(resdir, tmpWorkDir);
ZipUtils.rezip(diffAPkFile, tmpWorkDir, zipEntityMap);

Profiler.release();

Profiler.enter("rezip");

BetterZip.zipDirectory(tmpWorkDir,diffAPkFile);

//ZipUtils.rezip(diffAPkFile, tmpWorkDir, zipEntityMap);
Profiler.release();

FileUtils.deleteDirectory(tmpWorkDir);
FileUtils.deleteDirectory(resdir);


getLogger().warn(Profiler.dump());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ public void doTPatch() throws Exception {
TPatchTool tPatchTool = new TPatchTool(apkBO,
newApkBO,
patchContext.diffBundleDex);
//TODO
//tPatchTool.setVersionList();

List<Pair<BundleBO, BundleBO>> remoteBundles = new ArrayList<>();

Expand Down
2 changes: 1 addition & 1 deletion atlas-gradle-plugin/dexpatch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ dependencies {

group 'com.taobao.android'

version "1.4.0.9-rc16"
version "1.4.0.9-rc16-SNAPSHOT"
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@
*/
package com.taobao.android;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Set;

import com.android.utils.ILogger;
import com.android.utils.Pair;
import com.google.common.collect.Lists;
Expand All @@ -221,15 +230,6 @@
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Set;

/**
* Created by shenghua.nish on 2016-03-19 下午9:51.
*/
Expand Down Expand Up @@ -295,24 +295,36 @@ public void setOnlyIncludeModifyBundle(boolean onlyIncludeModifyBundle) {
* @return
*/
public boolean isModifyBundle(String bundleSoFileName) {

DiffType diffType = getModifyType(bundleSoFileName);

if (diffType == DiffType.NONE){
return false;
}

return DiffType.ADD.equals(diffType) || DiffType.MODIFY.equals(diffType);

}


public DiffType getModifyType(String bundleSoFileName) {
for (ArtifactBundleInfo artifactBundleInfo : artifactBundleInfos) {
String packageName = artifactBundleInfo.getPkgName();
if (null == packageName) {
return false;
return DiffType.NONE;
}
String bundleName = "lib" + packageName.replace('.', '_') + ".so";
if (bundleName.equals(bundleSoFileName)) {
if (null != logger) {
logger.info("[BundleDiffType]" + bundleSoFileName + ":" + artifactBundleInfo.getDiffType());
}
if (DiffType.ADD.equals(artifactBundleInfo.getDiffType()) || DiffType.MODIFY.equals(artifactBundleInfo.getDiffType())) {
return true;
}
return artifactBundleInfo.getDiffType();
}
}
return false;
return DiffType.NONE;
}


public String getBundleName(String bundleSoFileName) {
return FilenameUtils.getBaseName(bundleSoFileName.replace("lib", ""));
}
Expand Down
Loading

0 comments on commit 3078dfc

Please sign in to comment.