`
流浪鱼
  • 浏览: 1638550 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

    博客分类:
  • ant
 
阅读更多

使用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

 

 

 

 

 

  • 大小: 48 KB
  • doc.rar (24.5 KB)
  • 下载次数: 75
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics