1. 前提条件
已经安装了JDK6.0;
2. 环境准备
1) 下载gwt-windows-1.7.1;解压缩到d:/gwt目录下待用;
2) 下载svnant-1.3.0;解压缩到d:/ svnant-1.3.0目录下待用;
3) 下载apache-ant-1.8.1-bin.zip解压缩到d:/ ant-1.8.1目录下待用;
4) 将d:/ svnant-1.3.0/lib下的jar包全部复制到d:/ ant-1.8.1/lib目录下
5) 设置环境变量ANT_HOME= D:/ ant-1.8.1;并将“%ANT_HOME%/bin”加入到环境变量path中;
3. 编写build.properties
svn.url=http://192.168.1.216/svn/test
local.dir=C:/SVNTest
gwt.sdk.home=D: /gwt-windows-1.7.1
gwt.sdk.dev.jar.name=gwt-dev-windows.jar
jdk.home.1.6=D:/jdk1.6.0_15
svn.username=test
svn.password=test
4. 编写build.xml
<project name="test" default="all">
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd_HH_mm_ss" />
</tstamp>
<!-- define the svn url and the local directory to be checked out -->
<property file="build.properties" />
<property name="project.name" value="test" />
<property name="module.jdk.bin.test" value="${jdk.home.1.6}/bin"/>
<property name="project.path" value="${local.dir}/${project.name}" />
<property name="project.classes.path" value="${project.path}/WebRoot/WEB-INF/classes" />
<property name="project.gwt.path" value="${project.path}/WebRoot/test/gwt" />
<property name="gwt.compiler.output.test" value="${project.path}/GWTCompilerOutputTest"/>
<property name="project.target.path" value="${local.dir}/target/${project.name}"/>
<path id="ant.classpath">
<pathelement location="${ant_home}/lib/svnant.jar"/>
<pathelement location="${ant_home}/lib/svnClientAdapter.jar"/>
<pathelement location="${ant_home}/lib/svnjavahl.jar"/>
<pathelement location="${ant_home}/lib/svnkit.jar"/>
<pathelement location="${ant_home}/lib/ganymed.jar"/>
</path>
<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" >
<classpath refid="ant.classpath"/>
</taskdef>
<!-- prepare for the checking out:clean the directory -->
<target name="clean" description="delete the dirs for the task">
<delete dir="${project.path}" />
<delete dir="${project.target.path}" />
</target>
<target name="create_dirs" depends="clean" description="make the dirs for the task">
<mkdir dir="${project.path}" />
<mkdir dir="${project.target.path}" />
<mkdir dir="${project.target.path}/classes" />
<mkdir dir="${project.gwt.path}" />
<mkdir dir="${project.classes.path}" />
</target>
<path id="project.lib.path">
<fileset dir="${project.path}/WebRoot/WEB-INF/lib">
<include name="**/*.jar" />
</fileset>
</path>
<path id="project.src.path">
<dirset dir="${project.path}">
<include name="src"/>
</dirset>
</path>
<!-- check out the scource from the svn -->
<target name="checkout" depends="create_dirs">
<echo message="下载${project.name}源代码"/>
<svn javahl="true" username="${svn.username}" password="${svn.password}" >
<checkout url="${svn.url}" destPath="${project.path}" />
</svn>
</target>
<!-- define the svn task-->
<target name="compile-src" description="编译${project.name}源代码">
<echo message="编译${project.name}源代码"/>
<javac srcdir="${project.path}/src" source="1.6"
destdir="${project.target.path}/classes" debug="true" encoding="UTF-8" includes="**" failοnerrοr="false" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:deprecation"/>
<classpath>
<fileset dir="${project.target.path}/classes">
<include name="*.jar"/>
</fileset>
</classpath>
<classpath refid="project.lib.path"/>
</javac>
<copy todir="${project.classes.path}" overwrite="yes">
<fileset dir="${project.path}/src">
<include name="**/**" />
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy todir="${project.classes.path}" overwrite="yes">
<fileset dir="${project.target.path}/classes">
<include name="**/**" />
</fileset>
</copy>
</target>
<!-- Run GWT compiler for GWT module ${gwt.module.name} -->
<target name="run.gwt.compiler.test" description="Run GWT compiler">
<echo message="编译${project.name}/gwt/${gwt.module.name}模块"/>
<java fork="true" jvm="${module.jdk.bin.test}/java" classname="com.google.gwt.dev.Compiler">
<jvmarg line="-Xmx256m"/>
<classpath>
<pathelement location="${gwt.sdk.home.test}/${gwt.sdk.dev.jar.name}"/>
<path refid="project.src.path"/>
<path refid="project.lib.path"/>
</classpath>
<arg value="-logLevel"/>
<arg value="WARN"/>
<arg value="-war"/>
<arg value="${gwt.compiler.output.test}"/>
<arg value="-style"/>
<arg value="DETAILED"/>
<arg value="${gwt.module.name}"/>
</java>
</target>
<target name="compile.gwt.test" depends="compile-src" description="Compile all GWT modules in module test">
<property name="gwt.sdk.home.test" value="${gwt.sdk.home}"/>
<antcall target="run.gwt.compiler.test">
<param name="gwt.module.name" value="com.test.gwt.model1"/>
</antcall>
<antcall target="run.gwt.compiler.test">
<param name="gwt.module.name" value=" com.test.gwt.model2"/>
</antcall>
<antcall target="run.gwt.compiler.test">
<param name="gwt.module.name" value=" com.test.gwt.model3"/>
</antcall>
<antcall target="run.gwt.compiler.test">
<param name="gwt.module.name" value=" com.test.gwt.model4"/>
</antcall>
<antcall target="run.gwt.compiler.test">
<param name="gwt.module.name" value=" com.test.gwt.model5"/>
</antcall>
</target>
<target name="copy_gwt" depends="compile.gwt.test" description="复制gwt" >
<copy todir="${project.gwt.path}" overwrite="yes">
<fileset dir="${gwt.compiler.output.test}/com.test.gwt.model1"></fileset>
</copy>
<copy todir="${project.gwt.path}" overwrite="yes">
<fileset dir="${gwt.compiler.output.test}/ com.test.gwt.model2"></fileset>
</copy>
<copy todir="${project.gwt.path}" overwrite="yes">
<fileset dir="${gwt.compiler.output.test}/ com.test.gwt.model3"></fileset>
</copy>
<copy todir="${project.gwt.path}" overwrite="yes">
<fileset dir="${gwt.compiler.output.test}/ com.test.gwt.model4 "></fileset>
</copy>
<copy todir="${project.gwt.path}" overwrite="yes">
<fileset dir="${gwt.compiler.output.test}/ com.test.gwt.model5"></fileset>
</copy>
</target>
<target name="war" depends="copy_gwt" description="生成war" >
<war destfile="${project.target.path}/${project.name}${TODAY}.war" webxml="${project.path}/WebRoot/WEB-INF/web.xml" basedir="${project.path}/WebRoot">
</war>
<delete file="${project.path}/WebRoot/WEB-INF/lib/${project.name}.jar" />
</target>
<target name="all" depends="checkout,compile-src,copy_gwt,war"/>
</project>
5. 编写批处理文件compiler.bat
cd ./
@ant
至此,已经完成整个工程的源代码下载、编译及打包