How to pack Server side java script in executable jar file

I used @JavaScript in Vaadin UI, it works great in developement.
But after I use maven to package project to a single jar file.
Those java script files were not included.

Is there a way to specify in the build plugin to include those javascript files?

Thank you!

If your js files are stored under src/main/resources they should be included by default in the jar

The java script file is in the same directory as class file, there are similar post like this!/thread/4924537

I am using this way

package com.mycompany.ui;
public class TreeUI extends UI {}

No answer for relative path of java script file for @Javascript.
Even I added the java script file to the jar file. I got this error:
Rejecting published file request for file that has not been published: dbasTree.js

So I moved the dbasTree.js to src/main/resources/static and changed to @JavaScript(“/dbasTree.js”)
Run in development, got “Rejecting published file request for file that has not been published: dbasTree.js” too.

What is the best way to use @JavaScript in Vaadin UI and how can I package the file to production jar file?


In a standard maven project resources inside src/main/resources would be packaged into the jar;
so putting your file dbasTree.js inside src/main/resources/com/mycompany/ui and annotate UI class with @JavaScript(“dbasTree.js”) should work


That worked.