private static CompileScope createScope(CompilerManager compilerManager,
                                          ProjectTaskContext context,
                                          Collection<? extends Module> modules,
                                          boolean includeDependentModules,
                                          boolean includeRuntimeDependencies,
                                          boolean includeTests) {
    CompileScope scope = !modules.isEmpty()?
      compilerManager.createModulesCompileScope(modules.toArray(Module.EMPTY_ARRAY), includeDependentModules, includeRuntimeDependencies, includeTests):
      new CompositeScope(CompileScope.EMPTY_ARRAY);

    if (context.isAutoRun()) {
      CompileDriver.setCompilationStartedAutomatically(scope);
    }

    RunConfiguration configuration = context.getRunConfiguration();
    if (configuration != null) {
      scope.putUserData(CompilerManager.RUN_CONFIGURATION_KEY, configuration);
      scope.putUserData(CompilerManager.RUN_CONFIGURATION_TYPE_ID_KEY, configuration.getType().getId());
    }
    ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.set(scope, context.getSessionId());
    return scope;
  }
private static CompileScope createScope(CompilerManager compilerManager,
                                          ProjectTaskContext context,
                                          Collection<? extends Module> modules,
                                          boolean includeDependentModules,
                                          boolean includeRuntimeDependencies,
                                          boolean includeTests)