Skip to content

Commit

Permalink
增加开关控制
Browse files Browse the repository at this point in the history
  • Loading branch information
查郁 committed Sep 6, 2018
1 parent 380d52d commit e28c08b
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 5 deletions.
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 @@ -233,7 +233,7 @@ dependencies {
compile localGroovy()
compile gradleApi()

compile "com.taobao.android:dex_patch:3.0.0-rc11"
compile "com.taobao.android:dex_patch:3.0.0-rc12"
compile "com.android.tools.build:gradle:3.0.1"
compile "org.apache.commons:commons-lang3:3.4"
compile "commons-lang:commons-lang:2.6"
Expand All @@ -256,5 +256,5 @@ jar {
from zipTree("libs/libarsc.jar")
}

version = '3.0.1-rc77'
version = '3.0.1-rc77-SNAPSHOT'

Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ public class PatchConfig {
@Config(message = " Play andfix patch bag ", order = 1, advance = true, group = "atlas_patch")
private boolean createAPatch = false;

public boolean isNewPatch() {
return newPatch;
}

public void setNewPatch(boolean newPatch) {
this.newPatch = newPatch;
}

private boolean newPatch = true;

@Config(message = " Dynamic deployment patch bag ", order = 2, group = "atlas_patch")
private boolean createTPatch = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ private BaseInput createInput(ApkBO apkBO, ApkBO newApkBO, boolean retainMainBun
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)) {
Expand Down Expand Up @@ -547,6 +548,8 @@ public TPatchContext call() throws Exception {
",");

tPatchContext.buildId = tBuildType.getPatchConfig().getBuildId();

tPatchContext.newPatch = tBuildType.getPatchConfig().isNewPatch();
tPatchContext.writeBuildInfo = tBuildType.getPatchConfig()
.isTpatchWriteBuildInfo();
tPatchContext.diffBundleDex = tBuildType.getPatchConfig()
Expand Down Expand Up @@ -593,6 +596,8 @@ public static class TPatchContext implements Serializable {

public String buildId;

public boolean newPatch = true;

public boolean diffNativeSo;

public boolean writeBuildInfo;
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 @@ -35,5 +35,5 @@ dependencies {
group 'com.taobao.android'


version "3.0.0-rc11"
version "3.0.0-rc12"

Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,17 @@ public String getNoPatchDexNum() {
private static final String PATCH_VERSION = "PATCH_VRESION";


public boolean isNewPatch() {
return newPatch;
}

public void setNewPatch(boolean newPatch) {
this.newPatch = newPatch;
}

private boolean newPatch = true;


private Map<String, org.jf.dexlib2.iface.ClassDef>lastBundleClassMap = new HashMap<String, org.jf.dexlib2.iface.ClassDef>();
private DexDiffInfo dexDiffInfo = new DexDiffInfo();

Expand Down Expand Up @@ -580,7 +591,7 @@ public DexDiffInfo doDiff() throws IOException, PatchException {
diffClasses.add(new DiffClass(NO_PATCH_DEX,Integer.valueOf(noPatchDexNum)));
}

diffClasses.add(new DiffClass(PATCH_VERSION,2));
diffClasses.add(new DiffClass(PATCH_VERSION,newPatch ? 2:1));
return dexDiffInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class TpatchInput extends BaseInput {

public File bundleWhiteList;

public boolean newPatch = true;

//dexpatch name:com.taobao.maindex
public String mainBundleName = "libcom_taobao_maindex";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public List<File> createBundleDexPatch(File newApkUnzipFolder,
DEFAULT_API_LEVEL,
null,
mainDex);
dexTool.setNewPatch(((DexPatchInput)input).newPatch);
dexTool.setExculdeClasses(((DexPatchInput)input).excludeClasses);
dexTool.setPatchClasses(((DexPatchInput)input).patchClasses);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.taobao.android.differ.dex.BundleDiffResult;
import com.taobao.android.inputs.HotPatchInput;
import com.taobao.android.inputs.TpatchInput;
import com.taobao.android.object.DexDiffInfo;
import org.apache.commons.io.FileUtils;

Expand Down Expand Up @@ -53,6 +54,7 @@ public List<File> createBundleDexPatch(File newApkUnzipFolder,
DEFAULT_API_LEVEL,
null,
mainDex);
dexTool.setNewPatch(((HotPatchInput)input).newPatch);
dexTool.setExculdeClasses(((HotPatchInput)input).excludeClasses);
dexTool.setPatchClassList(hotClassList);
DexDiffInfo dexDiffInfo = dexTool.createPatchDex(destDexFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public void setTPatch(boolean tpatch) {

private boolean tpatch;

public boolean isNewPatch() {
return newPatch;
}

public void setNewPatch(boolean newPatch) {
this.newPatch = newPatch;
}

private boolean newPatch = true;

public PatchDexTool(List<File> baseDexFiles, List<File> newDexFiles, int apiLevel, Map<String,ClassDef> map,boolean mainBundle) {
this.baseDexFiles = baseDexFiles;
this.newDexFiles = newDexFiles;
Expand All @@ -57,6 +67,7 @@ public PatchDexTool(List<File> baseDexFiles, List<File> newDexFiles, int apiLeve
assert (null != baseDexFiles && baseDexFiles.size() > 0);
assert (null != newDexFiles && newDexFiles.size() > 0);
this.dexDiffer = new DexDiffer(baseDexFiles, newDexFiles, apiLevel);
dexDiffer.setNewPatch(newPatch);
if (map == null) {
dexDiffer.setLastBundleClassMap(lastBundleClassMap);
}else {
Expand All @@ -73,7 +84,8 @@ public PatchDexTool(File baseDex, File newDex, int apiLevel,boolean mainBundle)
newDexFiles.add(newDex);
this.mainBundle = mainBundle;
this.dexDiffer = new DexDiffer(baseDex, newDex, apiLevel);
dexDiffer.setLastBundleClassMap(lastBundleClassMap);
dexDiffer.setNewPatch(newPatch);
dexDiffer.setLastBundleClassMap(lastBundleClassMap);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ public List<File> createBundleDexPatch(File newApkUnzipFolder,
DEFAULT_API_LEVEL,
bundleClassMap.get(diffDexFolder.getName()),
mainDex);
dexTool.setNewPatch(((TpatchInput)input).newPatch);
DexDiffInfo dexDiffInfo = dexTool.createPatchDex(diffDexFolder);
if (diffDexFolder.listFiles()!= null && diffDexFolder.listFiles().length > 0) {
dexs.addAll(FileUtils.listFiles(diffDexFolder,new String[]{"dex"},true));
Expand Down

0 comments on commit e28c08b

Please sign in to comment.