webapp project setup with GWT using maven

1 view
Skip to first unread message

Bruno Waes

unread,
Jun 5, 2007, 9:49:40 AM6/5/07
to gwt-maven
I am using maven for a few months now and i am really happy with the
way it works.

With the default "mvn archetype:create" i setup several projects that
result into jars.
With the "mvn archetype:create -DarchetypeArtifactId=maven-archetype-
webapp" i create a webapp project and then change the pom to make it
depend on the other jar-projects. So when i run "mvn package" i get a
nice war file, with everything in place.
My webapp project doesn't contain any java classes, basicly its just
where i wire my application together using Spring, store my freemarker
templates, ...

I havn't really found a way i like to integrate GWT projects. Basicly
its just java code so i was thinking of setting up a normal java
project, the client and server classes go into src/main/java, the
*.gwt.xml files go into /src/main/resources. All that creates a nice
jar that i can include in my webapp.
But somehow i also need to GWTCompile the client code ... and from
what i understand that can only be done from the source files. So i
would need to run the GWTCompile from this project and then add the
output to a resulting zip-type artifact or something ? so this project
would result in both a jar and a zip artifact ? (as i am quite new to
Maven i dont know if this still makes sense). Ideally a "mvn install'
would put both the jar and the zip in my maven repository so i can
have my webapp depend on them.
When building my webapp project afterwards, it should unzip the zip
artifact into the target directory. (I ll take care of the web.xml
file manually.)

Does my thinking above make any sense ?
How do you guys setup your larger projects ?

Thanks for reading this far and your replies.

Brill

unread,
Jun 6, 2007, 9:26:53 AM6/6/07
to gwt-maven
The deployable webapp will need at least a GWT entrypoint so it can
compile the clientside code into the webapp.
You can still maintain your separation of artifacts if you want to.
Simply write all your GWT code in another module (don't forget to
include the source when you package it into a jar), and in your
webapp, simply create a single entrypoint which loads you application
code.

It will be harder to develop the code this way however... because it
means you will have to write code in the dependent module, install it
and compile/run the webapp module.

What I tend to do is to write my client code in the webapp module, and
when I have something static or reusable, move it to a dependent
library (gwt module).
Unfortunately, simply the way GWT works and its nature make good
practice hard to achieve exactly as you want to do it :)

One approach I've been toying with (but don't have set up for serious
work yet) is to separate the GWT into its own module and develop with
a test entrypoint, then just build it as a jar or change the type to
jar to deploy it... a bit of a pain any way you slice it.

What would work I think, is a maven plugin that could merge war
files :)

- Brill

Bruno Waes

unread,
Jun 6, 2007, 12:12:55 PM6/6/07
to gwt-maven
I actually havnt been sitting still since i posted that message

original messave on maven user group:
http://mail-archives.apache.org/mod_mbox/maven-users/200706.mbox/%3cb7f109310706050845n7a...@mail.gmail.com%3e

a few hours later my own reply to the group:
http://mail-archives.apache.org/mod_mbox/maven-users/200706.mbox/%3cb7f109310706060120u19...@mail.gmail.com%3e

this is a way to have gwt in a seperate project with the dependencies
set up correctly.

of course this way you cant use the feature to merge web.xml file but
i actually dont need that. as in my webapp project there are only my
spring beans config files, and my web.xml file, and as i am using
spring i dont have any gwt specific servlets in my web.xml, springs
Dispatcher servlet takes care of that.

i plan on writing this out a little more comprehensivly on a blogpost
in the following days, because i think its quite a nice way of working
with larger GWT projects in a m2 environment.

bruno

