Personal tools

Netbeans:NetbeansGWTDeploy: Difference between revisions

From Adapt

Jump to: navigation, search
No edit summary
 
No edit summary
 
Line 76: Line 76:


Build the project, copy the generated WAR file in ''dist'' to a ''webapps'' directory and meow like a tomcat.
Build the project, copy the generated WAR file in ''dist'' to a ''webapps'' directory and meow like a tomcat.
For more information: [[media:gwt-tutorial-3.tar.gz|GWT Tutorial 3]]

Latest revision as of 23:04, 11 September 2008

Production Deployment

Compiling Java to Javascript

Add the following target to the build.xml file to compile the Java files into JavaScript...

<target name="-compile-to-javascript">
   <echo message="Compiling Java to JavaScript"/>
   <java classpath="${run.classpath}:${basedir}/src" 
         classname="com.google.gwt.dev.GWTCompiler" 
         fork="true">
      <arg value="-out"/>
      <arg path="${build.dir}/www/"/>
      <arg value="${application.args}"/>
      <arg value="edu.umiacs.gwt.hello.HelloWorld"/>
   </java>
</target>

...replacing the last argument with the root package name and module name.

Add the following target to call the target just created:

<target name="-post-jar" depends="-compile-to-javascript"/>

Web distribution directory

Build the project and look in the build/www directory to see what has been created. Now create a target to make a distribution copy of what was built. The distribution copy will be identical to the build copy except for the following changes: The parent directory edu.umiacs.gwt.hello.HelloWorld will also be renamed to hello-world and the HelloWorld.html file will be renamed to index.html. Add the following target and put in any additional cleanup tasks here:

<target name="-www-dist">
   <copy todir="${basedir}/dist/hello-world">
      <fileset dir="${basedir}/build/www/edu.umiacs.gwt.hello.HelloWorld"/>
   </copy>
   <move file="${basedir}/dist/hello-world/HelloWorld.html" 
         toFile="${basedir}/dist/hello-world/index.html"/>    
</target>

Modify the -post-jar target to depend on this new target:

<target name="-post-jar" depends="-compile-to-javascript,-www-dist"/>

Build the project, and using your web browser of choice, open up the index.html file in dist/hello-world.

Creating a WAR file

In the root package, create a web.xml file that contains the following:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
</web-app>

Create a new target to build the WAR file:

<target name="-war-dist">
   <war destfile="dist/hello-world.war" webxml="src/edu/umiacs/gwt/hello/web.xml">
      <fileset dir="dist/hello-world"/>
   </war>        
</target>

Modify the -post-jar target to depend on this new target:

<target name="-post-jar" depends="-compile-to-javascript,-www-dist,-war-dist"/>

Build the project, copy the generated WAR file in dist to a webapps directory and meow like a tomcat.

For more information: GWT Tutorial 3