public List<Map<String, Object>> parseBuildFile(File buildFile, Iterable<String> defaultIncludes) throws BuildFileParseException, BuildTargetException, IOException { ProjectBuildFileParser projectBuildFileParser = buildFileParserFactory.createParser(defaultIncludes); return parseBuildFile(buildFile, defaultIncludes, projectBuildFileParser); }
/** * @param buildTargets the build targets to generate a dependency graph for. * @param defaultIncludes the files to include before executing build files. * @param eventBus used to log events while parsing. * @return the dependency graph containing the build targets and their related targets. */ public DependencyGraph parseBuildFilesForTargets( Iterable<BuildTarget> buildTargets, Iterable<String> defaultIncludes, BuckEventBus eventBus) throws BuildFileParseException, BuildTargetException, IOException { // Make sure that knownBuildTargets is initially populated with the BuildRuleBuilders for the // seed BuildTargets for the traversal. eventBus.post(ParseEvent.started(buildTargets)); DependencyGraph graph = null; try (ProjectBuildFileParser buildFileParser = buildFileParserFactory.createParser(defaultIncludes)) { if (!isCacheComplete(defaultIncludes)) { Set<File> buildTargetFiles = Sets.newHashSet(); for (BuildTarget buildTarget : buildTargets) { File buildFile = buildTarget.getBuildFile(projectFilesystem); boolean isNewElement = buildTargetFiles.add(buildFile); if (isNewElement) { parseBuildFile(buildFile, defaultIncludes, buildFileParser); } } } graph = findAllTransitiveDependencies(buildTargets, defaultIncludes, buildFileParser); return graph; } finally { eventBus.post(ParseEvent.finished(buildTargets, Optional.fromNullable(graph))); } }
@VisibleForTesting DependencyGraph onlyUseThisWhenTestingToFindAllTransitiveDependencies( Iterable<BuildTarget> toExplore, final Iterable<String> defaultIncludes) throws IOException { ProjectBuildFileParser parser = buildFileParserFactory.createParser(defaultIncludes); return findAllTransitiveDependencies(toExplore, defaultIncludes, parser); }