GWT Compilation of gwt project with multiple modules

182 views
Skip to first unread message

vinayak

unread,
Feb 17, 2010, 1:17:37 AM2/17/10
to Google Web Toolkit, vinaya...@gmail.com
Hello,
I am a newbie to GWT and using gwt 2.0 and now gwt 2.0.2 to
create my web application. (Actually I am converting my existing app
to a gwt app...). To do this I am trying one small example. To avoid
very large .no-cache.js file and large first page Ioad time, I have
created 1 module (e.g. MyModule) and I am using it in my main gwt
project by inheriting it. My main project name is MyModuleUsage.

Here is the code in MyModule. This has no entrypoint class. It has one
MyForm class, one DetailsService and .gwt.xml file. (given below)

public class MyForm extends Composite {
// Code to create my form
}

MyModule.xml:

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='mymodule'>
<inherits name='com.google.gwt.user.User'/>
<source path='client'/>
</module>

After creating this module, I created MyModule.jar with src and class
files as described on

http://developerlife.com/tutorials/?p=229 (Although it was for
gwt1.4 and IDEA, I could use that info on gwt 2.0 and eclipse.)

I created MyModule.jar manually by copying src and class files in
required dir structure. ( I hope there is some utility of gwt itself
to create one...please let me know if any)

Code for MyModuleUsage is as given below.

public class MyModuleUsage implements EntryPoint {

public void onModuleLoad() {
// My buttons and textboxes and tables....
MyForm myform = new
MyForm(); // This is from inherited
module.
RootPanel.get("MyMod").add(myform.asWidget());
// some more buttons...and their click handlers..
}

MyModuleUsage.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='mymoduleusage'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.mycompany.my.MyModule'/>
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<entry-point class='com.mycomany.your.client.MyModuleUsage'/>
<source path='client'/>
<source path='shared'/>
</module>

There is one more service of this project itself to handle clicks of
buttons created inside MyModuleUsage..

Now if I run MyModuleUsage then I get required output. Click on
buttons of Myform are handled by service inside MyModule and click on
buttons of MyModuleUsage are handled by service inside MyModuleUsage
as expected. This gives me a feeling that I can use MyModule as
indepedent component which I can use any other gwt project.

If I do a gwt compilation of MyModuleUsage in eclipse then generated
no-cache.js file is of 6 kb and cache.html file is of 80 kb.

If I write code to generate same UI and service inside a single module
then generated no-cache.js file is of 10 kb and cache.html file is of
230 kb.

My question is , the way I am using multiple modules to reduce files
sizes, is it correct or no ?
Second I have never gwt compiled MyModule independently. so when
exactly it gets compiled ?
where are the compiled files for MyModule.

Message has been deleted

Ashar Lohmar

unread,
Feb 19, 2010, 6:36:51 AM2/19/10
to Google Web Toolkit
the "MyModule" that will be used in MyModuleUsage module does not need
to be GWT compiled ... and even further you can't GWTcomplie it
without an entry point, but you don't need it gwt complied,
in this type of scenario myModule is compiled in java (javac) and made
a jar that has the .class files along with the .java files for the
classes in the (from the) folder that are mentioned by <source
path='client'/> tags.

when you'll GWTcompile the MyModuleUsage module GWT il put in that
compilation all the classes needed for this module to run that
includes the classes from MyModule.

that in info is on AFAIK bases, if someone knows different please
correct me.

for "My question is , the way I am using multiple modules to reduce
files sizes, is it correct or no ?" only the people working on
developing GWT could give u an correct answer, my guess is that it'
wont reduce it. but it would be usefull if you've used MyModule in
other more modules like MyModuleUsage

Hope it helps you and clears some of you questions
good luck

On Feb 19, 7:28 am, vinayak <vinayakshu...@gmail.com> wrote:
> Moderators,
>                        Nobody is answering this question. Is it that
> others can not view this thread anywhere? Do I need to do something
> more to make it viewable to others ?
> Question must be easily answerable.... Please help.
> Thanks.
>
> - vinayak

> > If I do a gwtcompilationof MyModuleUsage in eclipse then generated


> > no-cache.js file is of 6 kb and cache.html file is of 80 kb.
>
> > If I write code to generate same UI and service inside a single module
> > then generated no-cache.js file is of 10 kb and cache.html file is of
> > 230 kb.
>
> > My question is , the way I am using multiple modules to reduce files
> > sizes, is it correct or no ?
> > Second I have never gwt compiled MyModule independently. so when
> > exactly it gets compiled ?

> > where are the compiled files for MyModule.- Hide quoted text -
>
> - Show quoted text -

vinayak

unread,
Feb 19, 2010, 7:34:21 AM2/19/10
to Google Web Toolkit
Thanks Ashar.
So I can conclude following. Correct me if I am wrong.
1. There is no need to gwt compile included module. It gets gwt
compiled whenever user module is gwt compiled.
2. A gwt project can not be gwt compiled if it does not contain an
EntryPoint class.

GWT developers, please take a look at other part of the question.
Thanks in advance.

- vinayak

On Feb 19, 4:36 pm, Ashar Lohmar <asharloh...@gmail.com> wrote:
> the "MyModule" that will be used in MyModuleUsage module does not need
> to be GWT compiled ... and even further you can't GWTcomplie it
> without an entry point, but you don't need it gwt complied,
> in this type of scenario myModule is compiled in java (javac) and made
> a jar that has the .class files along with the .java files for the
> classes in the (from the) folder that are mentioned by <source
> path='client'/>  tags.
>

> when you'll GWTcompile the MyModuleUsage module GWT il put in thatcompilationall the classes needed for this module to run that

Ashar Lohmar

unread,
Feb 19, 2010, 8:15:33 AM2/19/10
to Google Web Toolkit
from my experience trying to gwtcompile an module without EntryPoint
throwed an error (don't recall which)
modules/libraries that will be used with included don't need to be
GWTcompiled. exually (don't know how to spell it)
i have noticed that running apps which had this kind of module usage
in eclipse, in the war folder i only get folders (folder with
gwtcompild code with the names given by the rename-to attribute from
the module tag) for the modules that have entry points. so even that I
use code from the other modules i don't get folders for them

also on my production server, where i deploy the app, i run the build
script that only gwtcompiles the modules with the entrypoints, an put
in the webapps\ROOT folder of the tomcat server only the content of
the war folder of my app.

for a (good/correct) gwt compile script try building a dummy app
using the command line with webAppCreator.cmd (check the params) that
will also create a build.xml file which afterwards you could modify it
to suit your needs.

good luck

> > > - Show quoted text -- Hide quoted text -

vinayak

unread,
Mar 1, 2010, 11:22:02 PM3/1/10
to Google Web Toolkit
Thanks Ashar.
Others,
please share information regarding this.

Thanks.

Reply all
Reply to author
Forward
0 new messages