Search in sources :

Example 1 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class AndroidBinaryGraphEnhancerTest method testCreateDepsForPreDexing.

@Test
public void testCreateDepsForPreDexing() throws Exception {
    // Create three Java rules, :dep1, :dep2, and :lib. :lib depends on :dep1 and :dep2.
    BuildTarget javaDep1BuildTarget = BuildTargetFactory.newInstance("//java/com/example:dep1");
    TargetNode<?, ?> javaDep1Node = JavaLibraryBuilder.createBuilder(javaDep1BuildTarget).addSrc(Paths.get("java/com/example/Dep1.java")).build();
    BuildTarget javaDep2BuildTarget = BuildTargetFactory.newInstance("//java/com/example:dep2");
    TargetNode<?, ?> javaDep2Node = JavaLibraryBuilder.createBuilder(javaDep2BuildTarget).addSrc(Paths.get("java/com/example/Dep2.java")).build();
    BuildTarget javaLibBuildTarget = BuildTargetFactory.newInstance("//java/com/example:lib");
    TargetNode<?, ?> javaLibNode = JavaLibraryBuilder.createBuilder(javaLibBuildTarget).addSrc(Paths.get("java/com/example/Lib.java")).addDep(javaDep1Node.getBuildTarget()).addDep(javaDep2Node.getBuildTarget()).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(javaDep1Node, javaDep2Node, javaLibNode);
    BuildRuleResolver ruleResolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
    BuildRule javaDep1 = ruleResolver.requireRule(javaDep1BuildTarget);
    BuildRule javaDep2 = ruleResolver.requireRule(javaDep2BuildTarget);
    BuildRule javaLib = ruleResolver.requireRule(javaLibBuildTarget);
    // Assume we are enhancing an android_binary rule whose only dep
    // is //java/com/example:lib, and that //java/com/example:dep2 is in its no_dx list.
    ImmutableSortedSet<BuildRule> originalDeps = ImmutableSortedSet.of(javaLib);
    ImmutableSet<BuildTarget> buildRulesToExcludeFromDex = ImmutableSet.of(javaDep2BuildTarget);
    BuildTarget apkTarget = BuildTargetFactory.newInstance("//java/com/example:apk");
    FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildRuleParams originalParams = new BuildRuleParams(apkTarget, Suppliers.ofInstance(originalDeps), Suppliers.ofInstance(originalDeps), filesystem, TestCellBuilder.createCellRoots(filesystem));
    AndroidBinaryGraphEnhancer graphEnhancer = new AndroidBinaryGraphEnhancer(originalParams, ruleResolver, ResourcesFilter.ResourceCompressionMode.DISABLED, FilterResourcesStep.ResourceFilter.EMPTY_FILTER, /* bannedDuplicateResourceTypes */
    EnumSet.noneOf(RType.class), Optional.empty(), /* locales */
    ImmutableSet.of(), createStrictMock(PathSourcePath.class), AndroidBinary.PackageType.DEBUG, /* cpuFilters */
    ImmutableSet.of(), /* shouldBuildStringSourceMap */
    false, /* shouldPreDex */
    true, BuildTargets.getScratchPath(originalParams.getProjectFilesystem(), apkTarget, "%s/classes.dex"), DexSplitMode.NO_SPLIT, buildRulesToExcludeFromDex, /* resourcesToExclude */
    ImmutableSet.of(), /* skipCrunchPngs */
    false, /* includesVectorDrawables */
    false, ANDROID_JAVAC_OPTIONS, EnumSet.noneOf(ExopackageMode.class), /* buildConfigValues */
    BuildConfigFields.empty(), /* buildConfigValuesFile */
    Optional.empty(), /* xzCompressionLevel */
    Optional.empty(), /* trimResourceIds */
    false, /* keepResourcePattern */
    Optional.empty(), /* nativePlatforms */
    ImmutableMap.of(), /* nativeLibraryMergeMap */
    Optional.empty(), /* nativeLibraryMergeGlue */
    Optional.empty(), /* nativeLibraryMergeCodeGenerator */
    Optional.empty(), AndroidBinary.RelinkerMode.DISABLED, MoreExecutors.newDirectExecutorService(), /* manifestEntries */
    ManifestEntries.empty(), CxxPlatformUtils.DEFAULT_CONFIG, new APKModuleGraph(TargetGraph.EMPTY, originalParams.getBuildTarget(), Optional.empty()), new DxConfig(FakeBuckConfig.builder().build()));
    BuildTarget aaptPackageResourcesTarget = BuildTargetFactory.newInstance("//java/com/example:apk#aapt_package");
    BuildRuleParams aaptPackageResourcesParams = new FakeBuildRuleParamsBuilder(aaptPackageResourcesTarget).build();
    AaptPackageResources aaptPackageResources = new AaptPackageResources(aaptPackageResourcesParams, ruleFinder, ruleResolver, /* manifest */
    new FakeSourcePath("java/src/com/facebook/base/AndroidManifest.xml"), new IdentityResourcesProvider(ImmutableList.of()), ImmutableList.of(), ImmutableSortedSet.of(), ImmutableSet.of(), /* resourceUnionPackage */
    Optional.empty(), false, /* skipCrunchPngs */
    false, /* includesVectorDrawables */
    false, /* bannedDuplicateResourceTypes */
    EnumSet.noneOf(RType.class), /* manifestEntries */
    ManifestEntries.empty());
    ruleResolver.addToIndex(aaptPackageResources);
    AndroidPackageableCollection collection = new AndroidPackageableCollector(/* collectionRoot */
    apkTarget, ImmutableSet.of(javaDep2BuildTarget), /* resourcesToExclude */
    ImmutableSet.of(), new APKModuleGraph(TargetGraph.EMPTY, apkTarget, Optional.empty())).addClasspathEntry(((HasJavaClassHashes) javaDep1), new FakeSourcePath("ignored")).addClasspathEntry(((HasJavaClassHashes) javaDep2), new FakeSourcePath("ignored")).addClasspathEntry(((HasJavaClassHashes) javaLib), new FakeSourcePath("ignored")).build();
    ImmutableMultimap<APKModule, DexProducedFromJavaLibrary> preDexedLibraries = graphEnhancer.createPreDexRulesForLibraries(/* additionalJavaLibrariesToDex */
    ImmutableList.of(), collection);
    BuildTarget fakeUberRDotJavaCompileTarget = BuildTargetFactory.newInstance("//fake:uber_r_dot_java#compile");
    JavaLibrary fakeUberRDotJavaCompile = JavaLibraryBuilder.createBuilder(fakeUberRDotJavaCompileTarget).build(ruleResolver);
    BuildTarget fakeUberRDotJavaDexTarget = BuildTargetFactory.newInstance("//fake:uber_r_dot_java#dex");
    DexProducedFromJavaLibrary fakeUberRDotJavaDex = new DexProducedFromJavaLibrary(new FakeBuildRuleParamsBuilder(fakeUberRDotJavaDexTarget).build(), fakeUberRDotJavaCompile);
    ruleResolver.addToIndex(fakeUberRDotJavaDex);
    BuildRule preDexMergeRule = graphEnhancer.createPreDexMergeRule(preDexedLibraries, fakeUberRDotJavaDex);
    BuildTarget dexMergeTarget = BuildTargetFactory.newInstance("//java/com/example:apk#dex_merge");
    BuildRule dexMergeRule = ruleResolver.getRule(dexMergeTarget);
    assertEquals(dexMergeRule, preDexMergeRule);
    BuildTarget javaDep1DexBuildTarget = BuildTarget.builder(javaDep1BuildTarget).addFlavors(AndroidBinaryGraphEnhancer.DEX_FLAVOR).build();
    BuildTarget javaDep2DexBuildTarget = BuildTarget.builder(javaDep2BuildTarget).addFlavors(AndroidBinaryGraphEnhancer.DEX_FLAVOR).build();
    BuildTarget javaLibDexBuildTarget = BuildTarget.builder(javaLibBuildTarget).addFlavors(AndroidBinaryGraphEnhancer.DEX_FLAVOR).build();
    assertThat("There should be a #dex rule for dep1 and lib, but not dep2 because it is in the no_dx " + "list.  And we should depend on uber_r_dot_java", Iterables.transform(dexMergeRule.getDeps(), BuildRule::getBuildTarget), Matchers.allOf(Matchers.not(Matchers.hasItem(javaDep1BuildTarget)), Matchers.hasItem(javaDep1DexBuildTarget), Matchers.not(Matchers.hasItem(javaDep2BuildTarget)), Matchers.not(Matchers.hasItem(javaDep2DexBuildTarget)), Matchers.hasItem(javaLibDexBuildTarget), Matchers.hasItem(fakeUberRDotJavaDex.getBuildTarget())));
}
Also used : RType(com.facebook.buck.android.aapt.RDotTxtEntry.RType) TargetGraph(com.facebook.buck.rules.TargetGraph) FakeBuildRuleParamsBuilder(com.facebook.buck.rules.FakeBuildRuleParamsBuilder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) BuildTarget(com.facebook.buck.model.BuildTarget) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildRule(com.facebook.buck.rules.BuildRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) HasJavaClassHashes(com.facebook.buck.jvm.core.HasJavaClassHashes) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PathSourcePath(com.facebook.buck.rules.PathSourcePath) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) ExopackageMode(com.facebook.buck.android.AndroidBinary.ExopackageMode) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) JavaLibrary(com.facebook.buck.jvm.java.JavaLibrary) Test(org.junit.Test)

Example 2 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class AndroidPackageableCollectorTest method testFindTransitiveDependencies.

/**
   * This is a regression test to ensure that an additional 1 second startup cost is not
   * re-introduced to fb4a.
   */
@Test
public void testFindTransitiveDependencies() throws Exception {
    ProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
    Path prebuiltNativeLibraryPath = Paths.get("java/com/facebook/prebuilt_native_library/libs");
    projectFilesystem.mkdirs(prebuiltNativeLibraryPath);
    // Create an AndroidBinaryRule that transitively depends on two prebuilt JARs. One of the two
    // prebuilt JARs will be listed in the AndroidBinaryRule's no_dx list.
    BuildTarget guavaTarget = BuildTargetFactory.newInstance("//third_party/guava:guava");
    TargetNode<?, ?> guava = PrebuiltJarBuilder.createBuilder(guavaTarget).setBinaryJar(Paths.get("third_party/guava/guava-10.0.1.jar")).build();
    BuildTarget jsr305Target = BuildTargetFactory.newInstance("//third_party/jsr-305:jsr-305");
    TargetNode<?, ?> jsr = PrebuiltJarBuilder.createBuilder(jsr305Target).setBinaryJar(Paths.get("third_party/jsr-305/jsr305.jar")).build();
    TargetNode<?, ?> ndkLibrary = new NdkLibraryBuilder(BuildTargetFactory.newInstance("//java/com/facebook/native_library:library"), projectFilesystem).build();
    BuildTarget prebuiltNativeLibraryTarget = BuildTargetFactory.newInstance("//java/com/facebook/prebuilt_native_library:library");
    TargetNode<?, ?> prebuiltNativeLibraryBuild = PrebuiltNativeLibraryBuilder.newBuilder(prebuiltNativeLibraryTarget, projectFilesystem).setNativeLibs(prebuiltNativeLibraryPath).setIsAsset(true).build();
    BuildTarget libraryRuleTarget = BuildTargetFactory.newInstance("//java/src/com/facebook:example");
    TargetNode<?, ?> library = JavaLibraryBuilder.createBuilder(libraryRuleTarget).setProguardConfig(new FakeSourcePath("debug.pro")).addSrc(Paths.get("Example.java")).addDep(guavaTarget).addDep(jsr305Target).addDep(prebuiltNativeLibraryBuild.getBuildTarget()).addDep(ndkLibrary.getBuildTarget()).build();
    BuildTarget manifestTarget = BuildTargetFactory.newInstance("//java/src/com/facebook:res");
    TargetNode<?, ?> manifest = AndroidResourceBuilder.createBuilder(manifestTarget).setManifest(new PathSourcePath(projectFilesystem, Paths.get("java/src/com/facebook/module/AndroidManifest.xml"))).setAssets(new FakeSourcePath("assets")).build();
    BuildTarget keystoreTarget = BuildTargetFactory.newInstance("//keystore:debug");
    TargetNode<?, ?> keystore = KeystoreBuilder.createBuilder(keystoreTarget).setStore(new FakeSourcePath(projectFilesystem, "keystore/debug.keystore")).setProperties(new FakeSourcePath(projectFilesystem, "keystore/debug.keystore.properties")).build();
    ImmutableSortedSet<BuildTarget> originalDepsTargets = ImmutableSortedSet.of(libraryRuleTarget, manifestTarget);
    BuildTarget binaryTarget = BuildTargetFactory.newInstance("//java/src/com/facebook:app");
    TargetNode<?, ?> binary = AndroidBinaryBuilder.createBuilder(binaryTarget).setOriginalDeps(originalDepsTargets).setBuildTargetsToExcludeFromDex(ImmutableSet.of(BuildTargetFactory.newInstance("//third_party/guava:guava"))).setManifest(new FakeSourcePath("java/src/com/facebook/AndroidManifest.xml")).setKeystore(keystoreTarget).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(binary, library, manifest, keystore, ndkLibrary, prebuiltNativeLibraryBuild, guava, jsr);
    BuildRuleResolver ruleResolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(ruleResolver));
    AndroidBinary binaryRule = (AndroidBinary) ruleResolver.requireRule(binaryTarget);
    NdkLibrary ndkLibraryRule = (NdkLibrary) ruleResolver.requireRule(ndkLibrary.getBuildTarget());
    NativeLibraryBuildRule prebuildNativeLibraryRule = (NativeLibraryBuildRule) ruleResolver.requireRule(prebuiltNativeLibraryTarget);
    // Verify that the correct transitive dependencies are found.
    AndroidPackageableCollection packageableCollection = binaryRule.getAndroidPackageableCollection();
    assertResolvedEquals("Because guava was passed to no_dx, it should not be in the classpathEntriesToDex list", pathResolver, ImmutableSet.of(ruleResolver.getRule(jsr305Target).getSourcePathToOutput(), ruleResolver.getRule(libraryRuleTarget).getSourcePathToOutput()), packageableCollection.getClasspathEntriesToDex());
    assertResolvedEquals("Because guava was passed to no_dx, it should not be treated as a third-party JAR whose " + "resources need to be extracted and repacked in the APK. If this is done, then code " + "in the guava-10.0.1.dex.1.jar in the APK's assets/ tmp may try to load the resource " + "from the APK as a ZipFileEntry rather than as a resource within " + "guava-10.0.1.dex.1.jar. Loading a resource in this way could take substantially " + "longer. Specifically, this was observed to take over one second longer to load " + "the resource in fb4a. Because the resource was loaded on startup, this introduced a " + "substantial regression in the startup time for the fb4a app.", pathResolver, ImmutableSet.of(ruleResolver.getRule(jsr305Target).getSourcePathToOutput()), packageableCollection.getPathsToThirdPartyJars());
    assertResolvedEquals("Because assets directory was passed an AndroidResourceRule it should be added to the " + "transitive dependencies", pathResolver, ImmutableSet.of(new DefaultBuildTargetSourcePath(manifestTarget.withAppendedFlavors(AndroidResourceDescription.ASSETS_SYMLINK_TREE_FLAVOR))), packageableCollection.getAssetsDirectories());
    assertResolvedEquals("Because a native library was declared as a dependency, it should be added to the " + "transitive dependencies.", pathResolver, ImmutableSet.<SourcePath>of(new PathSourcePath(new FakeProjectFilesystem(), ndkLibraryRule.getLibraryPath())), ImmutableSet.copyOf(packageableCollection.getNativeLibsDirectories().values()));
    assertResolvedEquals("Because a prebuilt native library  was declared as a dependency (and asset), it should " + "be added to the transitive dependecies.", pathResolver, ImmutableSet.<SourcePath>of(new PathSourcePath(new FakeProjectFilesystem(), prebuildNativeLibraryRule.getLibraryPath())), ImmutableSet.copyOf(packageableCollection.getNativeLibAssetsDirectories().values()));
    assertEquals(ImmutableSet.of(new FakeSourcePath("debug.pro")), packageableCollection.getProguardConfigs());
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) Path(java.nio.file.Path) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PathSourcePath(com.facebook.buck.rules.PathSourcePath) TargetGraph(com.facebook.buck.rules.TargetGraph) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 3 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class CopyNativeLibrariesTest method createAndroidBinaryRuleAndTestCopyNativeLibraryCommand.

