vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
609 stars 167 forks source link

Maven plugin results are ignored when project is executed via jetty:run #6162

Open denis-anisimov opened 5 years ago

denis-anisimov commented 5 years ago

If I have a project where maven plugin is used and jetty can be run without WAR file (see e.g. https://github.com/vaadin/flow/tree/master/flow-tests/test-npm-only-features/test-npm-general):

<plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-maven-plugin</artifactId>
                <version>${project.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                            <goal>build-frontend</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

then there are several ways to run the project: using jetty:run and jetty:run-war (after mvn package).

What I do is:

When I run jetty:run the bundle file which is loaded by the app page is not even on the file system: I may not find it in the project. It looks like it's generated on the fly.

When I run jetty:run-war (after ) the generated bundle file is used.

The main issue here: why maven plugin generated bundle is not used even if it's already available ?

Theoretically it doesn't matter how to run and which bundle to use if the bundle is the same in any case. In fact it's not true. We are using ClassFinder abstraction to discover classes. In one case it's implemented inside maven plugin in other case it's implemented inside the flow-server module. And again: theoretically they should work in the same way. In fact they don't. This is a different issue and I will make it separately. But you may use this branch : https://github.com/vaadin/flow/pull/6161/commits/664b87431a97f558cb2dc28b730f4840c0d5302e and here is the test https://github.com/vaadin/flow/pull/6161/commits/5647b977f4428f3ee2378a23217e061d7c51f53f which fails in case you use jetty:run and it works as it should if you run it via jetty:run-war.

The main point of this ticket: web server should reuse the maven plugin bundle if it's already available.

denis-anisimov commented 5 years ago

related: https://github.com/vaadin/flow/issues/6163

Legioth commented 5 years ago

The main point of this ticket: web server should reuse the maven plugin bundle if it's already available.

mvn jetty:run is supposed to be run in a way that makes it possible to see the result of changes to client-side files without redeploying anything, regardless of whether a bundle already exists because of something you've done previously. Anything that is resembling a packaged .war file (e.g. mvn jetty:run-war) is instead supposed to only use what's inside the .war even if you would change files in your local file system.

We will always have this conflict between resolving things at build time for production-like deployments and resolving things at runtime for a smooth development experience. Redefining when each mode is used doesn't really matter as long as both modes exist.

What we actually can do would be roughly divided into these two categories:

  1. Fix bugs that cause the two modes to work in different ways.
  2. Make it easier for the user to understand which mode is used and control which mode they're using. Right now, there's probably a little too much magic involved.