So the steps to do to solve this problem are the following:
- Create a gwt.xml file in the Java project / jar file that we want to use.
- Include the library inheriting the module created at the step before.
- Include in the jar the source files.
Example: if we have the package it.unitn.example.utils and we want ot inform the GWT compiler about the classes that it includes we need to create in the package it.unitn.example the file utils.gwt.xml, containing the following code:
<module> <inherits name='com.google.gwt.user.User'/> <source path="utils"></source> </module>
Then if we want to use this module in a GWT project we only need to inherits it as for the other modules:
package it.unitn.example.application.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import it.unitn.example.utils.ExUtilClass; public class ModulTest implements EntryPoint { @Override public void onModuleLoad() { ExUtilClass utilClass = new ExUtilClass(); // doing something with utilClass }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6.4//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module rename-to='it.unitn.example.application'> <!-- Inherit the core Web Toolkit stuff. --> <inherits name='com.google.gwt.user.User'/> <inherits name='com.google.gwt.user.theme.standard.Standard'/> <inherits name='it.unitn.example.utils'/> <!-- Other module inherits --> <!-- Specify the app entry point class. --> <entry-point class='it.unitn.example.application.client.AppExample'/></module>
Nessun commento:
Posta un commento