Strategies for mixing in the gwt compatible and no

2019-08-09 06:15发布

问题:

Yes i know one alternative to solving this problem is simply to create two source directories from the original. The class path for the GWT compiler would thus be setup to simply only see the compatible source while both would be used for the server portion of your app.

Firstly i find this kind of ugly, because it means i now have two source directories with potential doubles of classes.

  • refactoring and other structural abilities of the IDE can potentially be problematic as it will get confused.
  • Sometimes its not possible to put some stuff in separate packages: think client and server packages simply because one would then have to make something public which should really be package private to limit scope accessibility.
  • is there a library that enables classes or methods to marked as ignored by the GWT compiler ?

Is there a better way ?

回答1:

You can exclude classes (files actually) from GWT's source path using Ant-like includes/excludes: http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuidePathFiltering You cannot exclude methods or inner classes though, it really is file-based. See http://code.google.com/p/google-web-toolkit/issues/detail?id=3769



回答2:

Make a shared directory that has the code that both the GWT side and server side can read. Any classes that would be duplicated instead go into this folder, to be accessed (without duplication!) from both client- and server-sides of your app.



标签: java gwt gwt2