Search in sources :

Example 1 with JavacToJarStepFactory

use of com.facebook.buck.jvm.java.JavacToJarStepFactory in project buck by facebook.

the class AndroidBinaryGraphEnhancer method createAdditionalBuildables.

AndroidGraphEnhancementResult createAdditionalBuildables() throws NoSuchBuildTargetException {
    ImmutableSortedSet.Builder<BuildRule> enhancedDeps = ImmutableSortedSet.naturalOrder();
    enhancedDeps.addAll(originalDeps);
    ImmutableList.Builder<BuildRule> additionalJavaLibrariesBuilder = ImmutableList.builder();
    AndroidPackageableCollector collector = new AndroidPackageableCollector(originalBuildTarget, buildTargetsToExcludeFromDex, resourcesToExclude, apkModuleGraph);
    collector.addPackageables(AndroidPackageableCollector.getPackageableRules(originalDeps));
    AndroidPackageableCollection packageableCollection = collector.build();
    AndroidPackageableCollection.ResourceDetails resourceDetails = packageableCollection.getResourceDetails();
    AndroidNativeLibsGraphEnhancementResult nativeLibsEnhancementResult = nativeLibsEnhancer.enhance(packageableCollection);
    Optional<ImmutableMap<APKModule, CopyNativeLibraries>> copyNativeLibraries = nativeLibsEnhancementResult.getCopyNativeLibraries();
    if (copyNativeLibraries.isPresent()) {
        ruleResolver.addAllToIndex(copyNativeLibraries.get().values());
        enhancedDeps.addAll(copyNativeLibraries.get().values());
    }
    Optional<ImmutableSortedMap<String, String>> sonameMergeMap = nativeLibsEnhancementResult.getSonameMergeMap();
    if (sonameMergeMap.isPresent() && nativeLibraryMergeCodeGenerator.isPresent()) {
        BuildRule generatorRule = ruleResolver.getRule(nativeLibraryMergeCodeGenerator.get());
        GenerateCodeForMergedLibraryMap generateCodeForMergedLibraryMap = new GenerateCodeForMergedLibraryMap(buildRuleParams.withAppendedFlavor(GENERATE_NATIVE_LIB_MERGE_MAP_GENERATED_CODE_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(generatorRule)), Suppliers.ofInstance(ImmutableSortedSet.of())), sonameMergeMap.get(), generatorRule);
        ruleResolver.addToIndex(generateCodeForMergedLibraryMap);
        BuildRuleParams paramsForCompileGenCode = buildRuleParams.withAppendedFlavor(COMPILE_NATIVE_LIB_MERGE_MAP_GENERATED_CODE_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(generateCodeForMergedLibraryMap)), Suppliers.ofInstance(ImmutableSortedSet.of()));
        DefaultJavaLibrary compileMergedNativeLibMapGenCode = new DefaultJavaLibrary(paramsForCompileGenCode, pathResolver, ruleFinder, ImmutableSet.of(generateCodeForMergedLibraryMap.getSourcePathToOutput()), /* resources */
        ImmutableSet.of(), javacOptions.getGeneratedSourceFolderName(), /* proguardConfig */
        Optional.empty(), /* postprocessClassesCommands */
        ImmutableList.of(), /* exportedDeps */
        ImmutableSortedSet.of(), /* providedDeps */
        ImmutableSortedSet.of(), JavaLibraryRules.getAbiInputs(ruleResolver, paramsForCompileGenCode.getDeps()), /* trackClassUsage */
        false, /* additionalClasspathEntries */
        ImmutableSet.of(), new JavacToJarStepFactory(// to 6 in their .buckconfig.
        javacOptions.withSourceLevel("7").withTargetLevel("7"), JavacOptionsAmender.IDENTITY), /* resourcesRoot */
        Optional.empty(), /* manifest file */
        Optional.empty(), /* mavenCoords */
        Optional.empty(), ImmutableSortedSet.of(), /* classesToRemoveFromJar */
        ImmutableSet.of());
        ruleResolver.addToIndex(compileMergedNativeLibMapGenCode);
        additionalJavaLibrariesBuilder.add(compileMergedNativeLibMapGenCode);
        enhancedDeps.add(compileMergedNativeLibMapGenCode);
    }
    ImmutableSortedSet<BuildRule> resourceRules = getTargetsAsRules(resourceDetails.getResourcesWithNonEmptyResDir());
    ImmutableCollection<BuildRule> rulesWithResourceDirectories = ruleFinder.filterBuildRuleInputs(resourceDetails.getResourceDirectories());
    FilteredResourcesProvider filteredResourcesProvider;
    boolean needsResourceFiltering = resourceFilter.isEnabled() || resourceCompressionMode.isStoreStringsAsAssets() || !locales.isEmpty();
    if (needsResourceFiltering) {
        BuildRuleParams paramsForResourcesFilter = buildRuleParams.withAppendedFlavor(RESOURCES_FILTER_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(resourceRules).addAll(rulesWithResourceDirectories).build()), Suppliers.ofInstance(ImmutableSortedSet.of()));
        ResourcesFilter resourcesFilter = new ResourcesFilter(paramsForResourcesFilter, resourceDetails.getResourceDirectories(), ImmutableSet.copyOf(resourceDetails.getWhitelistedStringDirectories()), locales, resourceCompressionMode, resourceFilter);
        ruleResolver.addToIndex(resourcesFilter);
        filteredResourcesProvider = resourcesFilter;
        enhancedDeps.add(resourcesFilter);
        resourceRules = ImmutableSortedSet.of(resourcesFilter);
    } else {
        filteredResourcesProvider = new IdentityResourcesProvider(resourceDetails.getResourceDirectories().stream().map(pathResolver::getRelativePath).collect(MoreCollectors.toImmutableList()));
    }
    // Create the AaptPackageResourcesBuildable.
    BuildRuleParams paramsForAaptPackageResources = buildRuleParams.withAppendedFlavor(AAPT_PACKAGE_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of()), Suppliers.ofInstance(ImmutableSortedSet.of()));
    AaptPackageResources aaptPackageResources = new AaptPackageResources(paramsForAaptPackageResources, ruleFinder, ruleResolver, manifest, filteredResourcesProvider, getTargetsAsResourceDeps(resourceDetails.getResourcesWithNonEmptyResDir()), getTargetsAsRules(resourceDetails.getResourcesWithEmptyResButNonEmptyAssetsDir()), packageableCollection.getAssetsDirectories(), resourceUnionPackage, shouldBuildStringSourceMap, skipCrunchPngs, includesVectorDrawables, bannedDuplicateResourceTypes, manifestEntries);
    ruleResolver.addToIndex(aaptPackageResources);
    enhancedDeps.add(aaptPackageResources);
    Optional<PackageStringAssets> packageStringAssets = Optional.empty();
    if (resourceCompressionMode.isStoreStringsAsAssets()) {
        BuildRuleParams paramsForPackageStringAssets = buildRuleParams.withAppendedFlavor(PACKAGE_STRING_ASSETS_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().add(aaptPackageResources).addAll(resourceRules).addAll(rulesWithResourceDirectories).addAll(Iterables.filter(ImmutableList.of(filteredResourcesProvider), BuildRule.class)).build()), Suppliers.ofInstance(ImmutableSortedSet.of()));
        packageStringAssets = Optional.of(new PackageStringAssets(paramsForPackageStringAssets, locales, filteredResourcesProvider, aaptPackageResources));
        ruleResolver.addToIndex(packageStringAssets.get());
        enhancedDeps.add(packageStringAssets.get());
    }
    // already been added to the APK under test.
    if (packageType != PackageType.INSTRUMENTED) {
        ImmutableSortedSet<JavaLibrary> buildConfigDepsRules = addBuildConfigDeps(buildRuleParams, packageType, exopackageModes, buildConfigValues, buildConfigValuesFile, ruleResolver, javacOptions, packageableCollection);
        enhancedDeps.addAll(buildConfigDepsRules);
        additionalJavaLibrariesBuilder.addAll(buildConfigDepsRules);
    }
    ImmutableList<BuildRule> additionalJavaLibraries = additionalJavaLibrariesBuilder.build();
    ImmutableMultimap<APKModule, DexProducedFromJavaLibrary> preDexedLibraries = ImmutableMultimap.of();
    if (shouldPreDex) {
        preDexedLibraries = createPreDexRulesForLibraries(// TODO(dreiss): Put R.java here.
        additionalJavaLibraries, packageableCollection);
    }
    // Create rule to trim uber R.java sources.
    Collection<DexProducedFromJavaLibrary> preDexedLibrariesForResourceIdFiltering = trimResourceIds ? preDexedLibraries.values() : ImmutableList.of();
    BuildRuleParams paramsForTrimUberRDotJava = buildRuleParams.withAppendedFlavor(TRIM_UBER_R_DOT_JAVA_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().add(aaptPackageResources).addAll(preDexedLibrariesForResourceIdFiltering).build()), Suppliers.ofInstance(ImmutableSortedSet.of()));
    TrimUberRDotJava trimUberRDotJava = new TrimUberRDotJava(paramsForTrimUberRDotJava, aaptPackageResources, preDexedLibrariesForResourceIdFiltering, keepResourcePattern);
    ruleResolver.addToIndex(trimUberRDotJava);
    // Create rule to compile uber R.java sources.
    BuildRuleParams paramsForCompileUberRDotJava = buildRuleParams.withAppendedFlavor(COMPILE_UBER_R_DOT_JAVA_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(trimUberRDotJava)), Suppliers.ofInstance(ImmutableSortedSet.of()));
    JavaLibrary compileUberRDotJava = new DefaultJavaLibrary(paramsForCompileUberRDotJava, pathResolver, ruleFinder, ImmutableSet.of(trimUberRDotJava.getSourcePathToOutput()), /* resources */
    ImmutableSet.of(), javacOptions.getGeneratedSourceFolderName(), /* proguardConfig */
    Optional.empty(), /* postprocessClassesCommands */
    ImmutableList.of(), /* exportedDeps */
    ImmutableSortedSet.of(), /* providedDeps */
    ImmutableSortedSet.of(), // we can just use its output as the ABI.
    JavaLibraryRules.getAbiInputs(ruleResolver, paramsForCompileUberRDotJava.getDeps()), /* trackClassUsage */
    false, /* additionalClasspathEntries */
    ImmutableSet.of(), new JavacToJarStepFactory(javacOptions.withSourceLevel("7").withTargetLevel("7"), JavacOptionsAmender.IDENTITY), /* resourcesRoot */
    Optional.empty(), /* manifest file */
    Optional.empty(), /* mavenCoords */
    Optional.empty(), ImmutableSortedSet.of(), /* classesToRemoveFromJar */
    ImmutableSet.of());
    ruleResolver.addToIndex(compileUberRDotJava);
    // Create rule to dex uber R.java sources.
    BuildRuleParams paramsForDexUberRDotJava = buildRuleParams.withAppendedFlavor(DEX_UBER_R_DOT_JAVA_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(compileUberRDotJava)), Suppliers.ofInstance(ImmutableSortedSet.of()));
    DexProducedFromJavaLibrary dexUberRDotJava = new DexProducedFromJavaLibrary(paramsForDexUberRDotJava, compileUberRDotJava);
    ruleResolver.addToIndex(dexUberRDotJava);
    Optional<PreDexMerge> preDexMerge = Optional.empty();
    if (shouldPreDex) {
        preDexMerge = Optional.of(createPreDexMergeRule(preDexedLibraries, dexUberRDotJava));
        enhancedDeps.add(preDexMerge.get());
    } else {
        enhancedDeps.addAll(getTargetsAsRules(packageableCollection.getJavaLibrariesToDex()));
        // If not pre-dexing, AndroidBinary needs to ProGuard and/or dex the compiled R.java.
        enhancedDeps.add(compileUberRDotJava);
    }
    // Add dependencies on all the build rules generating third-party JARs.  This is mainly to
    // correctly capture deps when a prebuilt_jar forwards the output from another build rule.
    enhancedDeps.addAll(ruleFinder.filterBuildRuleInputs(packageableCollection.getPathsToThirdPartyJars()));
    Optional<ComputeExopackageDepsAbi> computeExopackageDepsAbi = Optional.empty();
    if (!exopackageModes.isEmpty()) {
        BuildRuleParams paramsForComputeExopackageAbi = buildRuleParams.withAppendedFlavor(CALCULATE_ABI_FLAVOR).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(enhancedDeps.build()), Suppliers.ofInstance(ImmutableSortedSet.of()));
        computeExopackageDepsAbi = Optional.of(new ComputeExopackageDepsAbi(paramsForComputeExopackageAbi, exopackageModes, packageableCollection, copyNativeLibraries, preDexMerge));
        ruleResolver.addToIndex(computeExopackageDepsAbi.get());
        enhancedDeps.add(computeExopackageDepsAbi.get());
    }
    return AndroidGraphEnhancementResult.builder().setPackageableCollection(packageableCollection).setAaptPackageResources(aaptPackageResources).setCompiledUberRDotJava(compileUberRDotJava).setCopyNativeLibraries(copyNativeLibraries).setPackageStringAssets(packageStringAssets).setPreDexMerge(preDexMerge).setComputeExopackageDepsAbi(computeExopackageDepsAbi).setClasspathEntriesToDex(ImmutableSet.<SourcePath>builder().addAll(packageableCollection.getClasspathEntriesToDex()).addAll(additionalJavaLibraries.stream().map(BuildRule::getSourcePathToOutput).collect(MoreCollectors.toImmutableList())).build()).setFinalDeps(enhancedDeps.build()).setAPKModuleGraph(apkModuleGraph).build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) DefaultJavaLibrary(com.facebook.buck.jvm.java.DefaultJavaLibrary) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) BuildRule(com.facebook.buck.rules.BuildRule) JavacToJarStepFactory(com.facebook.buck.jvm.java.JavacToJarStepFactory) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) ImmutableMap(com.google.common.collect.ImmutableMap) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) JavaLibrary(com.facebook.buck.jvm.java.JavaLibrary) DefaultJavaLibrary(com.facebook.buck.jvm.java.DefaultJavaLibrary)

