Introduction maven3 and gwt2.5 rc2 - Lesson 01

32
Introduction to Apache Maven 3 and GWT 2.5-rc2 Lima, Perú 12/10/2012 Juan Manuel Rojas R. http://rhemsolutions.com/

description

First Part of GWT Course

Transcript of Introduction maven3 and gwt2.5 rc2 - Lesson 01

Page 1: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Introduction to Apache Maven 3 and GWT 2.5-rc2

Lima, Perú 12/10/2012Juan Manuel Rojas R.http://rhemsolutions.com/

Page 2: Introduction maven3 and gwt2.5 rc2 - Lesson 01

MavenIs a build automation tool typically used for Java projects.Maven dynamically downloads Java libraries and Maven plug-ins from one or more repositories such as the Maven 2 Central Repository search.maven.orgMaven use an XML file to describe the software project being built, dependencies, plugins, etc.Pluginsmvn [plugin-name]:[goal-name]

Page 3: Introduction maven3 and gwt2.5 rc2 - Lesson 01

POM.xml(Project Object Model)

Page 4: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Installing the JDK

WindowsDownload the JDK installer for Windows from http://www.oracle.com/technetwork/java/javase/downloads/jdk7u7-downloads-1836413.html

Run the installer

Add the bin\ directory of the installed JDK to the PATH environment variable, as described here: http://www.java.com/en/download/help/path.xml

To verify the JDK installation, open the Command Prompt and type java -version.

Page 5: Introduction maven3 and gwt2.5 rc2 - Lesson 01
Page 6: Introduction maven3 and gwt2.5 rc2 - Lesson 01
Page 8: Introduction maven3 and gwt2.5 rc2 - Lesson 01

The Maven Integration for Eclipse (m2eclipse, Eclipse m2e)

Update Sitehttp://download.eclipse.org/technology/m2e/releases

Open eclipseHelp - Install New SoftwareAdd Name : m2eLocation: http://download.eclipse.org/technology/m2e/releases

Select all and Next

Page 9: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Using the Archetype

mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.5.0-rc2

Page 10: Introduction maven3 and gwt2.5 rc2 - Lesson 01

New Project

Page 11: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Run dev mode

Page 12: Introduction maven3 and gwt2.5 rc2 - Lesson 01
Page 13: Introduction maven3 and gwt2.5 rc2 - Lesson 01
Page 14: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Import inEclipse

If Eclipse ask to install a connector -> installthen restart eclipse

Page 15: Introduction maven3 and gwt2.5 rc2 - Lesson 01
Page 16: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Add this lines<extraJvmArgs>-XX:MaxPermSize=512m -Xmx1024m</extraJvmArgs><generateDirectory>${project.build.sourceDirectory}</generateDirectory>

Page 17: Introduction maven3 and gwt2.5 rc2 - Lesson 01

<compilerArgument>-proc:none</compilerArgument>required by JPA

Page 18: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Setting the locale

Add to GWT module<extend-property name="locale" values="es_PE"/>(after entry point)

In HTML file Header (src/main/webapp/FirstProject.html)<meta name="gwt:property" content="locale=es_PE">

RenameMessages_fr.properties to Messages_es_PE.properties

Page 19: Introduction maven3 and gwt2.5 rc2 - Lesson 01

GWT taskmvn gwt:i18nGenerate Messages.java interfaz from Messages.properties and Messages_es_PE.properties

mvn gwt:runRun Dev Mode. Firefox is recommended and install the GWT Developer Plugin (don't update your browser) GWT DevMode Plugin for Firefox 16Optional parametermvn gwt:run -Dgwt.codeServerPort=9997

Page 20: Introduction maven3 and gwt2.5 rc2 - Lesson 01

GWT task (Continuation)

mvn packageBuild the war file of the application in target directory.

Page 21: Introduction maven3 and gwt2.5 rc2 - Lesson 01

GWT dev mode

Page 22: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode

New in GWT 2.5. works in any browser, plugins is not required.

Add to gwt module

<add-linker name="xsiframe"/><set-configuration-property name="devModeRedirectEnabled" value="true"/>

remove or comment the last line in production

Page 23: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)

Compile the application for first timemvn package

Start the code servermvn gwt:run-codeserveror mvn gwt:run-codeserver -Dgwt.codeServerPort=9876The code server is ready.Next, visit: http://localhost:9876/

Page 24: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)

Add to bookmarks (Drag and Drop)I am using Chrome

Page 25: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)

Start the web server (without stop the server code)mvn gwt:run

We use jetty. e.g. Chromehttp://127.0.0.1:8888/FirstProject.htmlwithout?gwt.codesvr=127.0.0.1:9997(hosted mode)

Page 26: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)

Dev Mode On

Dev Mode Off to clear cache

click

Page 27: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)

Play with some changes to client code and test with Dev Mode On. Update the browser is no longer required

Page 28: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)

Chrome Developer tools you can see the code generated

Page 29: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)

For see java code

Enable source maps in settings

Page 30: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)

Recompile super dev mode with source maps enabled.Click Dev Mode On

Page 31: Introduction maven3 and gwt2.5 rc2 - Lesson 01

Super dev mode (Continuation)