use of com.facebook.buck.rules.Description in project buck by facebook.
the class MissingSymbolsHandlerIntegrationTest method shouldFindNeededDependenciesFromSymbols.
@Test
public void shouldFindNeededDependenciesFromSymbols() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symbol_finder", temporaryFolder);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, String> environment = ImmutableMap.copyOf(System.getenv());
Config rawConfig = Configs.createDefaultConfig(projectFilesystem.getRootPath());
BuckConfig config = new BuckConfig(rawConfig, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), rawConfig));
ImmutableSet<Description<?>> allDescriptions = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(projectFilesystem, environment).getAllDescriptions();
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance();
MissingSymbolsHandler missingSymbolsHandler = MissingSymbolsHandler.create(projectFilesystem, allDescriptions, config, buckEventBus, new TestConsole(), DEFAULT_JAVAC_OPTIONS, environment);
MissingSymbolEvent missingSymbolEvent = MissingSymbolEvent.create(BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/b:b"), "com.example.a.A", MissingSymbolEvent.SymbolType.Java);
ImmutableSetMultimap<BuildTarget, BuildTarget> neededDeps = missingSymbolsHandler.getNeededDependencies(ImmutableList.of(missingSymbolEvent));
assertEquals("MissingSymbolsHandler failed to find the needed dependency.", neededDeps, ImmutableSetMultimap.of(BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/b:b"), BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/a:a")));
}
use of com.facebook.buck.rules.Description in project buck by facebook.
the class JavaSymbolFinderIntegrationTest method shouldFindTargetDefiningSymbol.
@Test
public void shouldFindTargetDefiningSymbol() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symbol_finder", temporaryFolder);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, String> environment = ImmutableMap.copyOf(System.getenv());
Config rawConfig = Configs.createDefaultConfig(projectFilesystem.getRootPath());
BuckConfig config = new BuckConfig(rawConfig, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), rawConfig));
ParserConfig parserConfig = config.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(config, new ExecutableFinder());
ImmutableSet<Description<?>> allDescriptions = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(projectFilesystem, environment).getAllDescriptions();
SrcRootsFinder srcRootsFinder = new SrcRootsFinder(projectFilesystem);
ProjectBuildFileParserFactory projectBuildFileParserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(projectFilesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(projectFilesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(allDescriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance();
JavaSymbolFinder finder = new JavaSymbolFinder(projectFilesystem, srcRootsFinder, DEFAULT_JAVAC_OPTIONS, new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), projectBuildFileParserFactory, config, buckEventBus, new TestConsole(), environment);
SetMultimap<String, BuildTarget> foundTargets = finder.findTargetsForSymbols(ImmutableSet.of("com.example.a.A"));
assertEquals("JavaSymbolFinder failed to find the right target.", ImmutableSetMultimap.of("com.example.a.A", BuildTargetFactory.newInstance(projectFilesystem, "//java/com/example/a:a")), foundTargets);
}
use of com.facebook.buck.rules.Description in project buck by facebook.
the class TargetsCommand method getDescriptionClassFromParams.
@SuppressWarnings("unchecked")
private Optional<ImmutableSet<Class<? extends Description<?>>>> getDescriptionClassFromParams(CommandRunnerParams params) {
ImmutableSet<String> types = getTypes();
ImmutableSet.Builder<Class<? extends Description<?>>> descriptionClassesBuilder = ImmutableSet.builder();
for (String name : types) {
try {
BuildRuleType type = params.getCell().getBuildRuleType(name);
Description<?> description = params.getCell().getDescription(type);
descriptionClassesBuilder.add((Class<? extends Description<?>>) description.getClass());
} catch (IllegalArgumentException e) {
params.getBuckEventBus().post(ConsoleEvent.severe("Invalid build rule type: " + name));
return Optional.empty();
}
}
return Optional.of(descriptionClassesBuilder.build());
}
use of com.facebook.buck.rules.Description in project buck by facebook.
the class ResolverIntegrationTest method createParser.
@BeforeClass
public static void createParser() {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuckConfig buckConfig = FakeBuckConfig.builder().build();
ParserConfig parserConfig = buckConfig.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(buckConfig, new ExecutableFinder());
ImmutableSet<Description<?>> descriptions = ImmutableSet.of(new RemoteFileDescription(new ExplodingDownloader()), new PrebuiltJarDescription());
DefaultProjectBuildFileParserFactory parserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(filesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(filesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(descriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
buildFileParser = parserFactory.createParser(new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), new TestConsole(), ImmutableMap.of(), BuckEventBusFactory.newInstance(), /* ignoreBuckAutodepsFiles */
false);
}
Aggregations