ant 脚本从 svn上下载文件 的具体步骤,报错

emilyzhang 发布于 2012/01/16 09:01
阅读 10K+
收藏 2

我用的svn 是 svn-1.6.13.zip   ,ant 是 apache-ant-1.8.2-bin.zip  ,svnant 是 svnant-1.3.1.zip

解压安装成功,用ant 来copy 资源等都是可以的,  

也把这么下面几个jar包都扔到 ant 的 lib 目录

svnant.jar , svnClientAdapter.jar , svnjavahl.jar , svnkit.jar

eclipse 里面也导入了这几个jar 包.

但用ant 从svn 下载资源就有问题了,具体如下:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Sample build file used to retrieve svnant's sources -->
<project name="ant-svn-checkout" basedir="." default="checkoutThis">
  <!--  all properties are in 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="${lib.dir}">
      <include name="**/*.jar"/>
    </fileset>
  </path> 
  <!-- load the svn task -->
  <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath"/>
  <target name="checkoutThis">
    <svn javahl="true" failonerror="false" username="${svnant.repository.user}" password="${svnant.repository.passwd}">
      <checkout url="${svnant.latest.url}" revision="HEAD" destPath="${svnant.dest.url}" />
    </svn>
  </target>
</project>

报错信息如下:

Buildfile: D:\workspace\testSvnAnt\build.xml
checkoutThis:
      [svn] Deprecated attribute 'javahl'. This attribute will disappear with SVNANT 1.3.2. Use svnSetting instead.
      [svn] Deprecated attribute 'failonerror'. This attribute will disappear with SVNANT 1.3.2. Use svnSetting instead.
      [svn] Deprecated attribute 'username'. This attribute will disappear with SVNANT 1.3.2. Use svnSetting instead.
      [svn] Deprecated attribute 'password'. This attribute will disappear with SVNANT 1.3.2. Use svnSetting instead.
      [svn] Missing 'javahl' dependencies on the classpath !
      [svn] the execution failed for some reason. cause: Cannot find javahl, svnkit nor command line svn client
      [svn]  at org.tigris.subversion.svnant.SvnFacade.getClientAdapter(Unknown Source)
      [svn]  at org.tigris.subversion.svnant.SvnTask.executeImpl(Unknown Source)
      [svn]  at org.tigris.subversion.svnant.SvnTask.execute(Unknown Source)
      [svn]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
      [svn]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [svn]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [svn]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [svn]  at java.lang.reflect.Method.invoke(Method.java:597)
      [svn]  at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      [svn]  at org.apache.tools.ant.Task.perform(Task.java:348)
      [svn]  at org.apache.tools.ant.Target.execute(Target.java:390)
      [svn]  at org.apache.tools.ant.Target.performTasks(Target.java:411)
      [svn]  at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      [svn]  at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
      [svn]  at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      [svn]  at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
      [svn]  at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
      [svn]  at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
      [svn]  at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
BUILD SUCCESSFUL
Total time: 890 milliseconds

我把javahl 改成="false",报Missing 'commandline' dependencies on the classpath ! 其他错跟上面一样,

我再把svn 改成 svnSetting ,它又报不支持 checkout 元素

Buildfile: D:\workspace\testSvnAnt\build.xml
checkoutThis:

BUILD FAILED
D:\workspace\testSvnAnt\build.xml:15: svnSetting doesn't support the nested "checkout" element.

Total time: 453 milliseconds

我再把checkout 改成 export  还是报不支持 export

Buildfile: D:\workspace\testSvnAnt\build.xml
checkoutThis:

BUILD FAILED
D:\workspace\testSvnAnt\build.xml:15: svnSetting doesn't support the nested "export" element.

Total time: 438 milliseconds

 

请大家帮我看看,谢谢

加载中
0
红薯
红薯
我的配置供参考:
<taskdef name="svn"  classname="org.tigris.subversion.svnant.SvnTask" classpathref="oschina.classpath"/>

<target name="svnup">
	<svn svnkit="true" javahl="false" failonerror="false">
		<update dir='.' revision="HEAD"/>
	</svn>
</target>
0
e
emilyzhang
还是不行
丁巍
丁巍
你好,我想问下这个问题最后解决没
0
中传思客
-Djava.library.path=${basedir}/javahl
这个怎么配置啊
0
jinker
jinker
要另外下载svnkit 把svant里面的svnkit.jar包去掉,换成下载的svnkit
0
xingshenyan
xingshenyan

这个问题已解决,主要是楼主应该把JAVAHL属性设置在<SVNSETTING>元素中,然后在ANT的SVN命令中再引用<svnsetting>元素。

请看新浪博客这篇文章中有详细解答:ANT集成SVNANT访问SVN(Subversion) http://blog.sina.com.cn/s/blog_5920510a01018bvt.html

e
emilyzhang
谢谢
0
weinan2087
weinan2087

引用来自“红薯”的答案

我的配置供参考:
<taskdef name="svn"  classname="org.tigris.subversion.svnant.SvnTask" classpathref="oschina.classpath"/>

<target name="svnup">
	<svn svnkit="true" javahl="false" failonerror="false">
		<update dir='.' revision="HEAD"/>
	</svn>
</target>

红薯大哥我也遇到了类似的问题,麻烦帮我解决一下:
这个是我的build.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" basedir=".">
 <property name="svn-url" value="https://10.1.5.91:8443/svn/tips_mbfe_yak/04-code/TBPS_EX/DataMigration/src"></property>
    <property name="svnlib" value="lib2"></property>
    <path id="path.svnant">
          <pathelement location="${svnlib}/svnant.jar"/>
          <pathelement location="${svnlib}/svnClientAdapter.jar"/>
          <pathelement location="${svnlib}/svnjavahl.jar"/>
          <pathelement location="${svnlib}/svnkit.jar"/>
    </path>
  
    <typedef
          resource="org/tigris/subversion/svnant/svnantlib.xml"
          classpathref="path.svnant"
      />
   
 <svnSetting id="svn.settings" svnkit="false" javahl="true" username="tbps"  password="1" />
   
 <target name="svnTest">
        <svn refid="svn.settings">
            <checkout recurse="true" url="${svn-url}" destPath="temp" />
        </svn>
    </target>
 
</project>

我的配置您看一下有什么问题吗?
但是我运行就会报这样的一个错误:
      [svn] Missing 'javahl' dependencies on the classpath !

BUILD FAILED
D:\TBPS_ex_1\project\build.xml:27: Cannot find javahl, svnkit nor command line svn client

Total time: 1 second

返回顶部
顶部