use of com.facebook.buck.jvm.java.JavaRuntimeLauncher in project buck by facebook.
the class AndroidBinary method addProguardCommands.
/**
* @return the resulting set of ProGuarded classpath entries to dex.
*/
@VisibleForTesting
ImmutableSet<Path> addProguardCommands(Set<Path> classpathEntriesToDex, Set<Path> depsProguardConfigs, boolean skipProguard, ImmutableList.Builder<Step> steps, BuildableContext buildableContext, SourcePathResolver resolver) {
ImmutableSet.Builder<Path> additionalLibraryJarsForProguardBuilder = ImmutableSet.builder();
for (JavaLibrary buildRule : rulesToExcludeFromDex) {
additionalLibraryJarsForProguardBuilder.addAll(buildRule.getImmediateClasspaths().stream().map(resolver::getAbsolutePath).collect(MoreCollectors.toImmutableSet()));
}
// Create list of proguard Configs for the app project and its dependencies
ImmutableSet.Builder<Path> proguardConfigsBuilder = ImmutableSet.builder();
proguardConfigsBuilder.addAll(depsProguardConfigs);
if (proguardConfig.isPresent()) {
proguardConfigsBuilder.add(resolver.getAbsolutePath(proguardConfig.get()));
}
Path proguardConfigDir = getProguardTextFilesPath();
// Transform our input classpath to a set of output locations for each input classpath.
// TODO(jasta): the output path we choose is the result of a slicing function against
// input classpath. This is fragile and should be replaced with knowledge of the BuildTarget.
final ImmutableMap<Path, Path> inputOutputEntries = classpathEntriesToDex.stream().collect(MoreCollectors.toImmutableMap(java.util.function.Function.identity(), (path) -> getProguardOutputFromInputClasspath(proguardConfigDir, path)));
// Run ProGuard on the classpath entries.
ProGuardObfuscateStep.create(javaRuntimeLauncher, getProjectFilesystem(), proguardJarOverride.isPresent() ? Optional.of(resolver.getAbsolutePath(proguardJarOverride.get())) : Optional.empty(), proguardMaxHeapSize, proguardAgentPath, resolver.getRelativePath(aaptGeneratedProguardConfigFile), proguardConfigsBuilder.build(), sdkProguardConfig, optimizationPasses, proguardJvmArgs, inputOutputEntries, additionalLibraryJarsForProguardBuilder.build(), proguardConfigDir, buildableContext, skipProguard, steps);
// ProGuard then return the input classes to dex.
if (skipProguard) {
return ImmutableSet.copyOf(inputOutputEntries.keySet());
} else {
return ImmutableSet.copyOf(inputOutputEntries.values());
}
}
Aggregations