Search code examples
gwtgwt-hosted-mode

How can I use a custom package structure in a GWT project?


I'm using the regular GWT project structure that is generated when creating a new GWT project via the Eclipse GWT plugin, e.g. com.mycompany.mygwtmodule.client for all the client stuff that is GWT-compiled into JavaScript.

Now I want to add some client code with a custom package structure, e.g. org.othercompany.somepackage...

Is that doable? And, if so, how?

I don't need a workaround, if it's not doable. However, it may still be helpful for you to know, why I want to do this: The custom package structure is from a 3rd-party GWT module that is used by my GWT project. I just need a small set of classes from it which I copied into my project instead of including the whole module which contains lots of stuff I don't care about. Those classes are using each other. As I do not want to touch their code at all, I am keeping their original package structure.

What I tried is to add <source path='my-eclipse-project-path/src/org/othercompany/somepackage'/> to my gwt.xml, but in hosted mode I'm getting the error: "No source code is available for type org.othercompany.somepackage.SomeClass; did you forget to inherit a required module?" No, I didn't ;-) The code is all there, but I couldn't make GWT find it.

Thanks for any helpful comments!


Solution

  • Its Better you create two separate modules ,since you are taking the code from some other 3rd party jar. First create module which contain the package structure - com.mycompany.mygwtmodule (one module) Second create another module -org.othercompany.somepackage (another module)

    Inherit the second module in first module.gwt.xml

     <inherits name="org.othercompany.somepackage" />