While working on spring-projects/spring-framework#28518, I found that I had to configure manually resource hints for resources located in static/* to be included in the native image in order to get those working on native images. Same need on public/* and other directories (default ones, but also ideally customized ones if that's possible).
Could you please add such resource hints for serving static web content?
Comment From: snicoll
There is also classpath:/META-INF/resources/webjars/ for Webjars support in WebMvcAutoConfiguration.
Comment From: snicoll
Getting the actual value configured by the user is an interesting use case. We could watch for a WebProperties RegisteredBean (that indicates that we've opt-in for the feature) and then read the environment. Or we could bind the configuration properties bean itself and access it.
There is also the BeanRegistrationAotProcessor where the AOT engine would instantiate any bean that implements the interface. A crazy idea would be to make WebProperties implement that interface (or a variant thereof) so that hints can be registered directly against the bound object.
Flagging for team attention to get feedback from the team.
Comment From: philwebb
We've had some trouble in the past trying to make properties classes too clever so I think I'd prefer that they don't implement an additional interface. Resource hints are interesting and I'm a little worried that we can try and make things too clever and paint ourselves into a corner.
For example, if we manage to support profiles with AOT then it's possible that the resource properties could change depending on the active profile. Since we won't know that at build time it will be hard for us to deduce the correct resources to include.
Perhaps we'd be better off with an explicit configuration on the build plugin and align the default so it works for most applications.
Comment From: snicoll
I went ahead and registered the defaults if they are available on the classpath. We could revisit this later if needed. I agree that trying to be too smart upfront is a bad idea.