use of com.android.builder.core.DesugarProcessBuilder in project atlas by alibaba.
the class AtlasDesugarTransform method processNonCachedOnes.
private void processNonCachedOnes(List<Path> classpath) throws IOException {
int parallelExecutions = waitableExecutor.getParallelism();
int index = 0;
Multimap<Integer, AtlasDesugarTransform.InputEntry> procBuckets = ArrayListMultimap.create();
for (AtlasDesugarTransform.InputEntry pathPathEntry : cacheMisses) {
int bucketId = index % parallelExecutions;
procBuckets.put(bucketId, pathPathEntry);
index++;
}
List<Path> desugarBootclasspath = getBootclasspath();
for (Integer bucketId : procBuckets.keySet()) {
Callable<Void> callable = () -> {
Map<Path, Path> inToOut = Maps.newHashMap();
for (AtlasDesugarTransform.InputEntry e : procBuckets.get(bucketId)) {
inToOut.put(e.getInputPath(), e.getOutputPath());
}
DesugarProcessBuilder processBuilder = new DesugarProcessBuilder(desugarJar.get(), verbose, inToOut, classpath, desugarBootclasspath, minSdk, tmpDir);
boolean isWindows = SdkConstants.currentPlatform() == SdkConstants.PLATFORM_WINDOWS;
executor.execute(processBuilder.build(isWindows), new LoggedProcessOutputHandler(logger)).rethrowFailure().assertNormalExitValue();
// now copy to the cache because now we have the file
for (AtlasDesugarTransform.InputEntry e : procBuckets.get(bucketId)) {
if (e.getCache() != null && e.getInputs() != null) {
e.getCache().createFileInCacheIfAbsent(e.getInputs(), in -> Files.copy(e.getOutputPath(), in.toPath()));
}
}
return null;
};
waitableExecutor.execute(callable);
}
}
Aggregations