我一直在使用svnant 1.3.0从我的SVN存储库中的分支创建标签。现在我已经从SVN 1.6升级到1.7,并且没有发布支持它的svnant二进制文件。但是我从tigris.org下载了svnant 1.4源代码并构建了一个svnant.jar。
我知道svnant有几个dependecies,我有以下内容:svnkit 1.7.5(来自svnant repository),svnjavahl(来自svnant repository),svnClientAdapter(来自svnant repository),svnkit-cli(来自svnant repository), trilead-ssh 1.0(来自maven存储库)和ganymed-ssh.jar build 210(来自maven存储库)。
我使用IVY进行依赖关系管理,并将所有上述jar(除了maven存储库中的两个)添加到我的Artifactory安装中。在我的IVY依赖文件中,我像这样检索jar:
<dependency org="svnant" name="svnant" rev="1.4.0" conf="test->default" />
<dependency org="svnkit" name="svnkit" rev="1.7.5" conf="test->default" />
<dependency org="svnjavahl" name="svnjavahl" rev="1.4.0" conf="test->default" />
<dependency org="svnClientAdapter" name="svnClientAdapter" rev="1.4.0" conf="test->default" />
<dependency org="svnkit-cli" name="svnkit-cli" rev="1.7.5"/>
<dependency org="trilead-ssh2" name="trilead-ssh2" rev="1.0.0" conf="test->default"/>
<dependency org="ch.ethz.ganymed" name="ganymed-ssh2" rev="build210" conf="test->default" />
正确检索所有罐子。我尝试像这样做一个branch2tag拷贝(retrieveIVY目标检索上面描述的jar文件):
<target name="create-tag" depends="retrieveIVY">
<taskdef classpathref="test.classpath.dep" resource="net/sf/antcontrib/antcontrib.properties" />
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="test.classpath.dep" />
<echo message="Creating tag ${env.tag_name}" />
<svnSetting username="${user}" password="${password}" client="svnkit" />
<svn>
<copy srcUrl="[srcUrl]" destUrl="[destUrl]" message="${env.tag_name}" />
</svn>
</target>
这适用于svnant 1.3.0和SVN 1.6(除了svnSetting标签)。但是使用新的jar版本我会收到以下错误:
The svn client 'svnkit' is not available !
at org.tigris.subversion.svnant.SvnClientType.checkAvailability(SvnClientType.java:122)
at org.tigris.subversion.svnant.SvnClientType.createClient(SvnClientType.java:93)
at org.tigris.subversion.svnant.SvnFacade.getClientAdapter(SvnFacade.java:362)
at org.tigris.subversion.svnant.SvnTask.executeImpl(SvnTask.java:597)
at org.tigris.subversion.svnant.SvnTask.execute(SvnTask.java:568)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
Caused by: org.tigris.subversion.svnclientadapter.SVNClientException: SVNKit client adapter is not available
at org.tigris.subversion.svnclientadapter.svnkit.SvnKitClientAdapterFactory.setup(SvnKitClientAdapterFactory.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.tigris.subversion.svnant.SvnClientType.invoke(SvnClientType.java:129)
at org.tigris.subversion.svnant.SvnClientType.checkAvailability(SvnClientType.java:112)
... 19 more
有人有想法可以解决这个问题吗?
答案 0 :(得分:6)
我建议直接使用svnkit java类,而不是使用svnant任务。这种方法与macrodef相结合,将产生类似但更可靠的解决方案。
<project name="build" default="checkout" xmlns:ivy="antlib:org.apache.ivy.ant">
<!--
======
Macros
======
-->
<macrodef name="svn-checkout">
<attribute name="src"/>
<attribute name="dest"/>
<sequential>
<mkdir dir="@{dest}"/>
<java classname="org.tmatesoft.svn.cli.SVN" dir="@{dest}" fork="true" classpathref="build.path">
<arg value="--non-interactive"/>
<arg line="--username ${svn.user}"/>
<arg line="--password ${svn.pass}"/>
<arg value="checkout"/>
<arg value="@{src}"/>
</java>
</sequential>
</macrodef>
<!--
=======
Targets
=======
-->
<target name="resolve" description="Resolve 3rd party dependencies">
<ivy:cachepath pathid="build.path">
<dependency org="org.tmatesoft.svnkit" name="svnkit-cli" rev="1.7.8" conf="default"/>
</ivy:cachepath>
</target>
<target name="checkout" depends="resolve" description="Pull code from SCM repository">
<svn-checkout src="http://svn.apache.org/repos/asf/subversion/trunk" dest="build/subversion"/>
</target>
<target name="clean" description="Cleanup build files">
<delete dir="build"/>
</target>
<target name="clean-all" depends="clean" description="Cleanup and purge ivy cache">
<ivy:cleancache/>
</target>
</project>
注意: