diff --git a/benchmark/pom.xml b/benchmark/pom.xml index d73a1116a7..660ae0d508 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -99,24 +99,9 @@ freemarker - - org.webjars - webjars-locator - ai.timefold.solver timefold-solver-webui - runtime - - - org.webjars - bootstrap - runtime - - - org.webjars - jquery - runtime @@ -242,11 +227,8 @@ maven-dependency-plugin - - org.webjars:*:jar - - org.webjars:*:jar + ai.timefold.solver:timefold-solver-webui:jar diff --git a/benchmark/src/main/java/ai/timefold/solver/benchmark/impl/report/WebsiteResourceUtils.java b/benchmark/src/main/java/ai/timefold/solver/benchmark/impl/report/WebsiteResourceUtils.java index dedebaf677..ae215a3a04 100644 --- a/benchmark/src/main/java/ai/timefold/solver/benchmark/impl/report/WebsiteResourceUtils.java +++ b/benchmark/src/main/java/ai/timefold/solver/benchmark/impl/report/WebsiteResourceUtils.java @@ -1,64 +1,25 @@ package ai.timefold.solver.benchmark.impl.report; -import static java.util.Collections.emptySet; -import static java.util.Map.entry; -import static java.util.Set.of; - import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; -import java.util.Map; -import java.util.Set; - -import org.webjars.WebJarAssetLocator; +import java.util.function.Function; public final class WebsiteResourceUtils { private static final String RESOURCE_NAMESPACE = "/ai/timefold/solver/benchmark/impl/report/"; + private static final String WEBJAR_RESOURCE_NAMESPACE = "META-INF/resources/webjars/timefold/"; public static void copyResourcesTo(File benchmarkReportDirectory) { - /* - * Describe which webjar resources we need. - * Otherwise the report would be dozens of megabytes in size. - */ - Map> webjarToResourceMap = Map.ofEntries( - entry("timefold", - emptySet()), - entry("bootstrap", - of("css/bootstrap.min.css", "js/bootstrap.bundle.min.js")), - entry("font-awesome", - of("css/all.min.css", "sprites/brands.svg", "sprites/solid.svg")), - entry("jquery", - of("jquery.min.js"))); - // Extract webjars. - File webjarDirectory = new File(benchmarkReportDirectory, "website/webjars/"); - new WebJarAssetLocator() - .getAllWebJars() - .forEach((artifactId, webjarInfo) -> { - if (!webjarToResourceMap.containsKey(artifactId)) { - return; - } - // The webjarInfo typically contains the version, but we don't want to use it in the path. - String resourcePrefix = "META-INF/resources/webjars/" + artifactId + "/"; - String resourcePrefixWithVersion = resourcePrefix + webjarInfo.getVersion() + "/"; - File webjarTargetDirectory = new File(webjarDirectory, artifactId); - webjarInfo.getContents().forEach(resource -> { - Set resourceSet = webjarToResourceMap.get(artifactId); // Empty means all resources. - /* - * Some webjars do not have a version in the resource path. - * Case in point: the Timefold webjar. - */ - String actualResourcePrefix = - resource.startsWith(resourcePrefixWithVersion) ? resourcePrefixWithVersion : resourcePrefix; - if (resourceSet.isEmpty() || resourceSet.stream().anyMatch(resource::endsWith)) { - // Only copy the resources we need. - String relativePath = resource.substring(actualResourcePrefix.length()); - copyResource(webjarTargetDirectory, "/", resource, relativePath); - } - }); - }); - // Manually copy some additional resources. + // Manually extract webjars, as webjar-locator had issues with Quarkus. + copyWebjarResource(benchmarkReportDirectory, "css/timefold-webui.css"); + copyWebjarResource(benchmarkReportDirectory, "js/timefold-webui.js"); + copyWebjarResource(benchmarkReportDirectory, "img/timefold-favicon.svg"); + copyWebjarResource(benchmarkReportDirectory, "img/timefold-logo-horizontal-negative.svg"); + copyWebjarResource(benchmarkReportDirectory, "img/timefold-logo-horizontal-positive.svg"); + copyWebjarResource(benchmarkReportDirectory, "img/timefold-logo-stacked-positive.svg"); + // Manually copy some other resources. copyResource(benchmarkReportDirectory, "website/css/prettify.css"); copyResource(benchmarkReportDirectory, "website/css/app.css"); copyResource(benchmarkReportDirectory, "website/js/chartjs-plugin-watermark.js"); @@ -66,27 +27,29 @@ public static void copyResourcesTo(File benchmarkReportDirectory) { copyResource(benchmarkReportDirectory, "website/js/app.js"); } - private static void copyResource(File benchmarkReportDirectory, String websiteResource) { - copyResource(benchmarkReportDirectory, websiteResource, websiteResource); + private static void copyWebjarResource(File benchmarkReportDirectory, String websiteResource) { + copyResource(benchmarkReportDirectory, WEBJAR_RESOURCE_NAMESPACE, websiteResource, "website/" + websiteResource, + s -> WebsiteResourceUtils.class.getClassLoader().getResourceAsStream(s)); } - private static void copyResource(File benchmarkReportDirectory, String websiteResource, String targetResource) { - copyResource(benchmarkReportDirectory, RESOURCE_NAMESPACE, websiteResource, targetResource); + private static void copyResource(File benchmarkReportDirectory, String websiteResource) { + copyResource(benchmarkReportDirectory, RESOURCE_NAMESPACE, websiteResource, websiteResource, + WebsiteResourceUtils.class::getResourceAsStream); } private static void copyResource(File benchmarkReportDirectory, String namespace, String websiteResource, - String targetResource) { - File outputFile = new File(benchmarkReportDirectory, targetResource); + String targetResource, Function resourceLoader) { + var outputFile = new File(benchmarkReportDirectory, targetResource); outputFile.getParentFile().mkdirs(); - try (InputStream in = WebsiteResourceUtils.class.getResourceAsStream(namespace + websiteResource)) { + try (var in = resourceLoader.apply(namespace + websiteResource)) { if (in == null) { - throw new IllegalStateException("The websiteResource (" + websiteResource - + ") does not exist."); + throw new IllegalStateException("The websiteResource (%s) does not exist." + .formatted(websiteResource)); } Files.copy(in, outputFile.toPath()); } catch (IOException e) { - throw new IllegalStateException("Could not copy websiteResource (" + websiteResource - + ") to outputFile (" + outputFile + ").", e); + throw new IllegalStateException("Could not copy websiteResource (%s) to outputFile (%s)." + .formatted(websiteResource, outputFile), e); } } diff --git a/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/benchmarkReport.html.ftl b/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/benchmarkReport.html.ftl index 5e86ae8022..f2a26dbfb7 100644 --- a/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/benchmarkReport.html.ftl +++ b/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/benchmarkReport.html.ftl @@ -6,20 +6,20 @@ ${benchmarkReport.plannerBenchmarkResult.name} Planner benchmark report - - + + - - + + - <#-- Too large for a webjar. --> + <#-- Contains functions called by chart.js; must go first. --> - - <#-- Includes Popper for dropdowns. --> - + + <#-- Includes Popper for dropdowns. --> + @@ -92,7 +92,7 @@
- Timefold Logo (horizontal, negative) + Timefold Logo (horizontal, negative)
Benchmark Report diff --git a/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/shared-watermark.js.ftl b/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/shared-watermark.js.ftl index 3a0f1c34d2..d122f71289 100644 --- a/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/shared-watermark.js.ftl +++ b/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/shared-watermark.js.ftl @@ -1,5 +1,5 @@ watermark: { - image: "website/webjars/timefold/img/timefold-logo-stacked-positive.svg", + image: "website/img/timefold-logo-stacked-positive.svg", x: 15, y: 15, width: 48, diff --git a/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/website/img/timefold-logo-horizontal-negative.svg b/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/website/img/timefold-logo-horizontal-negative.svg deleted file mode 100644 index 26aa96ab2f..0000000000 --- a/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/website/img/timefold-logo-horizontal-negative.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/website/img/timefold-logo-stacked-positive.svg b/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/website/img/timefold-logo-stacked-positive.svg deleted file mode 100644 index 7c871643b2..0000000000 --- a/benchmark/src/main/resources/ai/timefold/solver/benchmark/impl/report/website/img/timefold-logo-stacked-positive.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/build/build-parent/pom.xml b/build/build-parent/pom.xml index d6ab6c60c7..26c7b70445 100644 --- a/build/build-parent/pom.xml +++ b/build/build-parent/pom.xml @@ -23,7 +23,7 @@ 1.5.12 2.24.1 9.7.1 - 3.15.1 + 3.16.1 1.26.1 3.6.1 1.11.0 @@ -35,9 +35,6 @@ 2.21.1 2.0.16 3.3.5 - 0.52 - 5.2.3 - 3.6.4 1.0.0 @@ -171,27 +168,6 @@ jcl-over-slf4j ${version.org.slf4j} - - - - org.webjars - webjars-locator - ${version.org.webjars.webjars-locator} - - - org.webjars - bootstrap - ${version.org.webjars.bootstrap} - runtime - - - org.webjars - jquery - ${version.org.webjars.jquery} - runtime - - -