private void createAndroidBinaryRuleAndTestCopyNativeLibraryCommand(ImmutableSet<TargetCpuType> cpuFilters, Path sourceDir, Path destinationDir, ImmutableList<String> expectedCommandDescriptions) {
    // Invoke copyNativeLibrary to populate the steps.
    ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
    CopyNativeLibraries.copyNativeLibrary(new FakeProjectFilesystem(), sourceDir, destinationDir, cpuFilters, stepsBuilder);
    ImmutableList<Step> steps = stepsBuilder.build();
    assertEquals(steps.size(), expectedCommandDescriptions.size());
    ExecutionContext context = TestExecutionContext.newInstance();
    for (int i = 0; i < steps.size(); ++i) {
        String description = steps.get(i).getDescription(context);
        assertEquals(expectedCommandDescriptions.get(i), description);
    }
}
Also used : ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) ImmutableList(com.google.common.collect.ImmutableList) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Step(com.facebook.buck.step.Step)

Example 4 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class AndroidResourceTest method testInputRuleKeyChangesIfDependencySymbolsChanges.

@Test
public void testInputRuleKeyChangesIfDependencySymbolsChanges() throws Exception {
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    TargetNode<?, ?> depNode = AndroidResourceBuilder.createBuilder(BuildTargetFactory.newInstance("//:dep"), filesystem).setManifest(new FakeSourcePath("manifest")).setRes(Paths.get("res")).build();
    TargetNode<?, ?> resourceNode = AndroidResourceBuilder.createBuilder(BuildTargetFactory.newInstance("//:rule"), filesystem).setDeps(ImmutableSortedSet.of(depNode.getBuildTarget())).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(depNode, resourceNode);
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    AndroidResource dep = (AndroidResource) resolver.requireRule(depNode.getBuildTarget());
    AndroidResource resource = (AndroidResource) resolver.requireRule(resourceNode.getBuildTarget());
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(filesystem)));
    filesystem.writeContentsToPath("something", pathResolver.getRelativePath(dep.getPathToTextSymbolsFile()));
    RuleKey original = new InputBasedRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder).build(resource);
    fileHashCache.invalidateAll();
    filesystem.writeContentsToPath("something else", pathResolver.getRelativePath(dep.getPathToTextSymbolsFile()));
    RuleKey changed = new InputBasedRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder).build(resource);
    assertThat(original, Matchers.not(Matchers.equalTo(changed)));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeFileHashCache(com.facebook.buck.testutil.FakeFileHashCache) DefaultFileHashCache(com.facebook.buck.util.cache.DefaultFileHashCache) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) FileHashCache(com.facebook.buck.util.cache.FileHashCache) InputBasedRuleKeyFactory(com.facebook.buck.rules.keys.InputBasedRuleKeyFactory) RuleKey(com.facebook.buck.rules.RuleKey) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 5 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class DuplicateResourcesTest method makeRules.