Example 2 with JavacToJarStepFactory

use of com.facebook.buck.jvm.java.JavacToJarStepFactory in project buck by facebook.

the class RobolectricTestDescription method createBuildRule.

@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    JavacOptions javacOptions = JavacOptionsFactory.create(templateOptions, params, resolver, ruleFinder, args);
    AndroidLibraryGraphEnhancer graphEnhancer = new AndroidLibraryGraphEnhancer(params.getBuildTarget(), params.copyReplacingExtraDeps(Suppliers.ofInstance(resolver.getAllRules(args.exportedDeps))), javacOptions, DependencyMode.TRANSITIVE, /* forceFinalResourceIds */
    true, /* resourceUnionPackage */
    Optional.empty(), /* rName */
    Optional.empty(), args.useOldStyleableFormat);
    if (CalculateAbi.isAbiTarget(params.getBuildTarget())) {
        if (params.getBuildTarget().getFlavors().contains(AndroidLibraryGraphEnhancer.DUMMY_R_DOT_JAVA_FLAVOR)) {
            return graphEnhancer.getBuildableForAndroidResourcesAbi(resolver, ruleFinder);
        }
        BuildTarget testTarget = CalculateAbi.getLibraryTarget(params.getBuildTarget());
        BuildRule testRule = resolver.requireRule(testTarget);
        return CalculateAbi.of(params.getBuildTarget(), ruleFinder, params, Preconditions.checkNotNull(testRule.getSourcePathToOutput()));
    }
    ImmutableList<String> vmArgs = args.vmArgs;
    Optional<DummyRDotJava> dummyRDotJava = graphEnhancer.getBuildableForAndroidResources(resolver, /* createBuildableIfEmpty */
    true);
    ImmutableSet<Either<SourcePath, Path>> additionalClasspathEntries = ImmutableSet.of();
    if (dummyRDotJava.isPresent()) {
        additionalClasspathEntries = ImmutableSet.of(Either.ofLeft(dummyRDotJava.get().getSourcePathToOutput()));
        ImmutableSortedSet<BuildRule> newExtraDeps = ImmutableSortedSet.<BuildRule>naturalOrder().addAll(params.getExtraDeps().get()).add(dummyRDotJava.get()).build();
        params = params.copyReplacingExtraDeps(Suppliers.ofInstance(newExtraDeps));
    }
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    JavaTestDescription.CxxLibraryEnhancement cxxLibraryEnhancement = new JavaTestDescription.CxxLibraryEnhancement(params, args.useCxxLibraries, args.cxxLibraryWhitelist, resolver, ruleFinder, cxxPlatform);
    params = cxxLibraryEnhancement.updatedParams;
    // Rewrite dependencies on tests to actually depend on the code which backs the test.
    BuildRuleParams testsLibraryParams = params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(params.getDeclaredDeps().get()).addAll(BuildRules.getExportedRules(Iterables.concat(params.getDeclaredDeps().get(), resolver.getAllRules(args.providedDeps)))).build()), Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(params.getExtraDeps().get()).addAll(ruleFinder.filterBuildRuleInputs(javacOptions.getInputs(ruleFinder))).build())).withAppendedFlavor(JavaTest.COMPILED_TESTS_LIBRARY_FLAVOR);
    JavaLibrary testsLibrary = resolver.addToIndex(new DefaultJavaLibrary(testsLibraryParams, pathResolver, ruleFinder, args.srcs, validateResources(pathResolver, params.getProjectFilesystem(), args.resources), javacOptions.getGeneratedSourceFolderName(), args.proguardConfig, /* postprocessClassesCommands */
    ImmutableList.of(), /* exportDeps */
    ImmutableSortedSet.of(), /* providedDeps */
    resolver.getAllRules(args.providedDeps), JavaLibraryRules.getAbiInputs(resolver, testsLibraryParams.getDeps()), javacOptions.trackClassUsage(), additionalClasspathEntries, new JavacToJarStepFactory(javacOptions, new BootClasspathAppender()), args.resourcesRoot, args.manifestFile, args.mavenCoords, /* tests */
    ImmutableSortedSet.of(), /* classesToRemoveFromJar */
    ImmutableSet.of()));
    return new RobolectricTest(params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(testsLibrary)), Suppliers.ofInstance(ImmutableSortedSet.of())), ruleFinder, testsLibrary, additionalClasspathEntries, args.labels, args.contacts, TestType.JUNIT, javaOptions, vmArgs, cxxLibraryEnhancement.nativeLibsEnvironment, dummyRDotJava, args.testRuleTimeoutMs.map(Optional::of).orElse(defaultTestRuleTimeoutMs), args.testCaseTimeoutMs, args.env, args.getRunTestSeparately(), args.getForkMode(), args.stdOutLogLevel, args.stdErrLogLevel, args.robolectricRuntimeDependency, args.robolectricManifest);
}
Also used : JavacOptions(com.facebook.buck.jvm.java.JavacOptions) JavacToJarStepFactory(com.facebook.buck.jvm.java.JavacToJarStepFactory) Optional(java.util.Optional) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) DefaultJavaLibrary(com.facebook.buck.jvm.java.DefaultJavaLibrary) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) JavaLibrary(com.facebook.buck.jvm.java.JavaLibrary) DefaultJavaLibrary(com.facebook.buck.jvm.java.DefaultJavaLibrary) BuildTarget(com.facebook.buck.model.BuildTarget) Either(com.facebook.buck.model.Either) JavaTestDescription(com.facebook.buck.jvm.java.JavaTestDescription) BuildRule(com.facebook.buck.rules.BuildRule)

