| web.deploy.location=/users/bruceperry/parkerriver/gwt web.classes.location=/users/bruceperry/parkerriver/WEB-INF/classes |
下列XML描述了刚才的Ant文件的主要功能:
| <?xml version="1.0" encoding="UTF-8"?> <project name="gwtproj" default="all"> <property file="gwtproj.properties"/> <!—工程的顶级目录与ant文件存在的位置--> <dirname property="module.gwtproj.basedir" file="${ant.file}"/> <!--目录在顶级目录内的./classes--> <property name="gwtproj.output.dir" value= "${module.gwtproj.basedir}/classes"/> <!--这个目标调用MyForm-compile以创建./www目录下的所有的内容--> <target name="gwt-compile" depends= "compile.production.classes" description="use gwt's compiler"> <delete> <fileset dir="${web.deploy.location}" includes="**/*"/> </delete> <exec executable= "${module.gwtproj.basedir}/MyForm-compile" failonerror="true"/> <copy todir="${web.deploy.location}"> <fileset dir= "${module.gwtproj.basedir}/www"> </fileset> </copy> </target> <target name="compile.production.classes" description= "Compile the gwtproj production classes"> <mkdir dir="${gwtproj.output.dir}"/> <javac destdir="${gwtproj.output.dir}" debug= "on" failonerror="true" nowarn= "off" memoryMaximumSize="128m" fork= "true" executable="${module.jdk.home.gwtproj}/bin/javac"> <classpath refid="gwtproj.module.classpath"/> <src refid="gwtproj.module.sourcepath"/> </javac> </target> <!--把Java servlet类复制到web应用程序--> <target name="deploy.classes" depends="gwt-compile" description="copy classes to web directory"> <copy todir="${web.classes.location}"> <fileset dir="${gwtproj.output.dir}"> </fileset> </copy> </target> <target name="all" depends="deploy.classes" description="build all"/> </project> |
你可以从IDE(在IntelliJ中)中或在包含该构建文件的目录下使用下列命令行来运行这个Ant文件:
ant -buildfile gwtproj.xml
大部分情况下,在修改应用程序和运行Ant后,你都可以通过重载浏览器页面而在浏览器中看到这些变化。
十一、 安装
注意,在安装时,你必须把gwt-user.jar库添加到你的web应用程序的/WEB-INF/lib目录下。
我把创建的JAR文件,还有javax包(gwt-user-deploy.jar)都添加到/WEB-INF/lib目录下。这是因为Tomcat不会加载单个的web应用程序的库文件,如果它已经包含servlet API类的话。
十二、 难点
applicationCreator还会为你创建Ajax应用程序的HTML前端,在这个例子中是MyForm.html。