Saturday, January 28, 2017

Re: GWT/Maven: No source code is available for type junit.framework.Test; did you forget to inherit a required module?

I'd start with a new maven project "mylib", which is based on a simple archetype-quickstart maven stub, and I'd add two subfolders under src/main/java/mylib:
  • src/main/java/mylib/general
  • src/main/java/mylib/web
Then, I'd add the following file:


...with the following content:

  <inherits name=''/>
  <source path='web'/>

Then, I'd include mylib.general.* for server-side code, and mylib.web.* for GWT-based code.

Would this be the right way?
Could I place server-side only code under general (e. g. database related code) and GWT-based code under web?
(I still feel that the GWT compiler then would "ignore" the code under the general folder, doesn't it?)

That would work, as long as src/main/java/mylib or src/main/java/mylib/general is not exposed to GWT compiler by any other GWT module you might have. With the above only src/main/java/mylib/web would be analyzed and compiled by GWT compiler. Its basically the same as with using client, shared and server folder but the *.gwt.xml only makes the client and shared folder visible to the GWT compiler.

An alternative approach for library code is to not split the code up into distinct packages like you did but instead use an annotation and then build two different jar's (one that only contains GWT code, and another only containing code incompatible to GWT) by reading the annotation. That is basically the approach Guava uses to build guava.jar and guava-gwt.jar.

-- J.

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment