From 0c8799f1ea1fcdbff393b350bcfe54022f3958df Mon Sep 17 00:00:00 2001 From: Daniel Beck <1831569+daniel-beck@users.noreply.github.com> Date: Fri, 12 Aug 2022 11:07:51 +0200 Subject: [PATCH] Print the core dependency version (#612) * Print the core dependency version * Restyle a bit, make compile * Add CSP Co-authored-by: Daniel Beck --- resources/index-template.html | 7 +++++++ .../update_center/IndexHtmlBuilder.java | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/resources/index-template.html b/resources/index-template.html index cfee58a6e..aae7beab5 100644 --- a/resources/index-template.html +++ b/resources/index-template.html @@ -2,6 +2,7 @@ {{ title }} + diff --git a/src/main/java/io/jenkins/update_center/IndexHtmlBuilder.java b/src/main/java/io/jenkins/update_center/IndexHtmlBuilder.java index 0286374d7..be64df4ae 100644 --- a/src/main/java/io/jenkins/update_center/IndexHtmlBuilder.java +++ b/src/main/java/io/jenkins/update_center/IndexHtmlBuilder.java @@ -47,9 +47,9 @@ public class IndexHtmlBuilder implements Closeable { private final String template; private final String title; private String subtitle; - private String description; - private StringBuilder content; - private String opengraphImage; + private final String description; + private final StringBuilder content; + private final String opengraphImage; public IndexHtmlBuilder(File dir, String title, String globalTemplate) throws IOException { this.out = openIndexHtml(dir); @@ -89,14 +89,18 @@ public void add(MavenArtifact a) throws IOException { if (artifactMetadata == null) { return; } - add(a.getDownloadUrl().getPath(), a.getTimestampAsDate(), a.version, artifactMetadata); + if (a instanceof HPI) { + add(a.getDownloadUrl().getPath(), a.getTimestampAsDate(), a.version, artifactMetadata, ((HPI) a).getRequiredJenkinsVersion()); + } else { + add(a.getDownloadUrl().getPath(), a.getTimestampAsDate(), a.version, artifactMetadata, null); + } } public void add(String url, String caption) { - add(url, null, caption, null); + add(url, null, caption, null, null); } - public void add(String url, Date releaseDate, String caption, MavenRepository.ArtifactMetadata metadata) { + public void add(String url, Date releaseDate, String caption, MavenRepository.ArtifactMetadata metadata, String requiredJenkinsVersion) { String releaseDateString = ""; if (releaseDate != null) { releaseDateString = " Released: " + SimpleDateFormat.getDateInstance().format(releaseDate); @@ -115,6 +119,9 @@ public void add(String url, Date releaseDate, String caption, MavenRepository.Ar .append(base64ToHex(metadata.sha256)).append(""); } } + if (requiredJenkinsVersion != null) { + content.append("\n
Requires Jenkins ").append(requiredJenkinsVersion).append("
"); + } content.append("\n"); }