用ant实现SVN代码更新,部署 【clean】

要实现ant可以从svn服务器上检出代码要使用svnant jar文件。

从网上下载svnant 包,下载地址:

http://subclipse.tigris.org/files/documents/906/49042/svnant-1.3.1.zip

将下载好的svnant 解压将 lib目录下的所有jar复制到ant主目录中的 lib目录下。

编写build.xml

要svn task任务可以使用要在build.xml中添加

Xml代码 复制代码 收藏代码
  1. <typedefresource="org/tigris/subversion/svnant/svnantlib.xml"/>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" />

完整的xml文件如下:

Xml代码 复制代码 收藏代码
  1. <projectname="dt"basedir=".">
  2. <!--定义属性-->
  3. <propertyname="src"value="src/main/java"/>
  4. <propertyname="resources"value="src/main/resources"/>
  5. <propertyname="test"value="test"></property>
  6. <propertyname="target"value="target"></property>
  7. <propertyname="main-target"value="target/classes"/>
  8. <propertyname="test-target"value="target/test-classes"/>
  9. <propertyname="lib-dir"value="WebContent/WEB-INF/lib"/>
  10. <propertyname="tomcat.home"value="D:/webapp-server/apache-tomcat-6.0.20"/>
  11. <!--antlib目录>
  12. <propertyname="ant-lib-dir"value="D:/apache-ant-1.8.2/lib"/>
  13. <!--需指向本地tomcatlib目录-->
  14. <propertyname="tomcat-lib"value="D:/webapp-server/apache-tomcat-6.0.20/lib"/>
  15. <!--svn路径-->
  16. <propertyname="urlRepos"value="svn://192.168.1.1o/Project/dt"/>
  17. <!--定义classpath-->
  18. <pathid="classpath">
  19. <filesetdir="${lib-dir}"includes="***.jar"></fileset>
  20. <filesetdir="${tomcat-lib}"includes="***.jar"></fileset>
  21. </path>
  22. <!--引用svntask文件,使用svn任务可以使用-->
  23. <typedefresource="org/tigris/subversion/svnant/svnantlib.xml"/>
  24. <!--清理-->
  25. <targetname="clean">
  26. <deletedir="${target}"></delete>
  27. </target>
  28. <!--初始化-->
  29. <targetname="init"depends="clean">
  30. <mkdirdir="${main-target}"/>
  31. <mkdirdir="${test-target}"/>
  32. </target>
  33. <!--设置svn相关属性-->
  34. <svnSettingid="svn.setting"svnkit="true"username="hzl"password="111111"javahl="false"/>
  35. <!--检出代码这里使用export不是checkout二者区别checkout会svn相关信息文件检出,export只是检出最新的文件-->
  36. <targetname="checkout"depends="clean">
  37. <svnrefid="svn.setting">
  38. <exportsrcUrl="${urlRepos}"destPath="."force="true"/>
  39. </svn>
  40. </target>
  41. <!--编译-->
  42. <targetname="compile"depends="checkout">
  43. <javacsrcdir="${src}"destdir="${main-target}"encoding="UTF-8"includeAntRuntime="false">
  44. <classpathrefid="classpath"></classpath>
  45. </javac>
  46. <copytodir="${main-target}">
  47. <filesetdir="${resources}">
  48. <excludename="sql/**"/>
  49. </fileset>
  50. </copy>
  51. </target>
  52. <!--打war包-->
  53. <targetname="build"depends="compile">
  54. <wardestfile="${target}/dt.war"webxml="WebContent/WEB-INF/web.xml">
  55. <filesetdir="WebContent"></fileset>
  56. <classesdir="${main-target}"></classes>
  57. </war>
  58. <deletedir="${main-target}"></delete>
  59. <deletedir="${test-target}"></delete>
  60. </target>
  61. <!--shutdowntomcat-->
  62. <targetname="shutdowntomcat"description="========shutdowntomcat===========">
  63. <execexecutable="${tomcat.home}/bin/shutdown.sh"failonerror="false"></exec>
  64. <sleepseconds="10"/>
  65. </target>
  66. <!--startuptomcat-->
  67. <targetname="startuptomcat"description="========startuptomcat===========">
  68. <sleepseconds="5"/>
  69. <execexecutable="${tomcat.home}/bin/startup.sh"failonerror="false"></exec>
  70. </target>
  71. <!--部署到tomcat下面-->
  72. <targetname="deploy"depends="war">
  73. <copyfile="${target}/dt.war"todir="${tomcat.home}/webapps"/>
  74. </target>
  75. </project>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值