Skip to content

Commit

Permalink
Always watch META-INF/resources and index.html
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <phillip.kruger@gmail.com>
  • Loading branch information
phillip-kruger committed Sep 30, 2024
1 parent 2811eec commit 5811e26
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Capability;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
Expand All @@ -31,6 +33,12 @@
*/
public class StaticResourcesProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
HotDeploymentWatchedFileBuildItem indexHtmlFile() {
String staticRoot = StaticResourcesRecorder.META_INF_RESOURCES + "/index.html";
return new HotDeploymentWatchedFileBuildItem(staticRoot, !QuarkusClassLoader.isResourcePresentAtRuntime(staticRoot));
}

@BuildStep
void collectStaticResources(Capabilities capabilities,
List<AdditionalStaticResourceBuildItem> additionalStaticResources,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void handle(RoutingContext event) {
.putHeader(CONTENT_TYPE, getMimeType(fileName))
.end(Buffer.buffer(content));
} catch (IOException ex) {
ex.printStackTrace();
event.next();
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ public void handle(AsyncResult<ServerWebSocket> event) {
}

private void addSocket(ServerWebSocket session) {
JsonRpcRouter jsonRpcRouter = CDI.current().select(JsonRpcRouter.class).get();
jsonRpcRouter.addSocket(session);
try {
JsonRpcRouter jsonRpcRouter = CDI.current().select(JsonRpcRouter.class).get();
jsonRpcRouter.addSocket(session);
} catch (IllegalStateException ise) {
LOG.debug("Failed to connect to dev ui communication server, " + ise.getMessage());
}
}

private static final String UPGRADE = "Upgrade";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void sendStatic(RoutingContext context, String path) throws IOException
Path found = null;
for (Path root : resolvedWebRoots) {
Path resolved = root.resolve(path);
if (Files.exists(resolved)) {
if (resolved.getFileSystem().isOpen() && Files.exists(resolved)) {
found = resolved;
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.vertx.http.runtime.devmode;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -34,9 +33,7 @@ public void close() {

private void addPathIfContainsStaticResources(List<Path> resources, Path resourceDir) {
Path resource = resourceDir.resolve(StaticResourcesRecorder.META_INF_RESOURCES);
if (Files.exists(resource)) {
resources.add(resource);
}
resources.add(resource);
}

}

0 comments on commit 5811e26

Please sign in to comment.