use of com.android.apkzlib.zip.compress.Zip64NotSupportedException in project atlas by alibaba.
the class AwbApkPackageTask method splitIncrementalAction.
private File splitIncrementalAction(ApkData apkData, @Nullable File processedResources, Map<File, FileStatus> changedInputs) throws IOException {
Set<File> androidResources = getAndroidResources(apkData, processedResources);
File incrementalDirForSplit = new File(getIncrementalFolder(awbBundle), apkData.getFullName());
File cacheByPathDir = new File(incrementalDirForSplit, ZIP_DIFF_CACHE_DIR);
if (!cacheByPathDir.exists()) {
FileUtils.mkdirs(cacheByPathDir);
}
FileCacheByPath cacheByPath = new FileCacheByPath(cacheByPathDir);
KnownFilesSaveData saveData = KnownFilesSaveData.make(incrementalDirForSplit);
final Set<File> assetsFiles = assets.getFiles();
Set<Runnable> cacheUpdates = new HashSet<>();
ImmutableMap<RelativeFile, FileStatus> changedDexFiles = KnownFilesSaveData.getChangedInputs(changedInputs, saveData, KnownFilesSaveData.InputSet.DEX, dexFolders.getFiles(), cacheByPath, cacheUpdates);
ImmutableMap<RelativeFile, FileStatus> changedJavaResources;
try {
changedJavaResources = KnownFilesSaveData.getChangedInputs(changedInputs, saveData, KnownFilesSaveData.InputSet.JAVA_RESOURCE, javaResouresFiles.getFiles(), cacheByPath, cacheUpdates);
} catch (Zip64NotSupportedException e) {
// copy all changedInputs into a smaller jar and rerun.
ImmutableMap.Builder<File, FileStatus> copiedInputs = ImmutableMap.builder();
for (Map.Entry<File, FileStatus> fileFileStatusEntry : changedInputs.entrySet()) {
copiedInputs.put(copyJavaResourcesOnly(getIncrementalFolder(awbBundle), fileFileStatusEntry.getKey()), fileFileStatusEntry.getValue());
}
changedJavaResources = KnownFilesSaveData.getChangedInputs(copiedInputs.build(), saveData, KnownFilesSaveData.InputSet.JAVA_RESOURCE, javaResouresFiles.getFiles(), cacheByPath, cacheUpdates);
}
ImmutableMap<RelativeFile, FileStatus> changedAssets = KnownFilesSaveData.getChangedInputs(changedInputs, saveData, KnownFilesSaveData.InputSet.ASSET, assetsFiles, cacheByPath, cacheUpdates);
ImmutableMap<RelativeFile, FileStatus> changedAndroidResources = KnownFilesSaveData.getChangedInputs(changedInputs, saveData, KnownFilesSaveData.InputSet.ANDROID_RESOURCE, androidResources, cacheByPath, cacheUpdates);
ImmutableMap<RelativeFile, FileStatus> changedNLibs = KnownFilesSaveData.getChangedInputs(changedInputs, saveData, KnownFilesSaveData.InputSet.NATIVE_RESOURCE, jniFolders.getFiles(), cacheByPath, cacheUpdates);
File outputFile = getOutputFile(awbBundle);
Collection<BuildOutput> manifestOutputs = BuildOutputs.load(TaskOutputHolder.TaskOutputType.MERGED_MANIFESTS, awbManifestFolder.getSingleFile().getParentFile());
doTask(apkData, incrementalDirForSplit, outputFile, cacheByPath, manifestOutputs, changedDexFiles, changedJavaResources, changedAssets, changedAndroidResources, changedNLibs);
/*
* Update the cache
*/
cacheUpdates.forEach(Runnable::run);
/*
* Update the save data keep files.
*/
ImmutableMap<RelativeFile, FileStatus> allDex = IncrementalRelativeFileSets.fromZipsAndDirectories(dexFolders);
ImmutableMap<RelativeFile, FileStatus> allJavaResources = IncrementalRelativeFileSets.fromZipsAndDirectories(javaResouresFiles);
ImmutableMap<RelativeFile, FileStatus> allAssets = IncrementalRelativeFileSets.fromZipsAndDirectories(assetsFiles);
ImmutableMap<RelativeFile, FileStatus> allAndroidResources = IncrementalRelativeFileSets.fromZipsAndDirectories(androidResources);
ImmutableMap<RelativeFile, FileStatus> allJniResources = IncrementalRelativeFileSets.fromZipsAndDirectories(jniFolders);
saveData.setInputSet(allDex.keySet(), KnownFilesSaveData.InputSet.DEX);
saveData.setInputSet(allJavaResources.keySet(), KnownFilesSaveData.InputSet.JAVA_RESOURCE);
saveData.setInputSet(allAssets.keySet(), KnownFilesSaveData.InputSet.ASSET);
saveData.setInputSet(allAndroidResources.keySet(), KnownFilesSaveData.InputSet.ANDROID_RESOURCE);
saveData.setInputSet(allJniResources.keySet(), KnownFilesSaveData.InputSet.NATIVE_RESOURCE);
saveData.saveCurrentData();
return outputFile;
}
Aggregations