使用svnant插件让ant支持从svn更新项目

使用svnant插件支持从svn服务器中更新最新代码,需要注意的是使用svnant插件的时候必须保证你的机子安装了svn客户端,svnant本质是执行svn客户端命令的

svnant的官方网站为:

http://subclipse.tigris.org/svnant.html

svnant可支持的命令为(下面的图是从svnant-1.3.1\doc\svntask.html截出来的,具体可以查看该文件):

编写的build.xml内容为:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="checkoutProject" name="testSvn">
	<!--http://subclipse.tigris.org/svnant.html  需要svnant插件地址-->
	<!-- 关于svn属性的定义在build.properties --> 
	<property file="build.properties" /> 
	<!-- path to the svnant libraries. Usually they will be located in ANT_HOME/lib -->
	<path id="svnant.classpath">
		<fileset dir="${svnantlib.dir}">
		  <include name="**/*.jar"/>
		</fileset>
	 </path> 
	
	<!-- load the svn task 加载SVN的jar包,使他可以调用系统的svn命令-->
	<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />
	<!-- 设置svn相关属性 从svnant1.3.1以后必须使用svnSetting来设置svn的属性即用户名和密码等 -->  
    <svnSetting id="svn.setting" svnkit="true" username="${innofund.repository.user}" password="${innofund.repository.passwd}"  javahl="false" />

	<target name="clean">
		<description>删除生成的项目文件夹</description>
		<delete dir="${project.name}" />
	</target>

	<target name="checkoutProject" depends="clean">
		<description>检出新项目含svn信息,经过试验没有发现有svn相关信息</description>
		<echo message="从svn${innofund.url}检出代码开始" />
		<svn refid="svn.setting">
		  <checkout url="${innofund.url}" revision="HEAD" destPath="${project.name}" />
		</svn>
		<echo message="从svn${innofund.url}检出代码完成" />
	 </target>


	<target name="exportProject" depends="clean">
		<description>导出新项目没有svn信息</description>
		<echo message="从svn${innofund.url}导出代码开始" />
		<svn refid="svn.setting">
		  <export srcUrl="${innofund.url}" revision="HEAD" destPath="${project.name}" force="true"/>
		</svn>
		<echo message="从svn${innofund.url}导出代码完成" />
	 </target>

</project>

 注意:从1.3.1以后设置svn服务器的相关属性需要使用svnSetting属性

我已经把svnant插件的api上传了见附件doc.rar

我测试的代码见附件antsvn.rar

 

 

 

 

 

阅读终点,创作起航,您可以撰写心得或摘录文章要点写篇博文。去创作
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hqmln

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值