On Jun 6, 3:26 pm, Brill <b...@pappin.ca> wrote:
> The deployable webapp will need at least a GWT entrypoint so it can
> compile the clientside code into the webapp.
> You can still maintain your separation of artifacts if you want to.
> Simply write all your GWT code in another module (don't forget to
> include the source when you package it into a jar), and in your
> webapp, simply create a single entrypoint which loads you application
> code.
>
> It will be harder to develop the code this way however... because it
> means you will have to write code in the dependent module, install it
> and compile/run the webapp module.
>
> What I tend to do is to write my client code in the webapp module, and
> when I have something static or reusable, move it to a dependent
> library (gwt module).
> Unfortunately, simply the way GWT works and its nature make good
> practice hard to achieve exactly as you want to do it :)
>
> One approach I've been toying with (but don't have set up for serious
> work yet) is to separate the GWT into its own module and develop with
> a test entrypoint, then just build it as a jar or change the type to
> jar to deploy it... a bit of a pain any way you slice it.
>

> What would work I think, is amavenplugin that could merge war
> files :)
>
> - Brill
>
> On Jun 5, 9:49 am, Bruno Waes <bruno.w...@gmail.com> wrote:> I am usingmavenfor a few months now and i am really happy with the


> > way it works.
>
> > With the default "mvn archetype:create" i setup several projects that
> > result into jars.
> > With the "mvn archetype:create -DarchetypeArtifactId=maven-archetype-
> > webapp" i create a webapp project and then change the pom to make it
> > depend on the other jar-projects. So when i run "mvn package" i get a
> > nice war file, with everything in place.
> > My webapp project doesn't contain any java classes, basicly its just
> > where i wire my application together using Spring, store my freemarker
> > templates, ...
>
> > I havn't really found a way i like to integrate GWT projects. Basicly
> > its just java code so i was thinking of setting up a normal java
> > project, the client and server classes go into src/main/java, the
> > *.gwt.xml files go into /src/main/resources. All that creates a nice
> > jar that i can include in my webapp.
> > But somehow i also need to GWTCompile the client code ... and from
> > what i understand that can only be done from the source files. So i
> > would need to run the GWTCompile from this project and then add the
> > output to a resulting zip-type artifact or something ? so this project
> > would result in both a jar and a zip artifact ? (as i am quite new to

> >Maveni dont know if this still makes sense). Ideally a "mvn install'
> > would put both the jar and the zip in mymavenrepository so i can

Brill

unread,
Jun 7, 2007, 10:50:46 AM6/7/07
to gwt-maven
Something went a little wonky with those links, but I'm glad you found
a solution.
I'd be very interested in how you set it up.

- Brill

On Jun 6, 12:12 pm, Bruno Waes <bruno.w...@gmail.com> wrote:
> I actually havnt been sitting still since i posted that message
>
> original messave on maven user group:

> http://mail-archives.apache.org/mod_mbox/maven-users/200706.mbox/%3cb7f109310706050845n7acdb0c4j97695abebd264...@mail.gmail.com%3e


>
> a few hours later my own reply to the group:

> http://mail-archives.apache.org/mod_mbox/maven-users/200706.mbox/%3cb7f109310706060120u197f028by974e797e87554...@mail.gmail.com%3e

Bruno Waes

unread,
Jun 7, 2007, 11:31:59 AM6/7/07
to gwt-maven

On Jun 7, 4:50 pm, Brill <br...@pappin.ca> wrote:
> Something went a little wonky with those links, but I'm glad you found
> a solution.
> I'd be very interested in how you set it up.
>
> - Brill


lets try this url

http://www.nabble.com/using-zip-assembly-for-GWTCompile-output-tf3872577s177.html

bruno

Werner Thiemann

unread,
Aug 1, 2007, 11:22:42 AM8/1/07
to gwt-maven
You could also have solved your problem with the attached assembly id
while building the .zip by adding this line into the <configuration>
of your assembly plugin:
<appendAssemblyId>false</appendAssemblyId>

(sorry, I can't comment on the original post, so I put it here)

saludos
Werner

> http://www.nabble.com/using-zip-assembly-for-GWTCompile-output-tf3872...
>
> bruno

Reply all
Reply to author
Forward
0 new messages