IntelliJ weird behaviour

Hey!

I’m getting started with Vaadin Flow, and have setup a multi-module maven project as such:
parent-pom
→ service (child module)
→ ui (child module)

The idea was to have frontend code and all the vaadin dependencies in the “ui” module, and keep business logic etc in the “service” module. This is kind of the “norm” at my current company.

My vaadin maven plugin is configured as follows:

<configuration>
    <frontendDirectory>${project.basedir}/frontend</frontendDirectory>
    <generatedTsFolder>${project.basedir}/frontend</generatedTsFolder>
    <npmFolder>${project.basedir}/frontend</npmFolder>
</configuration>
<executions>
    <execution>
        <goals>
           <goal>prepare-frontend</goal>
        </goals>
    </execution>
</executions>

The idea is that all the generated frontend files would end up under ui/frontend, and not the project root (of the parent pom).

This seems to work great, when i click “Run” on my spring boot application class from IntelliJ, it builds, and outputs a ui/frontend directory with all the files required.

HOWEVER and here comes my problem: Whenever I build with Maven, it also generates the folders and everything correctly, BUT when I then go back and try and run my application via IntelliJ, it seems to end up in some weird state, and won’t properly boot. I get the exception com.vaadin.flow.server.ServiceException: java.io.IOException: Unable to find index.html. It should be available in the frontend folder when running in development mode

I can’t get it to boot via IntelliJ again unless I run mvn clean. I don’t quite understand why it differs. Any help is appreciated!

Additional information: I’m not using the spring-boot parent pom neither the spring-boot plugin

The devtools thingy also seems a bit broken, it’s looking for files in the wrong directory:

2024-02-29 11:04:57.359 ERROR [com.vaadin.base.devserver.IdeIntegration]: Unable to find file in /Users/robin/projects/back-office/src/main/java/com/xxx/backoffice/ui/MainView.java

It should be looking under /Users/robin/projects/back-office/ui/src...

Can I point vaadin to the frontend folder via application.properties or something similar? I’m assuming that’s whats missing here. I have it configured for the maven plugin, but i guess when just “running” the application via IntelliJ, the plugin isn’t used.

If you don’t configure anything; all frontend resource are within the UI module… not sure wat you did that it behaves wrongly for you tho :grimacing:

Ok true, idk what I was doing with my configuration. I removed the plugin config options and it works better :smile:

However, still not perfect… If I build a production build (with the build-frontend) goal, and then go and start it in IntelliJ, seems like it uses the production build files and I don’t get any devtools or similar.

Any idea if that can be solved as well? Or is the only option to run a clean-up after a production build?

You should normally never need a production build locally; by default a dev bundle is created if you don’t activate hot deploy https://vaadin.com/docs/latest/configuration/development-mode

Just FYI: you can always find the best / up-to-date config of projects in the examples you can download from start.vaadin.com and just adopt that to your needs in your projects

Hmm I guess you are right. It should prooobably only happen on CI.
Thanks for your help!