flow icon indicating copy to clipboard operation
flow copied to clipboard

running vaadin:prepare-frontend using directory dependency works, but jar dependencies filter away resources

Open roeltje25 opened this issue 1 year ago • 4 comments

Description of the bug

While developing in eclipse I use a dependency library I include this project locally. when prepare-runtime runs via maven the files from META-INF/frontend/ are ALL copied to the generated/jar-resources directory. Which is great and correct and all good things. But when a colleague who has not checked out the dependency from github is doing the same thing the files are copied from the jar file. However, for some unknown reason now only css, javascript and typescript are copied along. To me this is absolutely wrong, or at least should be documented clearly somewhere logical. Now, I had to investigate and debug the maven stuff and get all the way to here:

https://github.com/vaadin/flow/blob/main/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskCopyFrontendFiles.java#L43 which is used here https://github.com/vaadin/flow/blob/main/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskCopyFrontendFiles.java#L97

The use case is e.g. that I have several iconsets that are defined in svg files which are loaded in an init javascript. these all reside in a dependent library so we can share this among projects

Expected behavior

All files in the META-INF/frontend or otherwise META-INF/resources/frontend directories should be copied to generated/jar-resources on running vaadin:prepare-frontend goal in maven

Minimal reproducible example

Use a starter project add a dependent library with some frontend files which are not javascript, typscript or css, such as a svg file.

Versions

  • Vaadin / Flow version: 24.4.3
  • Java version: 21.0.3
  • OS version: Windows 11
  • IDE (if applicable): Eclipse 2024-06

roeltje25 avatar Jun 27 '24 13:06 roeltje25

All files in the META-INF/frontend or otherwise META-INF/resources/frontend directories should be copied to generated/jar-resources on running vaadin:prepare-frontend goal in maven

Note: This might not be true and can result in a potential information leakage if there for example are README.md in the folder for the development team. So this is an assumption that holds not true for every project.

knoobie avatar Jun 27 '24 14:06 knoobie

All files in the META-INF/frontend or otherwise META-INF/resources/frontend directories should be copied to generated/jar-resources on running vaadin:prepare-frontend goal in maven

Note: This might not be true and can result in a potential information leakage if there for example are README.md in the folder for the development team. So this is an assumption that holds not true for every project.

Although, this could be the case, it is against the conventions in e.g. maven which do not normally filter like that. And I might in fact WANT to include README.md in the frontend. If auxiliary files about the frontend directory are needed, we should include them elsewhere or explicitly ignore them in some file.

That should of course be documented, or at least the existing filtering should be documented. Regardless, in our situation we need to include svgs to load as iconsets. We want these bundled, not as regular resources. This is currently not possible....

roeltje25 avatar Jun 30 '24 06:06 roeltje25

maven which do not normally filter like that

Maven typically is not program that exposes things over the web; Vaadin on the other hand is 😉

A workaround could be to publish your svgs as npm package and include as frontend dependency.

There is also a similar feature request / pull request already open regarding a customizing; so if you are interested to create one for your use-case the team could consider it as well https://github.com/vaadin/flow/pull/19550

knoobie avatar Jun 30 '24 07:06 knoobie

TaskCopyFrontendFiles filters the resources from resource folder by WILDCARD_INCLUSIONS for JARs whereas for file system originated resources it doesn't do this filtering. Perhaps Flow should copy all the resources in both cases.

Could you please provide a ready minimal project where we can see this problem?

mshabarov avatar Jul 02 '24 10:07 mshabarov