flow icon indicating copy to clipboard operation
flow copied to clipboard

build-frontend: "Unable to locate file ./src/hello-world.ts" should provide more info

Open mvysny opened this issue 1 year ago • 0 comments

Description of the bug

I'm getting

Caused by: com.vaadin.flow.server.ExecutionFailedException: Unable to locate file ./src/hello-world.ts
    at com.vaadin.flow.server.frontend.TaskCopyTemplateFiles.execute (TaskCopyTemplateFiles.java:71)
    at com.vaadin.flow.server.frontend.NodeTasks.execute (NodeTasks.java:342)
    at com.vaadin.flow.plugin.base.BuildFrontendUtil.runNodeUpdater (BuildFrontendUtil.java:332)
    at com.vaadin.flow.plugin.maven.BuildFrontendMojo.execute (BuildFrontendMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)

The problem is that there's nothing in my project that depends on hello-world.ts. As it turned out, there was some old forgotten class file in Maven's target/classes and I was running mvn -C package, so Maven didn't clear out target/ and was discovering this kind of class. This is not for Vaadin to solve, of course, but Vaadin could provide more informative error message guiding me towards the nature of the problem.

Expected behavior

Vaadin plugin should provide more information at TaskCopyTemplateFiles:71: it should print the clazz and jsmAnnotation and path as the very minimum; maybe even the npm folder and other properties.

Minimal reproducible example

Not easy to reproduce, but basically:

  1. Start with Skeleton starter, add a class which imports frontend/src/hello-world.js. Make a production build and watch it succeed.
  2. Delete the class sources.
  3. Run mvn -C package -Pproduction - since the class is still left compiled in target/classes it will be picked by classpath scanning and TaskCopyTemplateFiles should throw.

Versions

  • Vaadin / Flow version: 24.3.5

mvysny avatar Feb 22 '24 08:02 mvysny