Search in sources :

Example 1 with JavaRuntimeLauncher

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());
    }
}
Also used : Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) OptionalCompat(com.facebook.buck.util.OptionalCompat) ExopackageInfo(com.facebook.buck.rules.ExopackageInfo) HasRuntimeDeps(com.facebook.buck.rules.HasRuntimeDeps) CopyStep(com.facebook.buck.step.fs.CopyStep) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) ImmutableCollection(com.google.common.collect.ImmutableCollection) RichStream(com.facebook.buck.util.RichStream) JavaLibrary(com.facebook.buck.jvm.java.JavaLibrary) MkdirStep(com.facebook.buck.step.fs.MkdirStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) FluentIterable(com.google.common.collect.FluentIterable) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SymlinkFilesIntoDirectoryStep(com.facebook.buck.shell.SymlinkFilesIntoDirectoryStep) Keystore(com.facebook.buck.jvm.java.Keystore) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) Path(java.nio.file.Path) EnumSet(java.util.EnumSet) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) AddToRuleKey(com.facebook.buck.rules.AddToRuleKey) ImmutableMap(com.google.common.collect.ImmutableMap) BuildableProperties(com.facebook.buck.rules.BuildableProperties) BuildableContext(com.facebook.buck.rules.BuildableContext) Set(java.util.Set) BuildTarget(com.facebook.buck.model.BuildTarget) HasClasspathEntries(com.facebook.buck.jvm.java.HasClasspathEntries) AbstractBuildRule(com.facebook.buck.rules.AbstractBuildRule) FileVisitResult(java.nio.file.FileVisitResult) List(java.util.List) Stream(java.util.stream.Stream) Optional(java.util.Optional) PACKAGING(com.facebook.buck.rules.BuildableProperties.Kind.PACKAGING) StepExecutionResult(com.facebook.buck.step.StepExecutionResult) JavaRuntimeLauncher(com.facebook.buck.jvm.java.JavaRuntimeLauncher) AccumulateClassNamesStep(com.facebook.buck.jvm.java.AccumulateClassNamesStep) Joiner(com.google.common.base.Joiner) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Iterables(com.google.common.collect.Iterables) Step(com.facebook.buck.step.Step) ResourceCompressionMode(com.facebook.buck.android.ResourcesFilter.ResourceCompressionMode) Supplier(com.google.common.base.Supplier) RepackZipEntriesStep(com.facebook.buck.zip.RepackZipEntriesStep) SourcePath(com.facebook.buck.rules.SourcePath) Multimap(com.google.common.collect.Multimap) BuildRule(com.facebook.buck.rules.BuildRule) AbstractExecutionStep(com.facebook.buck.step.AbstractExecutionStep) ExecutionContext(com.facebook.buck.step.ExecutionContext) ImmutableList(com.google.common.collect.ImmutableList) Files(com.google.common.io.Files) Suppliers(com.google.common.base.Suppliers) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) RedexOptions(com.facebook.buck.android.redex.RedexOptions) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Nullable(javax.annotation.Nullable) SupportsInputBasedRuleKey(com.facebook.buck.rules.keys.SupportsInputBasedRuleKey) MoreCollectors(com.facebook.buck.util.MoreCollectors) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) JavaLibraryClasspathProvider(com.facebook.buck.jvm.java.JavaLibraryClasspathProvider) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) HashCode(com.google.common.hash.HashCode) ManifestEntries(com.facebook.buck.rules.coercer.ManifestEntries) ReDexStep(com.facebook.buck.android.redex.ReDexStep) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) ANDROID(com.facebook.buck.rules.BuildableProperties.Kind.ANDROID) AbstractMap(java.util.AbstractMap) XzStep(com.facebook.buck.step.fs.XzStep) Paths(java.nio.file.Paths) ResourceFilter(com.facebook.buck.android.FilterResourcesStep.ResourceFilter) ZipScrubberStep(com.facebook.buck.zip.ZipScrubberStep) BuildContext(com.facebook.buck.rules.BuildContext) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) BuildTargets(com.facebook.buck.model.BuildTargets) AbstractGenruleStep(com.facebook.buck.shell.AbstractGenruleStep) ImmutableSet(com.google.common.collect.ImmutableSet) JavaLibrary(com.facebook.buck.jvm.java.JavaLibrary) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ResourceFilter (com.facebook.buck.android.FilterResourcesStep.ResourceFilter)1 ResourceCompressionMode (com.facebook.buck.android.ResourcesFilter.ResourceCompressionMode)1 ReDexStep (com.facebook.buck.android.redex.ReDexStep)1 RedexOptions (com.facebook.buck.android.redex.RedexOptions)1 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 AccumulateClassNamesStep (com.facebook.buck.jvm.java.AccumulateClassNamesStep)1 HasClasspathEntries (com.facebook.buck.jvm.java.HasClasspathEntries)1 JavaLibrary (com.facebook.buck.jvm.java.JavaLibrary)1 JavaLibraryClasspathProvider (com.facebook.buck.jvm.java.JavaLibraryClasspathProvider)1 JavaRuntimeLauncher (com.facebook.buck.jvm.java.JavaRuntimeLauncher)1 Keystore (com.facebook.buck.jvm.java.Keystore)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 BuildTargets (com.facebook.buck.model.BuildTargets)1 AbstractBuildRule (com.facebook.buck.rules.AbstractBuildRule)1 AddToRuleKey (com.facebook.buck.rules.AddToRuleKey)1 BuildContext (com.facebook.buck.rules.BuildContext)1 BuildRule (com.facebook.buck.rules.BuildRule)1 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)1 BuildableContext (com.facebook.buck.rules.BuildableContext)1 BuildableProperties (com.facebook.buck.rules.BuildableProperties)1