Tuesday, July 14, 2009

Installing GWT 1.7 with Maven2



Change pom.xml:

<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>1.7.0</version>
</dependency>

RUN Maven2 (via Ant) to see missing dependencies:



<property name="GOOGLE_WAR" value=".\\war" />
<property name="MAVEN_TARGET" value=".\\target" />
<property name="GOOGLE_SRC" value=".\\src" />
<property file=".\\maven\\resources\\${user.name}.properties" />


<target name="prepare">
<echo>Make sure you have set up Maven Executable in .\\maven\\resources\\${user.name}.properties</echo>
<echo>Your mvn exe is set to ${MAVEN_EXEC}</echo>
<!-- resources:resources filters the files in the resources directory and copies them to target/classes -->
<!-- dependency:copy-dependencies copies the dependencies to the target/dependency folder -->
<exec taskname="mvn war" dir="${basedir}"
executable="${MAVEN_EXEC}">
<arg line="clean resources:resources dependency:copy-dependencies -Dtarget=${TARGET}" />
</exec>
<delete dir="${GOOGLE_WAR}\\WEB-INF\\lib" />
<!-- copy the maven depenecies to the war/WEB-INF/lib folder -->
<copy todir="${GOOGLE_WAR}\\WEB-INF\\lib">
<fileset dir="${MAVEN_TARGET}\\dependency" />
</copy>
<!-- copy the filtered resources to the src folder -->
<copy todir="${GOOGLE_SRC}">
<fileset dir="${MAVEN_TARGET}\\classes" />
</copy>
</target>





Install missing dependencies to your LOCAL REPO:

uki@Uki:~ $ cd /opt/gwt/gwt-mac-1.7.0 
uki@Uki:/opt/gwt/gwt-mac-1.7.0 $ mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-servlet -Dversion=1.7.0 -Dpackaging=jar -Dfile=gwt-servlet.jar [INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing /opt/gwt/gwt-mac-1.7.0/gwt-servlet.jar to /Users/uki/.m2/repository/com/google/gwt/gwt-servlet/1.7.0/gwt-servlet-1.7.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL




uki@Uki:/opt/gwt/gwt-mac-1.7.0 $ mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-user -Dversion=1.7.0 -Dpackaging=jar -Dfile=gwt-user.jar 
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing /opt/gwt/gwt-mac-1.7.0/gwt-user.jar to /Users/uki/.m2/repository/com/google/gwt/gwt-user/1.7.0/gwt-user-1.7.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL

RE-run the Ant (Maven2) until you get BUILD SUCCESSFUL