Skip to content

Add resource hints for serving static web content #31278

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

Closed
sdeleuze opened this issue Jun 8, 2022 · 4 comments
Closed

Add resource hints for serving static web content #31278

sdeleuze opened this issue Jun 8, 2022 · 4 comments
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@sdeleuze
Copy link
Contributor

sdeleuze commented Jun 8, 2022

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?

@snicoll
Copy link
Member

snicoll commented Jun 9, 2022

There is also classpath:/META-INF/resources/webjars/ for Webjars support in WebMvcAutoConfiguration.

@snicoll
Copy link
Member

snicoll commented Jun 9, 2022

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.

@snicoll snicoll added the for: team-attention An issue we'd like other members of the team to review label Jun 9, 2022
snicoll added a commit to snicoll/spring-boot that referenced this issue Jun 9, 2022
snicoll added a commit to snicoll/spring-boot that referenced this issue Jun 9, 2022
@philwebb
Copy link
Member

philwebb commented Jun 9, 2022

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.

@philwebb philwebb added the status: pending-design-work Needs design work before any code can be developed label Jun 9, 2022
@snicoll snicoll added type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged status: pending-design-work Needs design work before any code can be developed labels Jun 13, 2022
@snicoll snicoll self-assigned this Jun 13, 2022
@snicoll snicoll added this to the 3.0.0-M4 milestone Jun 13, 2022
@snicoll
Copy link
Member

snicoll commented Jun 13, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants