osh
osh

Reputation: 1261

Why must we specify the modules to be used in the gwt.xml files via the inherits tag?

Why must we specify the modules to be used in the gwt.xml files via the inherits tag? Isn't it enough to just import classes and the gwt compiler will just infere what the other dependencies to be included are?

Upvotes: 0

Views: 75

Answers (2)

Thomas Broyer
Thomas Broyer

Reputation: 64551

gwt.xml files contain many things that cannot be inferred from the code:

  • <source> tells which classes are expected to work in client code; the rules can be complex and you can have several gwt.xml files in the same package with different rules (overlapping or not). Actually, I'm working on modularizing gwt-user and it required a lot of those partitionning (e.g. so that you can use the Timer or Window classes without importing the whole widget set)
  • <super-source> tells GWT where it can find client-side specific implementations of classes. This is used to provide the emulation of the Java runtime, among other things (yes, the emulation of the Java runtime is (almost) entirely swappable if you think you have a better implementation of it)
  • <replace-with> and <generate-with> configures deferred binding which is used extensively in gwt-user (at a very low level to pick the fastest algorithm for StringBuilder depending on the browser, or a use requestAnimationFrame in browsers that support it, of workaround browser discrepancies, per browser; etc.)

And this is only a fraction of it.

Upvotes: 1

aglassman
aglassman

Reputation: 2653

Good question. It is better to explicitly define what GWT modules you want to have loaded. For example, If you have a dependency that has a .gwt.xml file in it and you only want to use the classes for server side things. If that .gwt.xml file in the jar was auto-loaded, then any entry points specified in that file would be loaded. This may not be what you want, and could cause unnecessary overhead in loading your gwt module.

Upvotes: 0

Related Questions