private static List<String> findTargetMavenHomes(@NotNull Project project, @Nullable String targetName) {
    List<String> mavenHomes;
    boolean localTarget = targetName == null;
    if (localTarget) {
      mavenHomes = new ArrayList<>();
      MavenUtil.getSystemMavenHomeVariants().forEach(it -> {
        mavenHomes.add(it.getTitle());
      });
    }
    else {
      TargetEnvironmentConfiguration targetEnvironmentConfiguration =
        TargetEnvironmentsManager.getInstance(project).getTargets().findByName(targetName);
      if (targetEnvironmentConfiguration != null) {
        mavenHomes = targetEnvironmentConfiguration.getRuntimes().resolvedConfigs().stream()
          .filter(runtimeConfiguration -> runtimeConfiguration instanceof MavenRuntimeTargetConfiguration)
          .map(runtimeConfiguration -> ((MavenRuntimeTargetConfiguration)runtimeConfiguration).getHomePath())
          .collect(Collectors.toList());
      }
      else {
        mavenHomes = new ArrayList<>();
      }
    }
    return mavenHomes;
  }
private static List<String> findTargetMavenHomes(@NotNull Project project, @Nullable String targetName)