public void discoverAndAppendTo(@NotNull DataNode<ProjectData> mainBuildProjectDataNode) {
    Index index = prepareIndexes(mainBuildProjectDataNode);

    List<String> jvmOptions = new SmartList<>();
    // the BuildEnvironment jvm arguments of the main build should be used for the 'buildSrc' import
    // to avoid spawning of the second gradle daemon
    BuildEnvironment mainBuildEnvironment = myResolverContext.getBuildEnvironment();
    if (mainBuildEnvironment != null) {
      jvmOptions.addAll(mainBuildEnvironment.getJava().getJvmArguments());
    }
    GradleExecutionSettings mainBuildExecutionSettings = myResolverContext.getSettings();
    if (mainBuildExecutionSettings != null) {
      jvmOptions.addAll(mainBuildExecutionSettings.getJvmArguments());
    }

    for (GradleLightBuild build : myResolverContext.getAllBuilds()) {
      String buildPath = FileUtil.toSystemIndependentName(build.getBuildIdentifier().getRootDir().getPath());

      GradleExecutionSettings buildSrcProjectSettings;
      if (myGradleHome != null) {
        if (mainBuildExecutionSettings != null) {
          buildSrcProjectSettings = new GradleExecutionSettings(
            myGradleHome,
            mainBuildExecutionSettings.getServiceDirectory(),
            DistributionType.LOCAL,
            mainBuildExecutionSettings.isOfflineWork()
          );
          buildSrcProjectSettings.setIdeProjectPath(mainBuildExecutionSettings.getIdeProjectPath());
          buildSrcProjectSettings.setJavaHome(mainBuildExecutionSettings.getJavaHome());
          buildSrcProjectSettings.setResolveModulePerSourceSet(mainBuildExecutionSettings.isResolveModulePerSourceSet());
          buildSrcProjectSettings.setUseQualifiedModuleNames(mainBuildExecutionSettings.isUseQualifiedModuleNames());
          buildSrcProjectSettings.setRemoteProcessIdleTtlInMs(mainBuildExecutionSettings.getRemoteProcessIdleTtlInMs());
          buildSrcProjectSettings.setVerboseProcessing(mainBuildExecutionSettings.isVerboseProcessing());
          buildSrcProjectSettings.setWrapperPropertyFile(mainBuildExecutionSettings.getWrapperPropertyFile());
          buildSrcProjectSettings.setDownloadSources(mainBuildExecutionSettings.isDownloadSources());
          buildSrcProjectSettings.setParallelModelFetch(mainBuildExecutionSettings.isParallelModelFetch());
          buildSrcProjectSettings.setDelegatedBuild(mainBuildExecutionSettings.isDelegatedBuild());
          buildSrcProjectSettings.withArguments(mainBuildExecutionSettings.getArguments());
          buildSrcProjectSettings.withEnvironmentVariables(mainBuildExecutionSettings.getEnv());
          buildSrcProjectSettings.passParentEnvs(mainBuildExecutionSettings.isPassParentEnvs());
          buildSrcProjectSettings.withVmOptions(jvmOptions);
          reuseTargetEnvironmentConfigurationProvider(buildSrcProjectSettings, mainBuildExecutionSettings);
        }
        else {
          buildSrcProjectSettings = new GradleExecutionSettings(myGradleHome, null, DistributionType.LOCAL, false);
        }
        includeRootBuildIncludedBuildsIfNeeded(buildSrcProjectSettings, index.compositeBuildData(), buildPath);
      }
      else {
        buildSrcProjectSettings = mainBuildExecutionSettings;
      }

      final String buildSrcProjectPath = buildPath + "/buildSrc";
      DefaultProjectResolverContext buildSrcResolverCtx = new DefaultProjectResolverContext(
        myResolverContext, buildSrcProjectPath, buildSrcProjectSettings
      );
      String buildName = index.buildNames().get(buildPath);

      String buildSrcGroup = getBuildSrcGroup(buildPath, buildName);

      buildSrcResolverCtx.setBuildSrcGroup(buildSrcGroup);
      handleBuildSrcProject(mainBuildProjectDataNode,
                            buildName,
                            index.buildClasspathNodesMap().getModifiable(Paths.get(buildPath)),
                            index.includedModulesPaths(),
                            buildSrcResolverCtx,
                            myProjectResolver.getProjectDataFunction(buildSrcResolverCtx, myResolverChain, true));
    }
  }
public void discoverAndAppendTo(@NotNull DataNode<ProjectData> mainBuildProjectDataNode)