Search in sources :

Example 1 with IntellijConfig

use of com.facebook.buck.jvm.java.intellij.IntellijConfig in project buck by facebook.

the class ProjectCommand method runDeprecatedIntellijProjectGenerator.

private int runDeprecatedIntellijProjectGenerator(CommandRunnerParams params, TargetGraph projectGraph, TargetGraphAndTargets targetGraphAndTargets, ImmutableSet<BuildTarget> passedInTargetsSet) throws IOException, InterruptedException {
    // Create an ActionGraph that only contains targets that can be represented as IDE
    // configuration files.
    ActionGraphAndResolver result = Preconditions.checkNotNull(ActionGraphCache.getFreshActionGraph(params.getBuckEventBus(), targetGraphAndTargets.getTargetGraph()));
    try (ExecutionContext executionContext = createExecutionContext(params)) {
        Project project = new Project(new SourcePathResolver(new SourcePathRuleFinder(result.getResolver())), FluentIterable.from(result.getActionGraph().getNodes()).filter(ProjectConfig.class).toSortedSet(Ordering.natural()), getBasePathToAliasMap(params.getBuckConfig()), getJavaPackageFinder(params.getBuckConfig()), executionContext, new FilesystemBackedBuildFileTree(params.getCell().getFilesystem(), params.getBuckConfig().getView(ParserConfig.class).getBuildFileName()), params.getCell().getFilesystem(), getPathToDefaultAndroidManifest(params.getBuckConfig()), new IntellijConfig(params.getBuckConfig()), getPathToPostProcessScript(params.getBuckConfig()), new PythonBuckConfig(params.getBuckConfig(), new ExecutableFinder()).getPythonInterpreter(), params.getObjectMapper(), isAndroidAutoGenerateDisabled(params.getBuckConfig()));
        File tempDir = Files.createTempDir();
        File tempFile = new File(tempDir, "project.json");
        int exitCode;
        try {
            exitCode = project.createIntellijProject(tempFile, executionContext.getProcessExecutor(), !passedInTargetsSet.isEmpty(), params.getConsole().getStdOut(), params.getConsole().getStdErr());
            if (exitCode != 0) {
                return exitCode;
            }
            List<String> additionalInitialTargets = ImmutableList.of();
            if (shouldProcessAnnotations()) {
                additionalInitialTargets = getAnnotationProcessingTargets(projectGraph, passedInTargetsSet);
            }
            // Build initial targets.
            if (hasInitialTargets(params.getBuckConfig()) || !additionalInitialTargets.isEmpty()) {
                BuildCommand buildCommand = createBuildCommandOptionsWithInitialTargets(params.getBuckConfig(), additionalInitialTargets);
                buildCommand.setArtifactCacheDisabled(true);
                exitCode = buildCommand.runWithoutHelp(params);
                if (exitCode != 0) {
                    return exitCode;
                }
            }
        } finally {
            // Either leave project.json around for debugging or delete it on exit.
            if (params.getConsole().getVerbosity().shouldPrintOutput()) {
                params.getConsole().getStdErr().printf("project.json was written to %s", tempFile.getAbsolutePath());
            } else {
                tempFile.delete();
                tempDir.delete();
            }
        }
        if (passedInTargetsSet.isEmpty()) {
            String greenStar = params.getConsole().getAnsi().asHighlightedSuccessText(" * ");
            params.getConsole().getStdErr().printf(params.getConsole().getAnsi().asHighlightedSuccessText("=== Did you know ===") + "\n" + greenStar + "You can run `buck project <target>` to generate a minimal project " + "just for that target.\n" + greenStar + "This will make your IDE faster when working on large projects.\n" + greenStar + "See buck project --help for more info.\n" + params.getConsole().getAnsi().asHighlightedSuccessText("--=* Knowing is half the battle!") + "\n");
        }
        return 0;
    }
}
Also used : PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) IntellijConfig(com.facebook.buck.jvm.java.intellij.IntellijConfig) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) IjProject(com.facebook.buck.jvm.java.intellij.IjProject) Project(com.facebook.buck.jvm.java.intellij.Project) FilesystemBackedBuildFileTree(com.facebook.buck.model.FilesystemBackedBuildFileTree) ExecutionContext(com.facebook.buck.step.ExecutionContext) ActionGraphAndResolver(com.facebook.buck.rules.ActionGraphAndResolver) File(java.io.File) ParserConfig(com.facebook.buck.parser.ParserConfig)

Aggregations

ExecutableFinder (com.facebook.buck.io.ExecutableFinder)1 IjProject (com.facebook.buck.jvm.java.intellij.IjProject)1 IntellijConfig (com.facebook.buck.jvm.java.intellij.IntellijConfig)1 Project (com.facebook.buck.jvm.java.intellij.Project)1 FilesystemBackedBuildFileTree (com.facebook.buck.model.FilesystemBackedBuildFileTree)1 ParserConfig (com.facebook.buck.parser.ParserConfig)1 PythonBuckConfig (com.facebook.buck.python.PythonBuckConfig)1 ActionGraphAndResolver (com.facebook.buck.rules.ActionGraphAndResolver)1 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)1 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)1 ExecutionContext (com.facebook.buck.step.ExecutionContext)1 File (java.io.File)1