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

[ui] Move generated files to build directory #22707

Closed

Conversation

ZacBlanco
Copy link
Contributor

@ZacBlanco ZacBlanco commented May 9, 2024

Description

Recent changes in #22645 meant new files were generated in the source directory structure. This change updates the build to output these generated files to maven's build output directory.

Motivation and Context

Prevents creating new files in the git working tree and is also good build hygiene.

Fixes #22685

Impact

N/A

Test Plan

  • Tested that IntelliJ-based builds can load the UI successfully
  • build presto-server module and tested the UI still works correctly.

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

== NO RELEASE NOTE ==

@ZacBlanco ZacBlanco requested a review from a team as a code owner May 9, 2024 17:18
@ZacBlanco ZacBlanco requested review from presto-oss and yhwang and removed request for presto-oss May 9, 2024 17:18
@ZacBlanco
Copy link
Contributor Author

Note: I've tried putting the generated files into ./target/generated-resources/ but IntelliJ failed to pick up these resources and put them on the classpath when executing applications/debugging in the IDE (e.g. such as when executing HiveQueryRunner or IcebergQueryRunner). I regularly use those applications for local testing and sometimes use the UI. The only way I was able to get the UI to work successfully in the IDE was by putting the generated files in ./target/classes. This seems like an IntelliJ bug that has been open for quite a few years:

https://youtrack.jetbrains.com/issue/IDEA-107816/generated-resources-are-not-copied-to-the-classpath

@ZacBlanco ZacBlanco force-pushed the upstream-ui-generated-sources branch from 090dbc2 to dadc778 Compare May 9, 2024 17:34
@ZacBlanco ZacBlanco marked this pull request as draft May 9, 2024 17:40
@ZacBlanco
Copy link
Contributor Author

@yhwang I took a shot at this. It worked locally but seems the CI doesn't like it. Any thoughts?

@yhwang
Copy link
Member

yhwang commented May 9, 2024

the CI failed with this:

[webpack-cli] Error: Cannot find module 'terser-webpack-plugin

I saw you added that dependency to the package.json. haven't had time to try your change yet. I will try it out later today.
The other thing is the -o <dir> option for the yarn install. I am not sure if that works for yarn 1.22.22 since the output directory is specified in the webpack.confg.js

edit

Seems the terser-webpack-plugin is needed by webpack by default. maybe no need to add it to the package.json unless you prefer to pin a specific version.

@yhwang
Copy link
Member

yhwang commented May 10, 2024

@ZacBlanco instead of the -o option for yarn install, you can use the following:

index 977ed01e4c..79ffca4911 100644
--- a/presto-main/src/main/resources/webapp/src/webpack.config.js
+++ b/presto-main/src/main/resources/webapp/src/webpack.config.js
@@ -51,7 +51,7 @@ module.exports = (env) => {
             extensions: ['.*', '.js', '.jsx']
         },
         output: {
-            path: path.join(__dirname, '..'),
+            path: path.join(__dirname, '..', '..', '..', '..', '..', 'target', 'classes', 'webapp'),
             filename: path.join('dist', '[name].js'),
         },
         optimization: {

Then the generated js will go to the presto-main/target/classes/webapp. I saw you use ${project.build.directory} in the pom.xml file which is a good change. Just need to figure out how to pass ${project.build.directory} to webpack.config.js to replace the '..', '..', '..', '..', '..', 'target' above. i.e. Having a default value in the webpack.config.js. For maven build, it passes ${project.build.directory} as an alternative value.

@ZacBlanco
Copy link
Contributor Author

I am closing this in favor of the solution in #22745

@ZacBlanco ZacBlanco closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mvn clean install adds files to presto-main/src
2 participants