Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade PlantUML to 1.2025.0 #1830

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_store
target/
/.registry/oci/*
*.iml
Expand Down
4 changes: 2 additions & 2 deletions docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ asciidoc:
blockdiag-version: 3.1.0
bpmn-version: 18.0.0
bytefield-version: 1.10.0
c4plantuml-version: 1.2024.1
c4plantuml-version: 1.2025.0
d2-version: 0.6.3
dbml-version: 1.0.30
diagramsnet-version: 16.2.4
Expand All @@ -20,7 +20,7 @@ asciidoc:
nwdiag-version: 3.1.0
packetdiag-version: 3.1.0
pikchr-version: '7269f78c4a'
plantuml-version: 1.2024.1
plantuml-version: 1.2025.0
rackdiag-version: 3.1.0
seqdiag-version: 3.1.0
structurizr-version: 3.0.0
Expand Down
2 changes: 1 addition & 1 deletion server/ops/docker/jdk17-noble/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ ARG D2_VERSION="0.6.3"
ARG DITAA_VERSION="1.0.3"
ARG DVISVGM_VERSION="3.2.1+ds-1build1"
ARG GRAPHVIZ_VERSION="9.0.0"
ARG PLANTUML_VERSION="1.2024.1"
ARG PLANTUML_VERSION="1.2025.0"
ARG UMLET_VERSION="2023-03-20_UMLet_v15.1"
ARG WIREVIZ_VERSION="0.3.3"
ARG TARGETARCH
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/io/kroki/server/service/Plantuml.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public SourceDecoder getSourceDecoder() {

@Override
public String getVersion() {
return "1.2024.1";
return "1.2025.0";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DownloadDitaaNativeImage {
public static Future<DitaaCommand> download(Vertx vertx) {
String ditaaVersion = new Ditaa(vertx, new JsonObject()).getVersion();
String downloadUrl = "https://github.com/yuzutech/ditaa-mini/releases/download/" + ditaaVersion + "/ditaamini-linux-amd64-" + ditaaVersion;
return DownloadNativeImage.download(vertx, downloadUrl, "Ditaa", "ditaamini-linux-amd64-" + ditaaVersion).map(ditaaBinPath -> {
return DownloadNativeImage.download(vertx, downloadUrl, "Ditaa", "ditaamini-linux-amd64-" + ditaaVersion, "ditaamini-linux-amd64-" + ditaaVersion).map(ditaaBinPath -> {
JsonObject options = new JsonObject();
options.put("KROKI_DITAA_BIN_PATH", ditaaBinPath);
return new DitaaCommand(options);
Expand Down
60 changes: 54 additions & 6 deletions server/src/test/java/io/kroki/server/DownloadNativeImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class DownloadNativeImage {

public static Future<String> download(Vertx vertx, String downloadUrl, String commandName, String nativeImageName) {
public static Future<String> download(Vertx vertx, String downloadUrl, String commandName, String downloadFileName, String nativeImageName) {
String binPathOptionName = "KROKI_" + commandName.toUpperCase() + "_BIN_PATH";
String binPath = System.getenv(binPathOptionName);
if (binPath != null && !binPath.isBlank()) {
Expand Down Expand Up @@ -56,12 +56,16 @@ public static Future<String> download(Vertx vertx, String downloadUrl, String co
return Future.failedFuture(new IllegalAccessError("Request failed with status code " + statusCode + " and message " + bufferHttpResponse.statusMessage()));
}
try {
File nativeFile = nativePath.toFile();
try (FileOutputStream fos = new FileOutputStream(nativeFile)) {
Path downloadFilePath = Paths.get(buildDirectory, downloadFileName);
try (FileOutputStream fos = new FileOutputStream(downloadFilePath.toFile())) {
fos.write(bufferHttpResponse.body().getBytes());
} catch (IOException e) {
return Future.failedFuture(e);
}
if (downloadFileName.endsWith(".zip")) {
unzipFile(downloadFilePath, Paths.get(buildDirectory));
}
File nativeFile = nativePath.toFile();
boolean result = nativeFile.setExecutable(true);
if (!result) {
return Future.failedFuture(new IllegalAccessError("Unable to make " + nativeFile + " executable!"));
Expand All @@ -73,4 +77,48 @@ public static Future<String> download(Vertx vertx, String downloadUrl, String co
}
});
}

private static void unzipFile(Path zipFile, Path targetDirectory) throws IOException {
byte[] buffer = new byte[1024];
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile.toFile()));
ZipEntry zipEntry = zis.getNextEntry();
while (zipEntry != null) {
File newFile = newFile(targetDirectory.toFile(), zipEntry);
if (zipEntry.isDirectory()) {
if (!newFile.isDirectory() && !newFile.mkdirs()) {
throw new IOException("Failed to create directory " + newFile);
}
} else {
// fix for Windows-created archives
File parent = newFile.getParentFile();
if (!parent.isDirectory() && !parent.mkdirs()) {
throw new IOException("Failed to create directory " + parent);
}

// write file content
FileOutputStream fos = new FileOutputStream(newFile);
int len;
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
fos.close();
}
zipEntry = zis.getNextEntry();
}
zis.closeEntry();
zis.close();
}

private static File newFile(File destinationDir, ZipEntry zipEntry) throws IOException {
File destFile = new File(destinationDir, zipEntry.getName());

String destDirPath = destinationDir.getCanonicalPath();
String destFilePath = destFile.getCanonicalPath();

if (!destFilePath.startsWith(destDirPath + File.separator)) {
throw new IOException("Entry is outside of the target dir: " + zipEntry.getName());
}

return destFile;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,50 @@ public class DownloadPlantumlNativeImage {

public static Future<PlantumlCommand> download(Vertx vertx) {
String plantumlVersion = new Plantuml(vertx, new JsonObject()).getVersion();
String downloadUrl = "https://github.com/yuzutech/plantuml/releases/download/v" + plantumlVersion + "/plantuml-linux-amd64-" + plantumlVersion;
return DownloadNativeImage.download(vertx, downloadUrl, "PlantUML", "plantuml-linux-amd64-" + plantumlVersion).map(plantumlBinPath -> {
String os = getOperatingSystemName();
String arch = getArch();
String zipName = "plantuml-" + os + "-" + arch + "-" + plantumlVersion + ".zip";
String binaryExtension = getBinaryExtension(os);
String binaryName = "plantuml-" + os + "-" + arch + "-" + plantumlVersion + binaryExtension;
String downloadUrl = "https://github.com/yuzutech/plantuml/releases/download/v1.2025.0/" + zipName;
return DownloadNativeImage.download(vertx, downloadUrl, "PlantUML", zipName, binaryName).map(plantumlBinPath -> {
JsonObject options = new JsonObject();
options.put("KROKI_PLANTUML_BIN_PATH", plantumlBinPath);
return new PlantumlCommand(options);
});
}

private static String getBinaryExtension(String os) {
String binaryExtension;
if (os.equals("win")) {
binaryExtension = ".exe";
} else {
binaryExtension = "";
}
return binaryExtension;
}

private static String getArch() {
String osArch = System.getProperty("os.arch");
String arch;
if (osArch.contains("aarch64")) {
arch = "arm64";
} else {
arch = "amd64";
}
return arch;
}

private static String getOperatingSystemName() {
String osName = System.getProperty("os.name");
String os;
if (osName.startsWith("Mac OS")) {
os = "darwin";
} else if (osName.startsWith("Windows")) {
os = "win";
} else {
os = "linux";
}
return os;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void should_throw_exception_when_unknown_output_specified() throws IOExce
public void should_preserve_styles_defined_in_workspace_while_applying_theme() throws IOException, InterruptedException {
String source = read("./workspace-style-with-theme.structurizr");
byte[] convert = Structurizr.convert(source, FileFormat.SVG, plantumlCommand, new StructurizrPlantUMLExporter(), SafeMode.SAFE, new JsonObject());
assertThat(new String(convert)).isEqualTo(read("./workspace-style-with-theme.svg"));
assertThat(stripComments(new String(convert))).isEqualTo(read("./workspace-style-with-theme.svg"));
}

private String stripComments(String xmlContent) {
Expand Down
2 changes: 1 addition & 1 deletion server/src/test/resources/bigbank.containers.expected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion server/src/test/resources/docs.expected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading