Closed mvysny closed 3 years ago
The reason that we can start the project without the stat.json is probably becaus Fusion adds the bundle into the index.html <script defer="defer" src="VAADIN/build/vaadin-bundle-433c776b2a8a219d4f73.cache.js">
which I guess is loaded when not using useDeprecatedV14Bootstrapping
as then I guess we might use the IndexHtmlRequestHandler instead of the BootsrapHandler.
There is also a deeper issue here: the WAR file will package an older version of flow-build-info.json
. I think it goes like this:
vaadinPrepareFrontend
is run, which creates a first version of flow-build-info.json
build/vaadin-generated
to build/resources/main
vaadinBuildFrontend
task is run, which modifies flow-build-info.json
and creates stats.json
.build/resources/main
.So should the files just be directly created to build/resources/main
instead of creating it to build/vaadin-generated
?
Maybe.... I'm trying to remember the reason why we're using build/vaadin-generated
instead of creating stuff simply in build/resources/main
...
A fix could either be to generate stuff directly to build/resources/main
, or alternatively I wonder what would happen if we configure Gradle to run processResources
AFTER vaadinBuildFrontend
like this:
project.tasks.getByName("processResources").mustRunAfter("vaadinBuildFrontend")
Let me investigate on this further.
There's some info on this here: https://github.com/vaadin/vaadin-gradle-plugin/pull/44
Uh-oh, using project.tasks.getByName("processResources").mustRunAfter("vaadinBuildFrontend")
fails right away with
:classes
\--- :processResources
\--- :vaadinBuildFrontend
\--- :classes (*)
The vaadinBuildFrontend
task needs to depend on classes, to be able to analyze e.g. @CssImport
annotations used by the project.
But maybe it could be enough to only depend on compileJava
according to https://docs.gradle.org/current/userguide/java_plugin.html? Not good - what about compileKotlin
and possibly other tasks hooked to classes
?
Generating token file to build/resources/main
before processResources
doesn't work: the processResources
will delete the build/resources/main
folder. Maybe run vaadinPrepareFrontend
after processResources
?
That works! However, running Intellij+Tomcat will invoke Gradle to build the war file, which in turn will invoke processResources
, thus removing the flow-build-info.json
file produced by vaadinPrepareFrontend
? Investigate.
Just as I suspected: Intellij+Tomcat ignores stuff present in build/resources/main
, making Vaadin fail that it can't locate pom.xml in tomcat/bin folder. A separate source folder is therefore needed.
The only way forward is to make vaadinPrepareFrontend
to generate the token file to build/vaadin-generated
as before, but then make vaadinBuildFrontend
work in the scope of build/resources/main
.
Currently the
stats.json
is generated into thebuild/vaadin-generated/META-INF/VAADIN/config/
folder, along withflow-build-info.json
. However,stats.json
is generated after Gradle copies stuff frombuild/vaadin-generated
tobuild/resources/main
, thereforestats.json
file is not packaged. Vaadin is able to run withoutstats.json
both in dev and in production mode, however certain things will not work (for example PolymerTemplate and LitTemplate).Desktop (please complete the following information):
To Reproduce TBD once the Gradle plugin 0.20.0.0.alpha3 is released.
Expected behavior The
stats.json
is generated tobuild/resources/main
which will then cause Gradle to package it correctly to WAR.Additional context The incorrect path can be seen in
webpack.generated.js
:PluginAdapterBase.servletResourceOutputDirectory()
returnsbuild/vaadin-generated/META-INF/VAADIN
PluginAdapterBase.webpackOutputDirectory()
returnsbuild/resources/main/META-INF/VAADIN/webapp/
Currently the
flow-build-info.json
is generated inbuild/vaadin-generated/META-INF/VAADIN/config/
(that is good); however is there a way to forcestats.json
to be generated elsewhere (inbuild/resources/main/META-INF/VAADIN/config/stats.json
)?