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")));
}
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")));
}
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));
}
Aggregations