Gwt-Ext deployment on Tomcat via ANT script
Jul 9th, 2008 by Dariusz
This time I would like to post the Ant script I’m using for deploying my Gwt-Ext application. The main thing what is required for deploying it successfully, is basically the path to the GWT source files.
The Login application as shown in this figure before running the build file:
Here is my whole build.xml file do deploy the application server:
-
<project name="LoginApplication" default="init" basedir=".">
-
-
<!– Prepare the variables –>
-
<property name="gwtpath" value="C:/Tools/gwt-windows-1.4.62" />
-
<property name="web.inf" value="${basedir}/WebContent/WEB-INF" />
-
<property name="gwt.module" value="org.mypackage.Login" />
-
-
<property name="dest.dir" value="${basedir}/dest"/>
-
<property name="dest.classes.dir" value="${basedir}/dest/classes"/>
-
<property name="www.dir" value="${dest.dir}/www"/>
-
<property name="src.dir" value="${basedir}/src"/>
-
<property name="lib.dir" value="${web.inf}/lib" />
-
<property name="classes.dir" value="${web.inf}/classes" />
-
-
<!– Set the classpth of all libraries –>
-
<path id="classpath">
-
<pathelement location="${gwtpath}/gwt-user.jar"/>
-
<pathelement location="${gwtpath}/gwt-dev-windows.jar"/>
-
<pathelement location="${src.dir}"/>
-
<fileset dir="${lib.dir}">
-
<include name="**/*.jar" />
-
</fileset>
-
</path>
-
-
<!– Target responsible for cleaning up –>
-
<target name="clean">
-
<tstamp>
-
<format property="now" pattern="d-MM-yyyy hh:mm aa"/>
-
</tstamp>
-
-
<echo message="===========================================" />
-
<echo message="Creating new build: ${now}" />
-
<echo message=" " />
-
<echo message="——————————————-" />
-
<echo message="Cleaning current directory… " />
-
<echo message="===========================================" />
-
-
<delete dir="${dest.dir}" />
-
<delete dir="${classes.dir}" />
-
-
<delete>
-
<fileset dir="${basedir}/WebContent" includes="*.*"/>
-
</delete>
-
</target>
-
-
<!– Target creates required directories. –>
-
<target name="init" depends="clean">
-
<echo message="==========================================" />
-
<echo message="OS Name: ${os.name} " />
-
<echo message="Java Home: ${java.home} " />
-
<echo message="Ant java version: ${ant.java.version} " />
-
<echo message="Java vendor: ${java.vendor} " />
-
<echo message="Java Version: ${java.version} " />
-
<echo message="==========================================" />
-
-
<mkdir dir="${dest.dir}" />
-
<mkdir dir="${dest.classes.dir}" />
-
<mkdir dir="${www.dir}" />
-
<mkdir dir="${classes.dir}" />
-
</target>
-
-
<!– Target compiles all the gwt files and convert them into Java Script and all other files. –>
-
<target name="compile-gwt" depends="init">
-
<java classname="com.google.gwt.dev.GWTCompiler" fork="true">
-
<classpath refid="classpath" />
-
<jvmarg value="-Xmx256M" />
-
<arg value="-out" />
-
<arg value="${www.dir}"/>
-
<arg value="${gwt.module}"/>
-
</java>
-
</target>
-
-
<!– Target responsible for compiling all java sources except the client package –>
-
<target name="compile" depends="compile-gwt">
-
<echo message="==========================================" />
-
<echo message="Compiling source files… " />
-
<echo message="==========================================" />
-
-
<javac destdir="${dest.classes.dir}"
-
excludes="**/client/*.java"
-
classpathref="classpath"
-
verbose="off"
-
debug="on"
-
deprecation="true">
-
<src path="${src.dir}" />
-
</javac>
-
-
<echo message="==========================================" />
-
<echo message="Copying needed files… " />
-
<echo message="==========================================" />
-
-
<copy todir="${dest.classes.dir}">
-
<fileset dir="${src.dir}" includes="**/*.dtd"/>
-
</copy>
-
</target>
-
-
<!– Target responsible for deploying files on server –>
-
<target name="deploy" depends="compile">
-
<echo message="==========================================" />
-
<echo message="Deploying sources… " />
-
<echo message="==========================================" />
-
<copy todir="${classes.dir}">
-
<fileset dir="${dest.classes.dir}"/>
-
<fileset dir="${classes.dir}" includes="**/*.dtd" />
-
<fileset dir="${classes.dir}" includes="**/*.xml" />
-
</copy>
-
-
<echo message="==========================================" />
-
<echo message="Deploying GWT resources " />
-
<echo message="==========================================" />
-
<copy todir="${basedir}/WebContent">
-
<fileset dir="${www.dir}/${gwt.module}">
-
</fileset>
-
</copy>
-
</target>
-
-
</project>
And here is a screenshot after it’s being deployed:
Now, either you copy the whole WebContent folder into your application directory stored in the webapps directory in Tomcat or you build a copy target in the build.xml to do it for you.
Cheers!




Thanks for posting this. How can I create a deployable war to deploy into jboss 4.2.
Thanks
Please, use this “tutorial” / “how-to” to create a “war” target.
http://ant.apache.org/manual/CoreTasks/war.html
i’d like to put all the generated files and gwt-ext related files into
a separate directory. if i do that the result is a blank page. i don’t
understand this, because as far as i can see all the .js references
are relative ones in the html and in the gwt-compiler generated
js files as well. please help me is you can!
jb3,
I wish I could help you but I don’t really know what’s the problem…
How are you deploying your app? Are you using the ANT script? If so, then after you deployed your application, you should see the directory: “Webcontent“. Everything what you see inside this directory, you just copy it to your webapps forlder inside your Tomcat. You have to restart your application in your Tomcat management and then it should work e.g. http://localhost:8080/YourApplicationName.
I hope this helps.
I use JBoss and deploy files manually at the moment.
If I put the generated files and the ‘js’ folder into
the webapp root (this is what your ant file does) it works fine.
but i would like to make a webapp structure like this:
WebAppRoot\
WEB-INF\web.xml
META-INF\manifest.mf
loginApp\
LogApp.html and related GWT-generated files
js\
ext\ ………
resources\ ……..
etc.
secureApp\
secureApp.html and related GWT-generated files
js\
ext\…..
resources\….
etc.
and if I put gwt-ext static html files and js into a subfolder,
and edit the web.xml as needed, then the html loads but js not.
I hope I could explain my problem clearly. I need all this to
apply authentication and authorization later. (If all goes to
the webapp root that is so ugly.)
Thanks for your attention and help in advance.
sorry, indentation is lost from my recent post, but i hope you’ll understand the
directory structure this way too…
Oh, I see what you mean. Honestly, I never tried it out to create more than one module and I’m not sure it’s working that way.
As far as I understand, the whole GWT development is based on one module but in the back you are controlling the panels what is allowed to see or not. Basically, like the java swing components.
Maybe someone else can help you and sorry for my unsatisfied response!