Export war in GWT using maven


GWT is a framework for building large and high performance rich internet application (RIA) in comes under rapid development mode. But the structure of the project is not similar to traditional J2EE web application project. The one main problem is to export the GWT project as a war in eclipse is tricky.
The simple solution is to build the project under the control of maven, will solves your problem. Also you can inherits the maven features into your GWT project. I assume that, the reader of this blog having base knowledge of Maven. Below tutorial and screen-shots helps you to create the GWT-Maven project  within minutes. For this tutorial, i have used Spring Tool Suite (STS), you can use other Eclipse IDEs also.
 In STS/Eclipse, Choose File -> New -> Other -> Maven -> Maven Project
       
 Choose the GWT Maven archetype from the available list

       Under the next wizard, archetype parameters, give Group Id, Artifact Id and Module Name & value.
 The module value that you have given in the wizard, will be your web module name and html & css file names looks like ‘mygwt.html’ & ‘mygwt.css’. The project structure will similar of the below screen.
Maven will create the three default packages – client, server & shared. The plugin has some problem to create the Async java file by default. Your code throws an error
Need not to worry, There are some gwt maven goals are available to make it to the running mode. The goals are,
                                       * gwt:generateAsync
                                       * gwt:i18n
Execute the above two goals, by right-clicking on the project and open ‘Run Configuration’ wizard. Create the new maven configurations.
 Create the goal for i18n same like generateAsyn goal. These goals will automatically creates the classes, “GreetingServiceAsync.java” & “Messages.java”  under  ../target/generated-sources/…/client/
Copy these files and paste it into the client package. Now, the IDE resolves the error by recognizing these classes. Now your GWT with maven structured project is ready to test and package as a war file. There is one another maven goal by enabling the GWT development environment. The goal name is  “gwt:run”.  The development mode and web app running in below screens.
Copy the URL / click the “Launch Default Browser” button, now you will be able to see the application running on the browser.

Now the development is got completed, you need to package your project as a war file. This is very simple to build using the maven command. Execute the goal, ‘clean compile package’ in the ‘Run Configuration’ wizard. These set of goal, will clean your target, compile the packages – all permutations and builds the package as war.
Packaged war will have the proper structure and can deploy the war without any issues on the Catalina container.