0

I have a GWT game project. I'd like to pull some of the base classes out into a project that can be shared with all my other GWT game projects. Something like:

  • FarmFrenzyFinale (gwt game project)
  • AcesOverNewYork (gwt game project)
  • mylib (shared project that the above two can import)

The project "mylib" would have some generic stuff in it like maybe a euclidean distance method, maybe some other methods which operate on GWT-specific classes, like adding a Label to a RootPanel.

After reading many posts on this subject, it seems that if we want "mylib" to be included in the GWT clientside code, we need to have specific package naming, and a projectname.gwt.xml file. Should look something like:

 |- com.me.mylib
 |    |---- mylib.gwt.xml // not sure of the contents here
 |
 |- com.me.mylib.client
 |    |---- classes you want included clientside go here.

Is the above correct? If so, when creating the project in eclipse, do we just create a new "java project", or are we supposed to create a new "Web Application" project? A new "web app" project will create a standalone gwt project for us, so I'm guessing we can just do a plain old "java project" as long as we setup the structure above ok.

Then after the above is setup, we can add "mylib" to the classpath of the games (farm frenzy etc). This would be done simply as right clicking the project, properties -> java build path -> projects -> add ?

Thanks

-------- Update ---------------

This is what my project currently looks like:

AcesOverNewYork
    |-- com.me.acesovernewyork
    |      |-- acesovernewyork.gwt.xml
    |-- com.me.acesovernewyork.client
           |-- all java files here, great.

mylib (not a gwt project, just a java project)
    |-- com.me.mylib.client
           |-- Foo.java

Now AcesOverNewYork (AONY) has "mylib" added as a project in the classpath (in eclipse, right-click AONY, Properties -> Java Build Path -> Projects -> Add -> "mylib".

I use the Foo class in AONY, compiles fine. When I try to run AONY, I get a runtime error:

"No source code is available for type com.me.mylib.client.Foo; 
 did you forget to inherit a required module?"

my acesovernewyork.gwt.xml file has the following in it:

<source path='client'/>

Hmm so what else am I missing here?

Thanks

2
  • mylib, does it contain client-side code? Commented Aug 7, 2012 at 12:40
  • Yes it does, will have references to GWT classes etc. Commented Aug 7, 2012 at 13:43

2 Answers 2

0
  • For the library project, you can use a simple Java project.
  • You don't need a "mylib.gwt.xml"
  • Yes, you can simply right click the project, properties -> java build path -> projects -> add

If you put the .gwt.xml files of your games into "com.me" (within their project), and add <source path='client' />, then all you have to do is to create a "com.me.client" package both in your game projects, and in your library project.

Sign up to request clarification or add additional context in comments.

2 Comments

Ok I think this is how I've got things set up, but still get the runtime error about not being able to find classes in the referenced lib project. Updated the question above to reflect its current state.
That's because you have your .gwt.xml file in "com.me.acesovernewyork". It must be in a common base package (like "com.me"), and the "client" package must (unfortunately) be a direct subpackage of that. Then you can have e.g. "com.me.client.acesovernewyork" and "com.me.client.mylib".
0

I don't know if you've heard about maven. Actually it doesn't matter a lot but maven has a tutorial about setting up a multi-project GWT. You should check it as it contains useful info even if you don't use maven.

http://mojo.codehaus.org/gwt-maven-plugin/user-guide/multiproject.html

You can skip the POM section if you don't intend to use maven, all the rest code is pure GWT

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.