use of com.android.ide.common.process.ProcessOutputHandler in project atlas by alibaba.
the class TPatchDiffResAPBuildTask method makeAapt.
private Aapt makeAapt(AaptGeneration aaptGeneration) throws IOException {
AndroidBuilder builder = getBuilder();
MergingLog mergingLog = new MergingLog(mergeBlameLogFolder);
ProcessOutputHandler processOutputHandler = new ParsingProcessOutputHandler(new ToolOutputParser(aaptGeneration == AaptGeneration.AAPT_V1 ? new AaptOutputParser() : new Aapt2OutputParser(), getILogger()), new MergingLogRewriter(mergingLog::find, builder.getErrorReporter()));
return AaptGradleFactory.make(aaptGeneration, builder, processOutputHandler, fileCache, true, com.android.utils.FileUtils.mkdirs(new File(appVariantContext.getScope().getIncrementalDir(getName()), "aapt-temp")), aaptOptions.getCruncherProcesses());
}
use of com.android.ide.common.process.ProcessOutputHandler in project atlas by alibaba.
the class AtlasDexArchiveBuilderTransform method convertToDexArchive.
private List<File> convertToDexArchive(@NonNull Context context, @NonNull QualifiedContent input, @NonNull TransformOutputProvider outputProvider, boolean isIncremental) throws Exception {
logger.verbose("Dexing {}", input.getFile().getAbsolutePath());
ImmutableList.Builder<File> dexArchives = ImmutableList.builder();
for (int bucketId = 0; bucketId < NUMBER_OF_BUCKETS; bucketId++) {
File preDexOutputFile = getPreDexFile(outputProvider, input, bucketId);
if (input.getFile().isDirectory()) {
File cachedVersion = cacheHandler.getCachedVersionIfPresent(input.getFile());
dexArchives.add(preDexOutputFile);
if (cachedVersion != null) {
FileUtils.copyDirectoryContentToDirectory(cachedVersion, preDexOutputFile);
return dexArchives.build();
}
}
if (preDexOutputFile.isDirectory() && preDexOutputFile.exists()) {
FileUtils.cleanOutputDir(preDexOutputFile);
} else {
FileUtils.deleteIfExists(preDexOutputFile);
}
AtlasDexArchiveBuilderTransform.DexConversionParameters parameters = new AtlasDexArchiveBuilderTransform.DexConversionParameters(input, preDexOutputFile, NUMBER_OF_BUCKETS, bucketId, minSdkVersion, dexOptions.getAdditionalParameters(), inBufferSize, outBufferSize, dexer, isDebuggable, isIncremental, false);
if (useGradleWorkers) {
context.getWorkerExecutor().submit(DexArchiveBuilderTransform.DexConversionWorkAction.class, configuration -> {
configuration.setIsolationMode(IsolationMode.NONE);
configuration.setParams(parameters);
});
} else {
executor.execute(() -> {
ProcessOutputHandler outputHandler = new ParsingProcessOutputHandler(new ToolOutputParser(new DexParser(), Message.Kind.ERROR, logger), new ToolOutputParser(new DexParser(), logger), errorReporter);
ProcessOutput output = null;
try (Closeable ignored = output = outputHandler.createOutput()) {
launchProcessing(parameters, output.getStandardOutput(), output.getErrorOutput());
} finally {
if (output != null) {
try {
outputHandler.handleOutput(output);
} catch (ProcessException e) {
// ignore this one
}
}
}
return null;
});
}
}
List<File> files = dexArchives.build();
return files;
}
use of com.android.ide.common.process.ProcessOutputHandler in project atlas by alibaba.
the class Dex method doTaskAction.
private void doTaskAction(@Nullable Collection<File> inputFiles, @Nullable File inputDir, boolean incremental) throws IOException, ProcessException, InterruptedException {
File outFolder = getOutputFolder();
if (!incremental) {
FileUtils.deleteDirectoryContents(outFolder);
}
File tmpFolder = getTmpFolder();
tmpFolder.mkdirs();
// if some of our .jar input files exist, just reset the inputDir to null
for (File inputFile : inputFiles) {
if (inputFile.exists()) {
inputDir = null;
}
}
if (inputDir != null) {
inputFiles = getProject().files(inputDir).getFiles();
}
final ProcessOutputHandler outputHandler = new ParsingProcessOutputHandler(new ToolOutputParser(new DexParser(), Message.Kind.ERROR, getILogger()), new ToolOutputParser(new DexParser(), getILogger()), getBuilder().getErrorReporter());
List<File> inputDexFiles = new ArrayList<File>();
inputDexFiles.addAll(inputFiles);
inputDexFiles.addAll(getLibraries());
getBuilder().getDexByteCodeConverter().convertByteCode(inputDexFiles, outFolder, getMultiDexEnabled(), getMainDexListFile(), getDexOptions(), outputHandler, 14);
File dexBaseFile = getDexBaseFile();
if (dexBaseFile != null) {
ZipFile files = new ZipFile(dexBaseFile);
ZipEntry entry = files.getEntry("classes.dex");
if (entry == null) {
throw new DexException("Expected classes.dex in " + dexBaseFile);
}
File file = new File(outFolder, "classes.dex");
com.taobao.android.dex.Dex merged = new DexMerger(new com.taobao.android.dex.Dex[] { new com.taobao.android.dex.Dex(file), new com.taobao.android.dex.Dex(files.getInputStream(entry)) }, CollisionPolicy.KEEP_FIRST).merge();
merged.writeTo(file);
}
}
Aggregations