大型 GWT 项目的结构

发布于 2024-10-19 00:08:41 字数 580 浏览 1 评论 0原文

具有多maven模块或单maven模块结构的上下文

  • 大项目

问题

  • 你最终使用了多maven模块还是单maven模块结构?

详细信息

如果您曾经从事过一个开发时间较长且包含大量功能的大型项目(即不是一个简单的项目),您是否选择将项目拆分为多个 Maven 模块或采用单模块方法?

例如,具有多模块结构,运行 mvn gwt:eclipse 等 Maven 命令时会崩溃(请参阅 http://bit.ly /gs4Rmo)。我想这对于单模块 GWT 项目来说效果很好。并且可能还有像上面这样的其他命令存在多模块结构问题。

然而,多模块结构可以带来更快开发的好处,即如果将“服务器”模块与“客户端”模块分开,则可以单独编译业务逻辑(服务器)并将其打包到生成的Web存档中。编译 GWT 代码大约需要 20 秒,因此如果您只修改服务器包,从长远来看可以节省大量时间。

在处理多模块/单模块项目时,您还遇到过哪些其他类似上述情况的情况?

谢谢你!

Context

  • big project with multi maven module or single maven module structure

Question

  • did you finally use multi-maven-module or single-maven-module structure?

Details

If you've worked on a big project that had long development duration and contains lots of functionality(i.e. not a trivial project), did you choose to split the project into multiple maven modules or went with the single-module approach?

For example, having a multi-module structure, crashes when running maven commands like mvn gwt:eclipse(see http://bit.ly/gs4Rmo). I guess this would have worked well with single module GWT project. And there could be other commands like the above that has issues with multi-module structure.

However, the multi-module structure could bring the benefits of a faster development, i.e. if you separate the "server" from "client" module, you could compile the business logic(server) separately and package it into resulting web archive. Compiling the GWT code, takes about 20 seconds, so if you only modify the server package, it could save you lots of time in the long run.

Which other cases like the one above did you encounter when working with a multi-module/single module project?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡淡離愁欲言轉身 2024-10-26 00:08:41

一些注意事项:

  1. 在开发服务器上,您不必“手动”编译代码:开发服务器会自动编译代码并重新加载它。只需保持开发服务器运行,更改一些代码,然后在浏览器中重新加载页面即可。 (只有当您更改现有类并且不更改项目结构时,这才是正确的)

  2. 多个 maven 模块与多个 GWT 模块无关。

  3. 如果您有在不同环境中执行的代码,您可能希望拥有多个 GWT 模块(= 多个入口点):例如,您的 Web 和移动站点具有完全不同的代码库。然后,您可以将该项目拆分为三个模块:webmobilecommon。然后,您需要在 webmobile 中引用 common

  4. 使用多个 GWT 模块的另一种情况是,如果您出于某种原因想要拥有多个主机(入口)HTML 页面。在极少数情况下,您会需要这样做,例如,当您在集成 OpenID 时需要进行重定向时。另一种情况是,您已经有了现有的网页,只需添加 GWT 来添加一些功能。

  5. 不要仅仅为了减少下载大小而将 GWT 项目拆分为多个模块:改用代码拆分

  6. 如果您的主要抱怨是 gwt 编译时间长,请阅读:如何我可以加快 gwt 编译器的速度吗?

A few notes:

  1. On development server you don't have to compile the code "by hand": dev server compiles the code automatically and reloads it. Just keep dev server running, change some code and then reload the page in browser. (this is only true if you change existing classes and don't change project structure)

  2. Multiple maven modules have nothing to do with multiple GWT modules.

  3. You would want to have multiple GWT modules (= multiple entry points) if you have code that executes in different environments: for example you have web and mobile sites that have quite different code bases. Then you would split the project into three modules: web, mobile and common. Then you'd reference common in both web and mobile.

  4. Another case for multiple GWT modules would be if you, for some reason, want to have a multiple host (entry) HTML pages. There are rare cases when you'd want this, for example when you need to do redirects when integrating OpenID. The other case would be that you already have existing Web pages where you are only adding GWT to add some functionality.

  5. Don't split the GWT project into multiple modules just to reduce download size: use Code Splitting instead.

  6. If your main gripe is long gwt compile times then read: How do I speed up the gwt compiler?

℡寂寞咖啡 2024-10-26 00:08:41

我们从多个模块开始,最终合并为一个模块。主要原因是模块的维护是一个巨大的开销。每个模块都有一个 pom 来构建 UI、RPC 层和后端服务。因此,对于 30 个模块,我们需要管理 90 个 Maven 项目。

合并模块将 90 个 Maven 项目变成了 3 个,只有一个父级 pom.xml 项目。

这大大降低了维护开销并缩短了构建时间。 GWT 的编译器非常慢,因此使用一次编译解析源文件一次而不是多次会使事情变得更快。

另一方面,单个模块意味着编译器会立即将所有内容放入内存中。如果您在代码中插入任何分割点,这可能会使查找分割点的速度变得难以忍受。因此,如果您打算拆分,可能值得考虑将这些点放在哪里并相应地安排您的项目。

We started with multiple modules and eventually merged into a single module. The main reason for this was maintenance of modules is a huge overhead. Each module had a pom to build the UI, RPC layer and backend services. So with 30 modules we had 90 maven projects to manage.

Merging the modules turned 90 maven projects into 3 with one parent level pom.

This considerably lowers maintenance overhead and improves build times. GWT's compiler is notoriously slow so having a single compile parsing source files once instead of multiple times makes things much faster.

On the flip side, a single module means the compiler slurps everything up into memory at once. This could make split points intolerably slow to find if you insert any in your code. Therefore if you intend to split, it may be worth considering where you're putting those points and arrange your project accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文