Skip to content

Commit 8705f81

Browse files
fix: fix glob pattern in runtime hints registration (#22531) (#22533)
Fixes the pattern used to register runtime hints for native build in order to match resources in subfolders. Also adds some basic test to ensure main resources are accepted Fixes #22526 Co-authored-by: Marco Collovati <marco@vaadin.com>
1 parent 08c365d commit 8705f81

File tree

2 files changed

+80
-3
lines changed

2 files changed

+80
-3
lines changed

vaadin-spring/src/main/java/com/vaadin/flow/spring/springnative/VaadinHintsRegistrar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
3434
.forEach(cls -> ref.registerType(cls, MemberCategory.values()));
3535

3636
// Bundles, build info etc
37-
hints.resources().registerPattern("META-INF/VAADIN/*");
37+
hints.resources().registerPattern("META-INF/VAADIN/**");
3838
hints.resources().registerPattern("vaadin-i18n/*");
3939
hints.resources().registerPattern("vaadin-featureflags.properties");
4040

@@ -55,8 +55,8 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
5555

5656
// Flow server resources like BootstrapHandler.js and
5757
// RouteNotFoundError_prod.html
58-
hints.resources().registerPattern("com/vaadin/flow/server/*");
59-
hints.resources().registerPattern("com/vaadin/flow/router/*");
58+
hints.resources().registerPattern("com/vaadin/flow/server/**");
59+
hints.resources().registerPattern("com/vaadin/flow/router/**");
6060
}
6161

6262
private void registerResourceIfPresent(RuntimeHints hints, String path) {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.spring.springnative;
17+
18+
import org.junit.jupiter.api.Test;
19+
import org.springframework.aot.hint.RuntimeHints;
20+
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
21+
22+
import static org.assertj.core.api.Assertions.assertThat;
23+
24+
class VaadinHintsRegistrarTest {
25+
26+
@Test
27+
void shouldRegisterVaadinMetadata() {
28+
RuntimeHints hints = new RuntimeHints();
29+
new VaadinHintsRegistrar().registerHints(hints,
30+
getClass().getClassLoader());
31+
assertThat(RuntimeHintsPredicates.resource()
32+
.forResource("META-INF/VAADIN/conf/flow-build-info.json"))
33+
.accepts(hints);
34+
}
35+
36+
@Test
37+
void shouldRegisterFeatureFlags() {
38+
RuntimeHints hints = new RuntimeHints();
39+
new VaadinHintsRegistrar().registerHints(hints,
40+
getClass().getClassLoader());
41+
assertThat(RuntimeHintsPredicates.resource()
42+
.forResource("vaadin-featureflags.properties")).accepts(hints);
43+
}
44+
45+
@Test
46+
void shouldRegisterDefaultI18NPropertiesFiles() {
47+
RuntimeHints hints = new RuntimeHints();
48+
new VaadinHintsRegistrar().registerHints(hints,
49+
getClass().getClassLoader());
50+
assertThat(RuntimeHintsPredicates.resource()
51+
.forResource("vaadin-i18n/translations.properties"))
52+
.accepts(hints);
53+
assertThat(RuntimeHintsPredicates.resource()
54+
.forResource("vaadin-i18n/translations_en.properties"))
55+
.accepts(hints);
56+
assertThat(RuntimeHintsPredicates.resource()
57+
.forResource("vaadin-i18n/translations_it_IT.properties"))
58+
.accepts(hints);
59+
}
60+
61+
@Test
62+
void shouldRegisterFlowServerStaticResources() {
63+
RuntimeHints hints = new RuntimeHints();
64+
new VaadinHintsRegistrar().registerHints(hints,
65+
getClass().getClassLoader());
66+
assertThat(RuntimeHintsPredicates.resource()
67+
.forResource("com/vaadin/flow/router/NoRoutesError_dev.html"))
68+
.accepts(hints);
69+
assertThat(RuntimeHintsPredicates.resource()
70+
.forResource("com/vaadin/flow/server/BootstrapHandler.js"))
71+
.accepts(hints);
72+
assertThat(RuntimeHintsPredicates.resource()
73+
.forResource("com/vaadin/flow/server/frontend/index.ts"))
74+
.accepts(hints);
75+
}
76+
77+
}

0 commit comments

Comments
 (0)