Monday, October 26, 2015

How to Create, Compile and Run GWT applicaiton using Maven and Eclipse

Step 1:- Make sure you had already installed Apache MAVEN in your machine. We can download Apache MAVEN from https://maven.apache.org/download.cgi
Once you installed Apache MAVEN you will be able to see this folder structure.
Image_1

Step 2- Make sure you have installed m2eclipse plugin for Eclipse. Once you installed this in ecplise you will be able to right click and then run and debug the application while running it as Maven projects. In STS IDe it is by default available.
The goal of the m2ec project is to provide a first-class Apache Maven support in the Eclipse IDE, making it easier to edit Maven's pom.xml, run a build from the IDE and much more.
Source: http://eclipse.org/m2e/
Step 3:- Install gwt maven plugin gwt-maven-plugin-2.7.0.jar download the same from the http://mvnrepository.com/artifact/org.codehaus.mojo/gwt-maven-plugin/2.7.0
First we need to install this plugin before using the same in Eclipse. for doing this use this command.
Go to bin folder of your installed maven
C:\apache-maven-3.2.5\bin>mvn install:install-file -DgroupId=org.codehaus.mojo -DartifactId=gwt-maven-plugin -Dversion=2.7.0 -Dpackaging=jar -Dfile=C:/to_delete/gwt-maven-plugin-2.7.0.jar
Image_2
=============You will see following message ===================================
C:\apache-maven-3.2.5\bin>mvn install:install-file -DgroupId=org.codehaus.mojo -DartifactId=gwt-maven-plugin -Dversion=2.7.0 -Dpackaging=jar -Dfile=C:/to_delete/gwt-maven-plugin-2.6.0-rc1.jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing C:\to_delete\gwt-maven-plugin-2.7.0.jar to C:\Users\XXXX\.m2\repository\org\codehaus\mojo\gwt-maven-plugin\2.7.0\gwt-maven-plugin-2.7.0.jar
[INFO] Installing C:\Users\XXXX\AppData\Local\Temp\mvninstall1372865269736446628.pom to C:\Users\XXXX\.m2\repository\org\codehaus\mojo\gwt-maven-plugin\2.7.0\gwt-maven-plugin-2.7.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.995 s
[INFO] Finished at: 2015-10-26T12:25:25+05:30
[INFO] Final Memory: 6M/119M
[INFO] ------------------------------------------------------------------------

Step 4:- Restart your eclipse and create a new MAven Project
right click --> new --> other -->Maven -->Maven Project-->Next-->Select our Maven installed files (refer to the below image)-->Fill all necessary information and
Image_3 Image_4 Image_5
Step 5:- After this project wil be created in Eclipse as shown below
Image_6
Step 6:- In our created project we found that their is no GreetingServiceAsync . We must generate them by triggering a Maven command or let Maven generate them automatically for you.i.e. gwt:generateAsync
right click on proect-->Run configuration --> inside MAven--> see below screen and click run
Image_7
on success we will see this on console prompt
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building GWT Maven Archetype 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- gwt-maven-plugin:2.7.0:generateAsync (default-cli) @ gwt-maven-plugin ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.684 s
[INFO] Finished at: 2015-10-26T14:14:16+05:30
[INFO] Final Memory: 12M/150M
[INFO] ------------------------------------------------------------------------

Step 7:- Finally run install command of maven to create build
right click on proect-->Run configuration --> inside MAven--> see below screen and click run
Image_8
we will get this log.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 41.543 s
[INFO] Finished at: 2015-10-26T14:17:03+05:30
[INFO] Final Memory: 27M/195M
[INFO] ------------------------------------------------------------------------

Deploy our build on tomcat and see the screen
Image_9

No comments: