0

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!

Sir Hackalot
  • 521
  • 6
  • 16

2 Answers2

2

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" />
moh
  • 1,426
  • 2
  • 16
  • 43
  • Thanks, yes that works and that's definitely the _right_ way to go to (in fact that's how I'm doing it in another project within a larger context). But within the much smaller context my question relates to I would like to keep things as simple and lightweight as possible though. So, no chance to copy those 3rd-party into the same source folder as the rest of my GWT project, keep those 3rd-party package names, and just make GWT find them somehow? – Sir Hackalot Mar 28 '15 at 15:57
1

You need to add the other source package in your sources.

This is done in your module.gwt.xml. There is an element source, that will list all source packages to be included for client:

<source path="client" />
<source path="shared" />

will include all packages in client and shared into the frontend code.

Details can be found here: http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuidePathFiltering

Update: if your packages have no common package you need to create two seperate modules and one inherits the other.

We use this a lot, it works out very nice.

thst
  • 4,592
  • 1
  • 26
  • 40
  • Thanks. As I described, this doesn't work. I assume, that only subpackages of the GWT module's package (i.e. com.mycompany.mygwtmodule) can be used within the source tag, as the specified path seems to be combined with it for some reason I don't understand. So, custom package paths that are not subpaths of the module path will be ignored - I think. BTW doesn't seem to work either... – Sir Hackalot Mar 27 '15 at 20:36