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

Qute: dev mode - debug a problem with no-restart-template #37224

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,9 @@ private RuntimeUpdatesProcessor setWatchedFilePathsInternal(Map<String, Boolean>
// First find all matching paths from all roots
try (final Stream<Path> walk = Files.walk(root)) {
walk.forEach(path -> {
if (path.equals(root)) {
if (path.equals(root)
// Never watch directories
|| Files.isDirectory(path)) {
return;
}
// Use the relative path to match the watched file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jakarta.inject.Inject;
import jakarta.inject.Singleton;

import io.quarkus.qute.Location;
import io.quarkus.qute.Template;
import io.quarkus.vertx.web.Route;
import io.vertx.ext.web.RoutingContext;
Expand All @@ -15,12 +16,20 @@ public class NoRestartRoute {

private String id;

@Inject
@Location("foo/norestart")
Template norestart;

@Inject
Template bar;

@Route(path = "norestart")
public void test(RoutingContext ctx) {
ctx.end(norestart.data("foo", id).render());
ctx.end(norestart.data("id", id).render());
}

@Route(path = "bar")
public void testBar(RoutingContext ctx) {
ctx.end(bar.data("id", id).render());
}

@PostConstruct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,39 @@ public class NoRestartTemplatesDevModeTest {
.withApplicationRoot(root -> root
.addClass(NoRestartRoute.class)
.addAsResource(new StringAsset(
"Hello {foo}!"),
"templates/norestart.html")
"Hello {id}!"),
"templates/foo/norestart.html")
.addAsResource(new StringAsset(
"quarkus.qute.dev-mode.no-restart-templates=templates/norestart.html"),
"Hi {id}!"),
"templates/bar.html")
.addAsResource(new StringAsset(
"quarkus.qute.dev-mode.no-restart-templates=templates/.+"),
"application.properties"));

@Test
public void testNoRestartTemplates() {
Response resp = given().get("norestart");
resp.then()
.statusCode(200);
String val = resp.getBody().asString();
assertTrue(val.startsWith("Hello "));
String val1 = resp.getBody().asString();
assertTrue(val1.startsWith("Hello "));

resp = given().get("bar");
resp.then()
.statusCode(200);
String val2 = resp.getBody().asString();
assertTrue(val2.startsWith("Hi "));

config.modifyResourceFile("templates/norestart.html", t -> t.concat("!!"));
config.modifyResourceFile("templates/foo/norestart.html", t -> t.concat("!!"));
config.modifyResourceFile("templates/bar.html", t -> t.concat("!!"));

resp = given().get("norestart");
resp.then().statusCode(200);
assertEquals(val + "!!", resp.getBody().asString());
assertEquals(val1 + "!!", resp.getBody().asString());

resp = given().get("bar");
resp.then().statusCode(200);
assertEquals(val2 + "!!", resp.getBody().asString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class QuteDevModeConfig {
* This regular expression can be used to specify the templates for which the application is not restarted.
* I.e. the templates are reloaded and only runtime validations are performed.
* <p>
* The matched input is the template path relative from the {@code templates} directory and the
* {@code /} is used as a path separator. For example, {@code templates/foo.html}.
* The matched input is the template path that starts with a template root, and the {@code /} is used as a path separator.
* For example, {@code templates/foo.html}.
*/
@ConfigItem
public Optional<Pattern> noRestartTemplates;
Expand Down