Skip to content

Commit

Permalink
deps: upgrade to Quarkus 3.16.1
Browse files Browse the repository at this point in the history
Required us to drop webjars-locator and do the extraction manually, on account of the root issue not being easily and quickly fixable:

classgraph/classgraph#891
  • Loading branch information
triceo committed Nov 7, 2024
1 parent 06d2c82 commit 5368801
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 116 deletions.
20 changes: 1 addition & 19 deletions benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,9 @@
<artifactId>freemarker</artifactId>
</dependency>
<!-- Webjars -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
</dependency>
<dependency>
<groupId>ai.timefold.solver</groupId>
<artifactId>timefold-solver-webui</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Testing -->
<dependency>
Expand Down Expand Up @@ -243,11 +228,8 @@
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredUsedUndeclaredDependencies>
<dependency>org.webjars:*:jar</dependency>
</ignoredUsedUndeclaredDependencies>
<ignoredUnusedDeclaredDependencies>
<dependency>org.webjars:*:jar</dependency>
<dependency>ai.timefold.solver:timefold-solver-webui:jar</dependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,92 +1,55 @@
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<String, Set<String>> 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<String> 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");
copyResource(benchmarkReportDirectory, "website/js/prettify.js");
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<String, InputStream> 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>${benchmarkReport.plannerBenchmarkResult.name} Planner benchmark report</title>

<link href="website/webjars/timefold/img/timefold-favicon.svg" rel="icon" type="image/svg+xml">
<link href="website/webjars/timefold/img/timefold-favicon.svg" rel="mask-icon" color="#000000">
<link href="website/img/timefold-favicon.svg" rel="icon" type="image/svg+xml">
<link href="website/img/timefold-favicon.svg" rel="mask-icon" color="#000000">

<link href="website/css/app.css" rel="stylesheet"/>
<link href="website/webjars/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="website/webjars/timefold/css/timefold-webui.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="website/css/timefold-webui.css" rel="stylesheet" />
<link href="website/css/prettify.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet" /> <#-- Too large for a webjar. -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" rel="stylesheet" />

<script src="https://buttons.github.io/buttons.js"></script>
<script src="website/js/app.js"></script> <#-- Contains functions called by chart.js; must go first. -->
<script src="website/webjars/jquery/jquery.min.js"></script>
<script src="website/webjars/bootstrap/js/bootstrap.bundle.min.js"></script> <#-- Includes Popper for dropdowns. -->
<script src="https://cdn.jsdelivr.net/npm/[email protected].0"></script>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> <#-- Includes Popper for dropdowns. -->
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/chart.umd.min.js"></script>
<script src="https://unpkg.com/@sgratzl/[email protected]"></script>
<script src="website/js/chartjs-plugin-watermark.js"></script>
<script src="website/js/prettify.js"></script>
Expand Down Expand Up @@ -92,7 +92,7 @@
<div class="container">
<div class="text-white">
<a href="#" class="navbar-brand">
<img src="website/webjars/timefold/img/timefold-logo-horizontal-negative.svg" alt="Timefold Logo (horizontal, negative)">
<img src="website/img/timefold-logo-horizontal-negative.svg" alt="Timefold Logo (horizontal, negative)">
</a>
<br />
Benchmark Report
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5368801

Please sign in to comment.