Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Maven <build><directory> setting ignored by frontend compilation, resulting in error: "Frontend compilation failed" #6629

Closed
basil-bourque opened this issue Oct 6, 2019 · 5 comments

Comments

@basil-bourque
Copy link

basil-bourque commented Oct 6, 2019

For full details including screenshots, see this Stack Overflow page:
https://stackoverflow.com/q/58229664/642706

To summarize:

Edit Vaadin 14.1.0alpha2 web-app project’s POM file to place the target build folder in a different place such as a ramdisk.

  • To the <properties> element add:
    <buildDirectory>/Volumes/RamDisk/target</buildDirectory>
  • To the <build> element, add:
    
<directory>${buildDirectory}</directory>

Most of the project is built in the specified location folder, except for:

  • generated-flow-imports.js
  • package.json

…both appearing in the default target folder rather than the overridden folder location.

This results in errors seen on the console:

[webpack] ERROR dev-webpack - ERROR in Entry module not found: Error: Can't resolve '/Volumes/RamDisk/target/frontend/generated-flow-imports.js' in '/Users/basilbourque/IdeaProjects/ticktock/frontend'
[webpack] ERROR dev-webpack - 
[webpack] ERROR dev-webpack - ERROR in Entry module not found: Error: Can't resolve '/Volumes/RamDisk/target/frontend/generated-flow-imports.js' in '/Users/basilbourque/IdeaProjects/ticktock/frontend'
[webpack] ERROR dev-webpack - ℹ 「wdm」: Failed to compile.
[webpack] ERROR dev-webpack - 
------------------ Frontend compilation failed. -----------------

Apparently some part of the Vaadin build process is not soft-coded for the target folder location, and is ignoring the specified override of the default target folder location.

@denis-anisimov
Copy link
Contributor

I see that generatedFolder field is used in both maven mojos for the mentioned files.

So this comes from dev mode which doesn't know anything about maven and uses the hardcoded values for the build folder and other locations.

I don't see how we can fix this generally since as I said maven settings are not involved in dev mode run.
You can set vaadin.frontend.generated.folder system property when you run the project to specify the location of target/frontend/ which is used by default.

@basil-bourque
Copy link
Author

basil-bourque commented Oct 12, 2019

@denis-anisimov Seems like in your comment you were suggesting a possible workaround. Can you explain more concretely, as I know nothing about this frontend business.

I did find this FrontendUtils class which has some static variables involving frontend generated directories. But I know not what to do with them.

@denis-anisimov
Copy link
Contributor

This is actually not a workaround.
This is an officially supported feature and the only way which you may use to specify the generated folder at runtime.

You should set the vaadin.frontend.generated.folder system property value.
It's a general configuration property.
Normally when you execute an app via java you do it via java -Dvaadin.frontend.generated.folder=somevalue.

I'm not sure which way you run your web app.
The problem is : you are configuring your maven project but expect that it will automatically configures the running web app.
This is confusion rather than a bug: I agree that it's confusing because web app is trying to reuse the maven build project by default and you expect that it may be configured via maven.
But in fact this is not configred via maven.

I guess you are running the app via mvn jetty:run.
In this case you may provide a system property to your app via its config:

<systemProperties>
            <systemProperty>
              <name>propertyName</name>
              <value>propertyValue</value>
            </systemProperty>

There are other ways to set system property value via maven.

@denis-anisimov
Copy link
Contributor

We can solve this issue via saving a parameter in the token file and then read it from the deployment config instead of system property value.

@Artur-
Copy link
Member

Artur- commented Apr 20, 2023

Tested this with the latest 24.1 snapshot and it works. Maybe because the mentioned frontend files are no longer generated inside the target folder

@Artur- Artur- closed this as completed Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants