开发者

GWT - including source files outside module's package hierarchy

开发者 https://www.devze.com 2023-03-01 06:22 出处:网络
I have a GWT project in eclipse with the following structure for the GWT module com.foo.gwt -> Dashboard.gwt.xml

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?


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号