static Path generateVersionIndex()

in dashboard/src/main/java/com/google/cloud/tools/opensource/dashboard/DashboardMain.java [150:171]


  static Path generateVersionIndex(String groupId, String artifactId, List<String> versions)
      throws IOException, TemplateException, URISyntaxException {
    Path directory = outputDirectory(groupId, artifactId, "snapshot").getParent();
    directory.toFile().mkdirs();
    Path page = directory.resolve("index.html");

    Map<String, Object> templateData = new HashMap<>();
    templateData.put("versions", versions);
    templateData.put("groupId", groupId);
    templateData.put("artifactId", artifactId);

    File dashboardFile = page.toFile();
    try (Writer out =
        new OutputStreamWriter(new FileOutputStream(dashboardFile), StandardCharsets.UTF_8)) {
      Template dashboard = freemarkerConfiguration.getTemplate("/templates/version_index.ftl");
      dashboard.process(templateData, out);
    }

    copyResource(directory, "css/dashboard.css");

    return page;
  }