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

build-frontend fails when file is duplicated in frontend and META-INF/frontend #21008

Open
javier-godoy opened this issue Feb 18, 2025 · 4 comments

Comments

@javier-godoy
Copy link
Contributor

Description of the bug

I have a WAR project that contains the same file in /src/main/frontend/styles and /src/main/resources/META-INF/frontend/styles (because of reasons*)

When I run mvn clean package -Pproduction it fails with the following error

Failed to find the following css files in the node_modules or C:\Users\Javier\Downloads\skeleton-starter-flow-24\src\main\frontend directory tree:
[ERROR] - ./styles/image-crop-styles.css
[ERROR] Check that they exist or are installed. If you use a custom directory for your resource files instead of the default frontend folder then make sure it's correctly configured (e.g. set 'vaadin.frontend.frontend.folder' property)

Note that the file DOES exist.

* Yes, this setup is weird...

Expected behavior

The build should succeed (or it should fail with a different error, currently it complains that an existing file does not exist)

Minimal reproducible example

  1. Build the attached project with mvn clean package -Pproduction
  2. Observe that the build fails
  3. Delete \src\main\resources\META-INF\frontend\styles
  4. Rebuild: mvn clean package -Pproduction
  5. Observe that the build succeeds

skeleton-starter-flow-24.zip

Versions

  • Vaadin / Flow version: 24.6.5
  • Java version: Corretto-17.0.0.35.1 (build 17+35-LTS)
  • OS version: Windows 10.0.19045.5371
@mcollovati
Copy link
Collaborator

mcollovati commented Feb 18, 2025

It works if you put the resources in /src/main/resources/META-INF/resources/frontend/.
This is the path that TaskCopyLocalFrontendFiles uses to copy local resources to the generated/jarResources folder.
The path can be configured by setting frontendResourcesDirectory in the vaadin-maven-plugin configuration

<frontendResourcesDirectory>${project.basedir}/src/main/resources/META-INF/frontend</frontendResourcesDirectory>

Edit: the parameter is documented here

/src/main/resources/META-INF/resources/frontend/ is the documented folder for CSS and JS resources in add-on projects (https://vaadin.com/docs/latest/flow/advanced/loading-resources)

@javier-godoy
Copy link
Contributor Author

@mcollovati Thanks, I still have to move some things around, but it's a little bit more clear this way. The project was actually a non-spring project, so I tried to move resources according to Table 1 from https://vaadin.com/docs/latest/flow/advanced/loading-resources.

I still think there is an issue here, because I had put a file in directories A and B, then the build complained that A/file didn't exist (while it did exist), and I had to delete B/file so that A/file could be found.

@mcollovati
Copy link
Collaborator

The issue here is that the copy task considers only one folder, but the the piece of code that resolves the import also fallbacks to the META-INF/frontend folder.
So, the resource if "found" but not present in the generated folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Low Priority (P3)
Development

No branches or pull requests

3 participants