在 Eclipse 中使用 SVNAnt 构建失败(无法从资源加载定义)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8138807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using SVNAnt in eclipse Build Failed (Could not load definitions from resource)
提问by thomaf
I want to use SVNAnt in eclipse. But when I run my script, I have this message :
我想在 Eclipse 中使用 SVNAnt。但是当我运行我的脚本时,我收到了这条消息:
Buildfile: X:\XXX\bin\ant\axis_bujava.xml
[typedef] Could not load definitions from resource org/tigris/subversion/svnant/svnantlib.xml. It could not be found.
testSVNAnt:
BUILD FAILED
X:\XXX\bin\ant\axis_bujava.xml:11: Problem: failed to create task or type svn
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Here is the Ant build file :
这是 Ant 构建文件:
<?xml version="1.0"?>
<project default="testSVNAnt" basedir=".">
<path id="path.svnant">
<pathelement location="${basedir}/svnant.jar"/>
<pathelement location="${basedir}/svnClientAdapter.jar"/>
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="path.svnant" />
<target name="testSVNAnt">
<svn username="username" password="pass">
<checkout url="svn://svnurl" destPath="localpath" revision="HEAD"/>
</svn>
<echo message= "Subversion repository url: ${repository.url}" />
</target>
</project>
The JAR files are of course in basedir. I can't find similar problem nor any solutions.
JAR 文件当然在 basedir 中。我找不到类似的问题或任何解决方案。
采纳答案by thomaf
It finaly work using SvnAnt 1.3.1.
它最终使用 SvnAnt 1.3.1 工作。
The checkout work fine using this code :
使用此代码结帐工作正常:
<?xml version="1.0"?>
<project default="main" basedir=".">
<path id="path.svnant">
<pathelement location="${basedir}/svnant.jar" />
<pathelement location="${basedir}/svnClientAdapter.jar" />
<pathelement location="${basedir}/svnjavahl.jar" />
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="path.svnant" />
<target name="main">
<svn>
<checkout url="svn://xxx" destPath="X:/XXX" revision="HEAD" />
</svn>
</target>
</project>
Thanks for help.
感谢帮助。
回答by sunbabaphu
had the same problem.. replacing the value of "resource" from "org/tigris/subversion/svnant/svnantlib.xml" TO "svntask.properties" did it for me.
有同样的问题..将“资源”的值从“org/tigris/subversion/svnant/svnantlib.xml”替换为“svntask.properties”为我做了。
sample below: (svn_1.0.0; eclipse juno)
下面的示例:(svn_1.0.0;eclipse juno)
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="D:/.../ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<path id="path.svnant">
<pathelement location="D:/.../lib/svnant.jar" />
<pathelement location="D:/.../lib/svnClientAdapter.jar" />
<pathelement location="D:/.../lib/svnjavahl.jar" />
</path>
<typedef **resource="svntask.properties"** classpathref="path.svnant"/>
<target name="ifAvailable">
<available classpathref="path.svnant" **resource="svntask.properties"**
property="temp"/>
<echo message="SVNAnt is available = ${temp}"></echo>
</target>
OUTPUT>>>>>
输出>>>>>
Buildfile: D:\...\build.xml
ifAvailable: [echo] SVNAnt is available = true BUILD SUCCESSFUL Total time: 306 milliseconds
ifAvailable: [echo] SVNAnt is available = true BUILD SUCCESSFUL 总时间:306 毫秒
回答by oers
You have to use
你必须使用
<taskdef />
instead of <typedef/>
代替 <typedef/>
Everything else looks fine.
其他一切看起来都很好。
回答by Shrikant
Replace
代替
<taskdef resource="org/tigris/subversion/svnant/svnantlib.xml" />
with
和
<taskdef resource="svntask.properties"/>
The svntask.properties are present in the svnant.jar
svntask.properties 存在于 svnant.jar 中

