Difference between revisions of "Create a new Mavenized gCube GWT Portlet Guide"

From Gcube Wiki
Jump to: navigation, search
(Preface)
Line 2: Line 2:
 
This guide is mostly about '''how to make''' the '''Google Eclipse Plugin''', '''Eclipse''' and '''Maven''' work '''together'''. Which could not be trivial.
 
This guide is mostly about '''how to make''' the '''Google Eclipse Plugin''', '''Eclipse''' and '''Maven''' work '''together'''. Which could not be trivial.
  
This guide was tested with Eclipse 3.7 Indigo EE, on MacOS 10.6.8 with Java 6.  (only 3.7+ is supported)
+
This guide was tested with Eclipse 3.7 Indigo EE (3.7+ is supported), on MacOS 10.6.8 with Java 6.   
  
 
The Google official Notes on working with GWT, Maven, and Google Plugin for Eclipse are available at this [http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven#Configure_a_Maven_project_in_Eclipse link]. Use it for Troubleshooting and to get an overview of what you're going to do.
 
The Google official Notes on working with GWT, Maven, and Google Plugin for Eclipse are available at this [http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven#Configure_a_Maven_project_in_Eclipse link]. Use it for Troubleshooting and to get an overview of what you're going to do.

Revision as of 11:37, 24 December 2012

Preface

This guide is mostly about how to make the Google Eclipse Plugin, Eclipse and Maven work together. Which could not be trivial.

This guide was tested with Eclipse 3.7 Indigo EE (3.7+ is supported), on MacOS 10.6.8 with Java 6.

The Google official Notes on working with GWT, Maven, and Google Plugin for Eclipse are available at this link. Use it for Troubleshooting and to get an overview of what you're going to do.

What you need

Maven Plugin for Eclipse (m2e)

Install the following plugin on your Eclipse:

I am using the latest stable releases from eclipse.org although the current WTP integration is still in incubation… but works.

Talking numbers, these are the version numbers I used:

  • m2e – Maven Integration for Eclipse 1.2.0.20120903-1050
  • m2e-wtp – Maven Integration for WTP (Incubation) 0.16.0.20120914-0945
  • m2e connector for mavenarchiver pom properties 0.15.0.201207090125-signed-201209140800

Google Plugin for Eclipse (GPE)

Google Plugin for Eclipse (GPE) makes it easy to import Maven projects using GWT and App Engine. To get started, first install GPE and the additional Eclipse plugins required for your version of Eclipse (remember that only Indigo+ is supported)


Project creation

Create a new maven project, when prompted for selecting the archetype type 'org.codehaus.mojo' and select the gwt-maven-plugin as shown in the picture below (select 2.4.0 is you use GWT 2.4) :

Archetype.png

Click next and enter the maven coordinates for your artifact, see below for an example:

Coordinate.png

Hit finish and the gwt-maven-plugin will create a sample gwt project for you. If you use Indigo at a certain point it will fail creating the goal i18n and the goal generateAsync, this should not happen with Eclipse Juno. Don't worry, you don't need Juno just do the following:

  • open your pom.xml, locate the GWT Maven Plugin <plugin> node and delete the goals generating errors (generateAsync, i18n) see picture below:

Goals.png

  • Open the GreetingService interface and generate its related ServiceAsync:

Async.png

  • Open your entrypoint class and make it compile by :
    • deleting this line: private final Messages messages = GWT.create(Messages.class);
    • inserting explicit stings in the sendButton constructor and setText methos as shown below:

Emoty.png

Project first run

Now if you try to Run your project as a web application you will notice that also the web.xml is not complete, add what is suggested by the console n web.xml and everything should work fine, click the button and make sure the servlet communication works:

Fine.png

Maven Goals (Create your Web Archive)

  • goal gwt:compile
    • GWT Compile mode In order to gwt:compile your portlet create a Maven Build Configuration and enter gwt:compile on the goal text box.
  • goal package
    • package will generate the war for you in the target folder.
  • goal deploy
    • to use the deploy goal please refere to the gCube Maven Guide as you would need to create a distro folder with specific files in it.

Working example

An actual working example, that could be helpful for you, is the following project:

   <groupId>org.gcube.portlet.user</groupId>
  <artifactId>my-vres</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <type>war</type>

the project can be imported in your eclipse by using svn with this URL: