gwt-maven for Maven 2... First draft available!

2 views
Skip to first unread message

kebernet

unread,
Feb 17, 2007, 10:00:05 PM2/17/07
to gwt-maven
Dear gentle readers of this list. I know you have all been waiting and
clamouring for it. Well, here it is.

This is a first-draft quality and we don't have full docs available...
So here is the short form...


First, you need to create a GWT profile.. In your ~/.m2/settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings>
<profiles>
<profile>
<id>gwt-1.2.22</id>
<properties>
<google.webtoolkit.home>/Users/cooper/gwt-mac-1.2.22</
google.webtoolkit.home>
<!-- you only need this is you are on a max -->
<google.webtoolkit.extrajvmargs>-XstartOnFirstThread</
google.webtoolkit.extrajvmargs>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>gwt-1.2.22</activeProfile>
</activeProfiles>
</settings>

(1.3 should work fine too).

Next you need the gwt-maven repo in your project:
...
<repositories>
<repository>
<id>gwt-maven</id>
<url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</
url>
</repository>
</repositories>
...

Next you need to declare the plugin...

<plugin>
<groupId>com.totsp.gwt</groupId>
<artifactId>maven-googlewebtoolkit2-plugin</
artifactId>
<version>1.5.0</version>
<configuration>
<logLevel>ALL</logLevel>
<runTarget>mymodule.MyModule/MyHostPage.html</
runTarget>
<compileTarget>myModule.MyModule</compileTarget>
<generatorRootClasses>mymodule.server.MyBean</
generatorRootClasses>
<generatorDestinationPackage>mymodule.client</
generatorDestinationPackage>
<generateGettersAndSetters>true</
generateGettersAndSetters>
<generatePropertyChangeSupport>true</
generatePropertyChangeSupport>
</configuration>
<executions>
<execution>
<goals>
<goal>mergewebxml</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

Because of lifecycle problems with Maven 2, the mergewebxml goal
doesn't work as well as it does in m1. If you want to use it, you need
to add this to your war plugin config:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<!-- this is where gwt-maven will spit out the
merged file -->
<webXml>target/web.xml</webXml>
</configuration>
</plugin>

Now.. A quick rundown of the goals:

gwt:gwt --- Runs the Hosted Browser/Tomcat
gwt:debug -- Runs the Hosted Browser/Tomcat blocking debugger listener
on the listener port.
gwt:compile -- Runs the compiler and builds out the module base inside
the war target folder.
gwt:mergewebxml -- Merges servlets defined in the gwt.xml def into the
web.xml from the base project, and spits out into target/web.xml
gwt:generateClientBeans -- This is the new one.
This will use reflection to examine a set of server side beans and
generate GWT annotated DTOs into the specified package in your source
directory. Important configs here:

generatorRootClasses == a comma separate list of classes to start
crawling down the object graph from.
generatorDestinationPackage == the package you want the DTOs to go
into.
generateGettersAndSetters == pretty obvious
generatePropertyChangeSupport == creates PropertyChangeListener
support (implies gettersAndSetters = true ). You need to use the GWTx
project (http://code.google.com/p/gwtx/) to get PropertChangeSupport
in your GWT classes.

It doesn't do it now, but it is our intention to make the next release
spit out a Dozer (http://dozer.sourceforge.net/) mapping file between
the client side and server side classes. It doesn't do that right now,
however.

There is still a good bit of cleanup to do, and we still need docs,
but we are ready for feedback from the people who care :).

Let the bug reports flow!

Robert "kebernet" Cooper

unread,
Feb 17, 2007, 10:05:02 PM2/17/07
to gwt-maven
Oops. I forgot one thing... Since the generateClientBeans target uses reflection, you should have done a compile beforehand:

mvn  compile gwt:generateClientBeans

--
:Robert "kebernet" Cooper
::kebe...@gmail.com
I know X better than I did. / His is the scarecrow's bitter mouth  / sewn shut in cross-stitch;
the footprint of a weasel on snow.
X is the unknown assailant.
X marks the spot / toward which we speed like trains, /  at a fixed rate.
--Linda Pastan
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x9E8759F8

rusty

unread,
Feb 18, 2007, 7:39:45 PM2/18/07
to gwt-maven
Hi Robert,

Nice work! I must admit I was skeptical when you said you'd get it
done over the weekend, but I guess I shouldn't have been.

I'm just trying it out at the moment and have 2 quick questions:
- Is there a way to specify where the compiled html files will go to.
Currently they all end up in a folder called
my.package.whatever.ModuleName. I know GWT does this by default, but I
was almost certain there was a way to change this? (say I wanted it to
go in a folder just called 'ajax' or something)
- Is there a reason it might run differently during a mvn compile vs a
mvn gwt:compile. For me the gwt:compile works fine but the mvn compile
just exits really quickly with a status of 1.

I'm still new to maven2 so both of these issues could just be my lack
of experience showing through.

Rusty

On Feb 18, 1:05 pm, "Robert \"kebernet\" Cooper" <keber...@gmail.com>
wrote:


> Oops. I forgot one thing... Since the generateClientBeans target uses
> reflection, you should have done a compile beforehand:
>
> mvn compile gwt:generateClientBeans
>
> --
> :Robert "kebernet" Cooper

> ::keber...@gmail.com

rusty

unread,
Feb 18, 2007, 7:53:41 PM2/18/07
to gwt-maven
I figured out the second question. It was just my ignorance at play: I
had the task running in the wrong phase of the maven build process. I
still can't figure out my first question though.

Robert "kebernet" Cooper

unread,
Feb 18, 2007, 11:09:50 PM2/18/07
to gwt-...@googlegroups.com
Well yes! Any problem you have is all your fault!

The general idea is for GWT prjects to be WAR projects in M2. If you are doing a JAR deal, it can be entirely different. If you are trying to build something as a lib and getting a no-source jar... I understand you but I guess I need to re-def the module.

kebernet

unread,
Feb 19, 2007, 8:23:33 AM2/19/07
to gwt-maven
Er. and as to the package name in the path, I can't really control
that since that is how GWTCompile places it. I suppose I could make
the plugin manually rename the directory after it is built.

On Feb 18, 11:09 pm, "Robert \"kebernet\" Cooper" <keber...@gmail.com>
wrote:


> Well yes! Any problem you have is all your fault!
>
> The general idea is for GWT prjects to be WAR projects in M2. If you are
> doing a JAR deal, it can be entirely different. If you are trying to build
> something as a lib and getting a no-source jar... I understand you but I
> guess I need to re-def the module.
>

rusty

unread,
Feb 19, 2007, 6:52:27 PM2/19/07
to gwt-maven
I hope the food here is better than the service ;)

Thanks again for the plugin. In a funny coincidence I was planning to
integrate the GWT code that I've been working on into my main project
which is built with maven 2. Lo and behold the very day I need to do
that you release a working version of the plugin, with some
documentation. And it works first time. *nice*. A rename feature would
be nice, but not essential at this stage.

Rusty

Reply all
Reply to author
Forward
0 new messages