Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse 3.4 GWT 1.6 project - how to reference source from other projects?

Tags:

eclipse

gwt

I've got a GWT 1.6 project in Eclipse 3.4 and am trying to reference source from another (non-GWT) project in my workspace. I've added the project to my build path, but I can't run the application in hosted mode. When I do, I get a "no source code is available" error.

I've done some searching and reading and have tried a few things that others have suggested (including creating a jar from the dependent project and linking to it), but frankly nothing has worked.

If you're actually doing this, could you please help me out with a simple step-by-step setup? I'd really appreciate it, thanks!

like image 815
Boden Avatar asked Jun 04 '09 17:06

Boden


2 Answers

I have 2 Eclipse Projects. One is gwt project and one is not. Here's the directory structure that works for me:

workspace
-- gwt-project
   -- src/main/java
      -- com.gwt.GwtProjectModule
         -- GwtProjectModule.gwt.xml
-- non-gwt-project
   -- src/main/java
      -- com.nongwt.package.that.contains.source.you.need
         -- nongwt.gwt.xml
      -- com.nongwt.package.that.contains.source.you.need.client

nongwt.gwt.xml tells gwt to look inside "client" package, here's what it looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='nongwt'>
    <inherits name='com.google.gwt.user.User' />
    <source path="client" />
</module>

GwtProjectModule.gwt.xml can then inherit source code from nongwt. Here's the relevant line from inside GwtProjectModule.gwt.xml:

<inherits name="com.nongwt.package.that.contains.source.you.need.nongwt" />

Make sure you include non-gwt-project inside gwt-project's classpath in eclipse. It's the normal drill; right click on gwt-project, choose properties, choose "Java Build Path", click "Projects" tab, and "non-gwt-project"

Or, instead of including non-gwt-project in gwt-project's classpath as a project reference, you can also jar the contents of non-gwt--project, ensure that you include the source in the jar, and then include the jar in gwt-project's classpath.

Good Luck!

like image 64
Upgradingdave Avatar answered Nov 09 '22 20:11

Upgradingdave


I know this post is quite old but as I spent quite a lot of time on this issue and finally found the way to do it, I thought I might share the answer :

once you've created your launch configuration, open it run>run configurations... go to classpath tab and select user entries. add advanced>folder and select the source folder of your other module project. If as me you've separated the module conf file in a src/main/resources folder you have to add it as well.

should work.

like image 27
Fabrice Dewasmes Avatar answered Nov 09 '22 22:11

Fabrice Dewasmes