private static void addJavaCompilerOptions(
    @NotNull DefaultExternalSourceSet externalSourceSet, // mutable
    @NotNull Project project,
    @NotNull SourceSet sourceSet,
    @NotNull GradleSourceSetResolutionContext sourceSetResolutionContext
  ) {
    Task javaCompileTask = project.getTasks().findByName(sourceSet.getCompileJavaTaskName());
    if (javaCompileTask instanceof JavaCompile) {
      JavaCompile javaCompile = (JavaCompile)javaCompileTask;
      externalSourceSet.setJavaToolchainHome(getJavaToolchainHome(project, javaCompile));
      externalSourceSet.setSourceCompatibility(javaCompile.getSourceCompatibility());
      externalSourceSet.setPreview(javaCompile.getOptions().getCompilerArgs().contains("--enable-preview"));
      externalSourceSet.setTargetCompatibility(javaCompile.getTargetCompatibility());
    }
    if (externalSourceSet.getSourceCompatibility() == null) {
      externalSourceSet.setSourceCompatibility(sourceSetResolutionContext.projectSourceCompatibility);
    }
    if (externalSourceSet.getSourceCompatibility() == null) {
      externalSourceSet.setTargetCompatibility(sourceSetResolutionContext.projectTargetCompatibility);
    }
  }
private static void addJavaCompilerOptions(
    @NotNull DefaultExternalSourceSet externalSourceSet, // mutable
    @NotNull Project project,
    @NotNull SourceSet sourceSet,
    @NotNull GradleSourceSetResolutionContext sourceSetResolutionContext
  )