use of com.facebook.buck.jvm.core.JavaPackageFinder in project buck by facebook.
the class CopyResourcesStepTest method testAddResourceCommandsWithBuildFileParentOfSrcDirectory.
@Test
public void testAddResourceCommandsWithBuildFileParentOfSrcDirectory() {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
// Files:
// android/java/BUCK
// android/java/src/com/facebook/base/data.json
// android/java/src/com/facebook/common/util/data.json
ProjectFilesystem filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
BuildTarget buildTarget = BuildTargetFactory.newInstance(filesystem.getRootPath(), "//android/java:resources");
JavaPackageFinder javaPackageFinder = createJavaPackageFinder();
CopyResourcesStep step = new CopyResourcesStep(filesystem, resolver, ruleFinder, buildTarget, ImmutableSet.of(new FakeSourcePath(filesystem, "android/java/src/com/facebook/base/data.json"), new FakeSourcePath(filesystem, "android/java/src/com/facebook/common/util/data.json")), filesystem.getBuckPaths().getScratchDir().resolve("android/java/lib__resources__classes"), javaPackageFinder);
List<? extends Step> expected = ImmutableList.of(new MkdirAndSymlinkFileStep(filesystem, filesystem.resolve("android/java/src/com/facebook/base/data.json"), filesystem.getBuckPaths().getScratchDir().resolve("android/java/lib__resources__classes/com/facebook/base/data.json")), new MkdirAndSymlinkFileStep(filesystem, filesystem.resolve("android/java/src/com/facebook/common/util/data.json"), filesystem.getBuckPaths().getScratchDir().resolve("android/java/lib__resources__classes/com/facebook/common/util/data.json")));
assertEquals(expected, step.buildSteps());
}
use of com.facebook.buck.jvm.core.JavaPackageFinder in project buck by facebook.
the class JavaPackageFinderSerializerTest method testSerializingAndDeserializing.
@Test
public void testSerializingAndDeserializing() throws Exception {
DefaultJavaPackageFinder defaultFinder = new DefaultJavaPackageFinder(ImmutableSortedSet.of("paths", "from", "root"), ImmutableSet.of("path", "elements"));
ResourcesRootPackageFinder resourcesRootFinder = new ResourcesRootPackageFinder(Paths.get("/path/to/res/root"), defaultFinder);
Map<String, Object> data = JavaPackageFinderSerializer.serialize(resourcesRootFinder);
JavaPackageFinder result = JavaPackageFinderSerializer.deserialize(data);
assertThat(result, Matchers.instanceOf(ResourcesRootPackageFinder.class));
ResourcesRootPackageFinder outResFinder = (ResourcesRootPackageFinder) result;
assertThat(outResFinder.getResourcesRoot(), Matchers.equalToObject(resourcesRootFinder.getResourcesRoot()));
JavaPackageFinder chainedFinder = outResFinder.getFallbackFinder();
assertThat(chainedFinder, Matchers.instanceOf(DefaultJavaPackageFinder.class));
DefaultJavaPackageFinder outDefFinder = (DefaultJavaPackageFinder) chainedFinder;
assertThat(outDefFinder.getPathElements(), Matchers.equalToObject(defaultFinder.getPathElements()));
assertThat(outDefFinder.getPathsFromRoot(), Matchers.equalToObject(defaultFinder.getPathsFromRoot()));
}
use of com.facebook.buck.jvm.core.JavaPackageFinder in project buck by facebook.
the class JavacErrorParserTest method setUp.
@Before
public void setUp() {
projectFilesystem = new ProjectFilesystem(Paths.get(".").toAbsolutePath());
JavaPackageFinder javaPackageFinder = DefaultJavaPackageFinder.createDefaultJavaPackageFinder(ImmutableSet.of("/src/"));
javacErrorParser = new JavacErrorParser(projectFilesystem, javaPackageFinder);
}
use of com.facebook.buck.jvm.core.JavaPackageFinder in project buck by facebook.
the class ParsingJavaPackageFinderTest method testCaching.
@Test
public void testCaching() {
JavaPackageFinder parsingJavaPackageFinder = ParsingJavaPackageFinder.preparse(javaFileParser, fakeProjectFilesystem, ImmutableSortedSet.of(matchPath, mismatchPath), dummyPackageFinder);
assertEquals("org.test.package1", parsingJavaPackageFinder.findJavaPackage(matchPath));
assertEquals("org.test.haha", parsingJavaPackageFinder.findJavaPackage(mismatchPath));
assertEquals("org.test.package3", parsingJavaPackageFinder.findJavaPackage(Paths.get("case1/org/test/package3/notfound")));
assertEquals("org.test", parsingJavaPackageFinder.findJavaPackage(Paths.get("case1/org/test/notfound")));
assertEquals("com", parsingJavaPackageFinder.findJavaPackage(Paths.get("case1/com/notfound")));
}
Aggregations