Search in sources :

Example 6 with FakeJavaPackageFinder

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

the class ResourcesRootPackageFinderTest method testResourcesPath.

@Test
public void testResourcesPath() {
    Path resourcesRoot = Paths.get("java/example/resources");
    ResourcesRootPackageFinder finder = new ResourcesRootPackageFinder(resourcesRoot, new FakeJavaPackageFinder());
    assertEquals(Paths.get("com/facebook/"), finder.findJavaPackageFolder(Paths.get("java/example/resources/com/facebook/bar.txt")));
    assertEquals("com.facebook", finder.findJavaPackage(Paths.get("java/example/resources/com/facebook/bar.txt")));
}
Also used : Path(java.nio.file.Path) FakeJavaPackageFinder(com.facebook.buck.jvm.java.FakeJavaPackageFinder) ResourcesRootPackageFinder(com.facebook.buck.jvm.java.ResourcesRootPackageFinder) Test(org.junit.Test)

Example 7 with FakeJavaPackageFinder

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

the class ResourcesRootPackageFinderTest method testNonmatchingPath.

@Test
public void testNonmatchingPath() {
    Path resourcesRoot = Paths.get("java/example/resources");
    ResourcesRootPackageFinder finder = new ResourcesRootPackageFinder(resourcesRoot, new FakeJavaPackageFinder());
    assertNull("Should fall back to the FakeJavaPackageFinder and return null.", finder.findJavaPackageFolder(Paths.get("does/not/match.txt")));
}
Also used : Path(java.nio.file.Path) FakeJavaPackageFinder(com.facebook.buck.jvm.java.FakeJavaPackageFinder) ResourcesRootPackageFinder(com.facebook.buck.jvm.java.ResourcesRootPackageFinder) Test(org.junit.Test)

Example 8 with FakeJavaPackageFinder

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

the class ProjectTest method getModulesForActionGraph.

private ProjectWithModules getModulesForActionGraph(BuildRuleResolver ruleResolver, ImmutableSortedSet<ProjectConfig> projectConfigs, @Nullable JavaPackageFinder javaPackageFinder, @Nullable IntellijConfig intellijConfig) throws IOException {
    if (javaPackageFinder == null) {
        javaPackageFinder = new FakeJavaPackageFinder();
    }
    if (intellijConfig == null) {
        intellijConfig = new IntellijConfig(FakeBuckConfig.builder().build());
    }
    // Create the Project.
    ExecutionContext executionContext = TestExecutionContext.newInstance();
    ProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
    Properties keystoreProperties = new Properties();
    keystoreProperties.put("key.alias", "androiddebugkey");
    keystoreProperties.put("key.store.password", "android");
    keystoreProperties.put("key.alias.password", "android");
    try (OutputStream output = projectFilesystem.newFileOutputStream(Paths.get("keystore/debug.keystore.properties"))) {
        keystoreProperties.store(output, "");
    }
    ImmutableMap<Path, String> basePathToAliasMap = ImmutableMap.of();
    Project project = new Project(new SourcePathResolver(new SourcePathRuleFinder(ruleResolver)), projectConfigs, basePathToAliasMap, javaPackageFinder, executionContext, new InMemoryBuildFileTree(Iterables.transform(ruleResolver.getBuildRules(), BuildRule::getBuildTarget)), projectFilesystem, /* pathToDefaultAndroidManifest */
    Optional.empty(), intellijConfig, /* pathToPostProcessScript */
    Optional.empty(), "python", ObjectMappers.newDefaultInstance(), true);
    // Execute Project's business logic.
    List<SerializableModule> modules = new ArrayList<>(project.createModulesForProjectConfigs());
    return new ProjectWithModules(project, ImmutableList.copyOf(modules));
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) Properties(java.util.Properties) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) FakeJavaPackageFinder(com.facebook.buck.jvm.java.FakeJavaPackageFinder) ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) InMemoryBuildFileTree(com.facebook.buck.model.InMemoryBuildFileTree) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildRule(com.facebook.buck.rules.BuildRule) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Aggregations

FakeJavaPackageFinder (com.facebook.buck.jvm.java.FakeJavaPackageFinder)8 TestConsole (com.facebook.buck.testutil.TestConsole)5 FakeAndroidDirectoryResolver (com.facebook.buck.android.FakeAndroidDirectoryResolver)4 NoopArtifactCache (com.facebook.buck.artifact_cache.NoopArtifactCache)4 Cell (com.facebook.buck.rules.Cell)4 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)4 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)4 ArtifactCache (com.facebook.buck.artifact_cache.ArtifactCache)3 BuckEventBus (com.facebook.buck.event.BuckEventBus)3 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)3 Path (java.nio.file.Path)3 Before (org.junit.Before)3 AndroidDirectoryResolver (com.facebook.buck.android.AndroidDirectoryResolver)2 ResourcesRootPackageFinder (com.facebook.buck.jvm.java.ResourcesRootPackageFinder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Test (org.junit.Test)2 AndroidPlatformTarget (com.facebook.buck.android.AndroidPlatformTarget)1 SingletonArtifactCacheFactory (com.facebook.buck.artifact_cache.SingletonArtifactCacheFactory)1 BroadcastEventListener (com.facebook.buck.event.listener.BroadcastEventListener)1 InMemoryBuildFileTree (com.facebook.buck.model.InMemoryBuildFileTree)1