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

fix: Store layout packages #20075

Merged
merged 1 commit into from
Sep 27, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ReloadCache implements Serializable {
static Set<String> skippedResources = new HashSet<>();
static Set<String> dynamicWhiteList;
static Set<String> routePackages;
static Set<String> layoutPackages;
static Set<String> jarClassNames = new HashSet<>();
static Set<Class<?>> jarClasses = new HashSet<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public void failFastContextInitialized(ServletContextEvent event) {
getLogger().debug("There are no discovered routes yet. "
+ "Start to collect all routes from the classpath...");
try {
Collection<String> routePackages = null;
Collection<String> routePackages;
if (devModeCachingEnabled
&& ReloadCache.routePackages != null) {
routePackages = ReloadCache.routePackages;
Expand Down Expand Up @@ -356,11 +356,27 @@ public void failFastContextInitialized(ServletContextEvent event) {
"There are {} navigation targets after filtering route classes: {}",
navigationTargets.size(), navigationTargets);

Collection<String> layoutPackages;
if (devModeCachingEnabled
&& ReloadCache.layoutPackages != null) {
layoutPackages = ReloadCache.layoutPackages;
} else {
layoutPackages = getDefaultPackages();
}

Set<Class<?>> layoutClasses = findByAnnotation(
routePackages, Layout.class)
layoutPackages, Layout.class)
.collect(Collectors.toSet());

if (devModeCachingEnabled) {
ReloadCache.layoutPackages = layoutClasses.stream()
.map(Class::getPackageName)
.collect(Collectors.toSet());
}

RouteRegistryInitializer
.validateLayoutAnnotations(layoutClasses);

// Collect all layouts to use with Hilla as a main layout
layoutClasses.stream().filter(
clazz -> RouterLayout.class.isAssignableFrom(clazz))
Expand Down
Loading