private static @NotNull Path locateProjectHome(@NotNull Path baseDir) {
    String explicitHomePath = System.getProperty("idea.home.path");
    if (explicitHomePath != null) {
      return Path.of(explicitHomePath);
    }
    
    /* This part is used when the process is started locally from sources (when tests are started from the build scripts, the home path
       is specified explicitly via property). 
       It's supposed to 'baseDir' refers to the main repository located under <project-home>/out/classes. */
    Path currentPath = baseDir;
    while (currentPath != null && !isProjectHome(currentPath)) {
      currentPath = currentPath.getParent();
    }
    if (currentPath == null) {
      throw new MalformedRepositoryException("Cannot find project home to resolve " + PROJECT_DIR_MACRO + " macro, starting from " + baseDir);
    }
    return currentPath.toAbsolutePath();
  }
private static @NotNull Path locateProjectHome(@NotNull Path baseDir)