GWT - 包括模块包层次结构之外的源文件
我在 Eclipse 中有一个 GWT 项目,其 GWT 模块结构如下
com.foo.gwt -> Dashboard.gwt.xml
com.foo.gwt.client
com.foo.gwt.server
我有不同的包 com.bar.baz1
、com.bar.baz2
等,其内容我想要包含在客户端代码中。所有文件都兼容 GWT JAVA->JS 转换。
问题是
I have a GWT project in eclipse with the following structure for the GWT module
com.foo.gwt -> Dashboard.gwt.xml
com.foo.gwt.client
com.foo.gwt.server
I have different packages com.bar.baz1
, com.bar.baz2
, etc. whose contents I want to include in client side code. All the files are GWT JAVA->JS conversion compatible.
The problem is that the <source> tag in Dashboard.gwt.xml, treats the path as relative to the directory of Dashboard.gwt.xml
. So I cannot reference anything outside com.foo.gwt
hierarchy.
So I created a new module MyNewModule.gwt.xml
in com.bar
and included baz1
and baz2
sub packages using relative paths in tag. Finally I made Dashboard.gwt.xml to inherit the new module.
This works fine when I compile the Dashboard module but fails when I compile MyNewModule.
That's because some classes in MyNewModule reference classes of Dashboard module.
I tried inheriting Dashboard module in MyNewModule. This creates a circular reference, but GWT doesn't complain about it. Everything works but I am not comfortable with the circular reference. I don't need MyNewModule, all I need is a way to include code from packages outside Dashboard module's hierarchy.
I am wondering why GWT does not allow absolute source paths.
Am I missing something here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要单独编译每个模块。当您编译 com.foo.gwt 项目时,GWT 编译器将在 com.foo.gwt.xml 文件中查找所有依赖项,并编译 com.foo 和 com.bar.baz 中的所有 .java 文件。 (和其他库)到 javascript。
正如您所说,将 MyNewModule.gwt.xml 放入 com.bar.baz 项目并在 DashBoard.gwt.xml 文件中“继承”它是正确的。您缺少的部分是使用 MyNewModule 项目制作一个 .jar 文件并将其放入 war/WEB-INF/lib 文件夹(只是 gwt.xml 文件和编译的 java 类)。
You dont need to compile each module separately. When you compile your com.foo.gwt project, GWT compiler will look for all dependencies in your com.foo.gwt.xml file and will compile ALL .java files both your com.foo and com.bar.baz. (and other libraries) to javascript.
As you said, its correct to put MyNewModule.gwt.xml in the com.bar.baz project and "inherit" it in your DashBoard.gwt.xml file. The part you are missing is to make a .jar file with MyNewModule project and put in war/WEB-INF/lib folder (just gwt.xml file and compiled java classes).