Example 3 with JavacToJarStepFactory

use of com.facebook.buck.jvm.java.JavacToJarStepFactory in project buck by facebook.

the class AndroidPrebuiltAarDescription method createBuildRule.

@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver buildRuleResolver, A args) throws NoSuchBuildTargetException {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(buildRuleResolver);
    ImmutableSet<Flavor> flavors = params.getBuildTarget().getFlavors();
    if (flavors.contains(AAR_UNZIP_FLAVOR)) {
        Preconditions.checkState(flavors.size() == 1);
        BuildRuleParams unzipAarParams = params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of()), Suppliers.ofInstance(ImmutableSortedSet.copyOf(ruleFinder.filterBuildRuleInputs(args.aar))));
        return new UnzipAar(unzipAarParams, args.aar);
    }
    BuildRule unzipAarRule = buildRuleResolver.requireRule(params.getBuildTarget().withFlavors(AAR_UNZIP_FLAVOR));
    Preconditions.checkState(unzipAarRule instanceof UnzipAar, "aar_unzip flavor created rule of unexpected type %s for target %s", unzipAarRule.getClass(), params.getBuildTarget());
    UnzipAar unzipAar = (UnzipAar) unzipAarRule;
    if (CalculateAbi.isAbiTarget(params.getBuildTarget())) {
        return CalculateAbi.of(params.getBuildTarget(), ruleFinder, params, new ExplicitBuildTargetSourcePath(unzipAar.getBuildTarget(), unzipAar.getPathToClassesJar()));
    }
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    Iterable<PrebuiltJar> javaDeps = Iterables.concat(Iterables.filter(buildRuleResolver.getAllRules(args.deps), PrebuiltJar.class), Iterables.transform(Iterables.filter(buildRuleResolver.getAllRules(args.deps), AndroidPrebuiltAar.class), AndroidPrebuiltAar::getPrebuiltJar));
    if (flavors.contains(AAR_PREBUILT_JAR_FLAVOR)) {
        Preconditions.checkState(flavors.size() == 1, "Expected only flavor to be %s but also found %s", AAR_PREBUILT_JAR_FLAVOR, flavors);
        BuildRuleParams buildRuleParams = params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.copyOf(javaDeps)), Suppliers.ofInstance(ImmutableSortedSet.of(unzipAar)));
        return new PrebuiltJar(/* params */
        buildRuleParams, /* resolver */
        pathResolver, /* binaryJar */
        new ExplicitBuildTargetSourcePath(unzipAar.getBuildTarget(), unzipAar.getPathToClassesJar()), /* sourceJar */
        Optional.empty(), /* gwtJar */
        Optional.empty(), /* javadocUrl */
        Optional.empty(), /* mavenCoords */
        Optional.empty(), /* provided */
        false);
    }
    BuildRule prebuiltJarRule = buildRuleResolver.requireRule(BuildTargets.createFlavoredBuildTarget(params.getBuildTarget().checkUnflavored(), AAR_PREBUILT_JAR_FLAVOR));
    Preconditions.checkState(prebuiltJarRule instanceof PrebuiltJar, "%s flavor created rule of unexpected type %s for target %s", AAR_PREBUILT_JAR_FLAVOR, unzipAarRule.getType(), params.getBuildTarget());
    PrebuiltJar prebuiltJar = (PrebuiltJar) prebuiltJarRule;
    Preconditions.checkArgument(flavors.isEmpty(), "Unexpected flavors for android_prebuilt_aar: %s", flavors);
    BuildRuleParams androidLibraryParams = params.copyReplacingDeclaredAndExtraDeps(/* declaredDeps */
    Suppliers.ofInstance(ImmutableSortedSet.of(prebuiltJar)), /* extraDeps */
    Suppliers.ofInstance(ImmutableSortedSet.of(unzipAar)));
    return new AndroidPrebuiltAar(androidLibraryParams, /* resolver */
    pathResolver, ruleFinder, /* proguardConfig */
    new ExplicitBuildTargetSourcePath(unzipAar.getBuildTarget(), unzipAar.getProguardConfig()), /* nativeLibsDirectory */
    new ExplicitBuildTargetSourcePath(unzipAar.getBuildTarget(), unzipAar.getNativeLibsDirectory()), /* prebuiltJar */
    prebuiltJar, /* unzipRule */
    unzipAar, /* javacOptions */
    javacOptions, new JavacToJarStepFactory(javacOptions, new BootClasspathAppender()), /* exportedDeps */
    javaDeps, JavaLibraryRules.getAbiInputs(buildRuleResolver, androidLibraryParams.getDeps()));
}
Also used : JavacToJarStepFactory(com.facebook.buck.jvm.java.JavacToJarStepFactory) PrebuiltJar(com.facebook.buck.jvm.java.PrebuiltJar) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) InternalFlavor(com.facebook.buck.model.InternalFlavor) Flavor(com.facebook.buck.model.Flavor) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) BuildRule(com.facebook.buck.rules.BuildRule) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath)

Aggregations

JavacToJarStepFactory (com.facebook.buck.jvm.java.JavacToJarStepFactory)3 BuildRule (com.facebook.buck.rules.BuildRule)3 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)3 DefaultJavaLibrary (com.facebook.buck.jvm.java.DefaultJavaLibrary)2 JavaLibrary (com.facebook.buck.jvm.java.JavaLibrary)2 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)2 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)2 JavaTestDescription (com.facebook.buck.jvm.java.JavaTestDescription)1 JavacOptions (com.facebook.buck.jvm.java.JavacOptions)1 PrebuiltJar (com.facebook.buck.jvm.java.PrebuiltJar)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 Either (com.facebook.buck.model.Either)1 Flavor (com.facebook.buck.model.Flavor)1 InternalFlavor (com.facebook.buck.model.InternalFlavor)1 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 Optional (java.util.Optional)1