/*
   * Builds up the following dependency graph, which an android_binary can depend on how it likes:
   *
   *   //main_app:res        //direct_dep:library <--------+//direct_dep:res
   *                                  ^                             ^
   *                                  |                             |
   *                                  +                             +
   *                         //transitive_dep:library<-----+//transitive_dep:res
   *                                                                ^
   *                                                                |
   *                                                                +
   *                                                        //bottom_dep:res
   */
@Before
public void makeRules() throws Exception {
    mainResTarget = BuildTargetFactory.newInstance("//main_app:res");
    directDepResTarget = BuildTargetFactory.newInstance("//direct_dep:res");
    transitiveDepResTarget = BuildTargetFactory.newInstance("//transitive_dep:res");
    transitiveDepLibTarget = BuildTargetFactory.newInstance("//transitive_dep:library");
    bottomDepResTarget = BuildTargetFactory.newInstance("//bottom_dep:res");
    androidLibraryTarget = BuildTargetFactory.newInstance("//direct_dep:library");
    androidBinaryTarget = BuildTargetFactory.newInstance("//main_app:binary");
    keystoreTarget = BuildTargetFactory.newInstance("//main_app:keystore");
    filesystem = new FakeProjectFilesystem();
    mainRes = AndroidResourceBuilder.createBuilder(mainResTarget).setRes(new FakeSourcePath(filesystem, "main_app/res")).setRDotJavaPackage("package").build();
    directDepRes = AndroidResourceBuilder.createBuilder(directDepResTarget).setRes(new FakeSourcePath(filesystem, "direct_dep/res")).setRDotJavaPackage("package").setDeps(ImmutableSortedSet.of(transitiveDepResTarget, transitiveDepLibTarget)).build();
    transitiveDepLib = AndroidLibraryBuilder.createBuilder(transitiveDepLibTarget).addDep(transitiveDepResTarget).build();
    transitiveDepRes = AndroidResourceBuilder.createBuilder(transitiveDepResTarget).setRes(new FakeSourcePath(filesystem, "transitive_dep/res")).setRDotJavaPackage("package").setDeps(ImmutableSortedSet.of(bottomDepResTarget)).build();
    bottomDepRes = AndroidResourceBuilder.createBuilder(bottomDepResTarget).setRes(new FakeSourcePath(filesystem, "bottom_dep/res")).setRDotJavaPackage("package").build();
    library = AndroidLibraryBuilder.createBuilder(androidLibraryTarget).addDep(directDepResTarget).addDep(transitiveDepLibTarget).build();
    keystore = KeystoreBuilder.createBuilder(keystoreTarget).setStore(new FakeSourcePath(filesystem, "store")).setProperties(new FakeSourcePath(filesystem, "properties")).build();
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Before(org.junit.Before)

Aggregations

FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)438 Test (org.junit.Test)384 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)268 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)189 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)186 Path (java.nio.file.Path)169 BuildTarget (com.facebook.buck.model.BuildTarget)138 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)111 TargetGraph (com.facebook.buck.rules.TargetGraph)107 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)103 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)85 PathSourcePath (com.facebook.buck.rules.PathSourcePath)68 BuildRule (com.facebook.buck.rules.BuildRule)61 SourcePath (com.facebook.buck.rules.SourcePath)56 RuleKey (com.facebook.buck.rules.RuleKey)42 AllExistingProjectFilesystem (com.facebook.buck.testutil.AllExistingProjectFilesystem)40 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)39 ExecutionContext (com.facebook.buck.step.ExecutionContext)38 Before (org.junit.Before)30 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)29