我一直在使用svenant 1.3.0从SVN存储库中的分支创建标记。现在我已经从SVN 1.6升级到1.7,并且没有发布的svenant二进制文件支持它。但是我已经从tigris.org下载了svnant 1.4源代码,并构建了一个svnant.jar。
我知道svnant有一些依赖,我有以下:svnkit 1.7.5(从svnant存储库),svnjavahl(从svnant存储库),svnClientAdapter(从svnant存储库),svnkit-cli(从svnant存储库),trilead-ssh 1.0(从maven存储库)和ganymed-ssh.jar build 210(从maven存储库)。
我使用IVY进行依赖管理,并将上述所有jar(除了来自maven存储库的两个jar)添加到我的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" />
正确检索所有jar。我尝试像这样复制branchtag (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>
这适用于SVN 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
有人有解决这个问题的办法吗?
我建议直接使用svnkit java类,而不是纠结于svant任务。此方法与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>
注意:
- 这个例子使用ivy cachepath任务将依赖项下载到一个名为"build.path"的本地类路径引用中。