Jagadeesh
Jagadeesh

Reputation: 2800

How to use source code of one gwt application in to another application

I have two different gwt projects, and want to use classes of one gwt application in to an another module. Is there any way to do that?

I followed the below approach, added below two lines in the second project

   <inherits name="com.yellowbook.mdb.NationalResidential"/>
   <source path='com.yellowbook.mdb' />

but i am getting the following error:

 Unable to find 'com/yellowbook/mdb/NationalResidential.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

did i miss any thing here?

Upvotes: 2

Views: 199

Answers (2)

bNd
bNd

Reputation: 7630

If you want to use a one project into another one, then following are some of possible ways:

First approach

If you are using two projects as a separate module i.e. GWT Module, then you can create a package structure for common code and add entry into gwt.xml file.

ProjectModule1.gwt.xml

 <source path='shared'/>

ProjectModule2.gwt.xml

 <source path='shared'/>

Second approach

If you created separate project for this, then

In development:

  1. Add module entry in gwt.xml file, i.e.

    <inherits name='com.project2'/> //same for project 1
    
  2. Also if you working with eclipse, then add required project in build path for development

In Production:

  1. You need to create a jar and add to classpath for both the project.

But if you go with second approach, then it is not a very good approach, because when you want to load a project1 then project2 auto load and unnecessary javascript will load, so better to use module approach, or create a third project which has a common code of project1 & project2 and use it in both projects.

Upvotes: 1

devrys
devrys

Reputation: 1617

Beside copy and paste you could write a third GWT module that implements the classes and inherit this new module in both applications. This way you can re-use it anywhere you want.

Upvotes: 2

Related Questions