1.8.2 build.xml 中需要 ant-contrib,但会导致错误

发布于 2024-12-19 20:42:08 字数 629 浏览 1 评论 0原文

我发现我需要在 build.xml 中添加以下内容:

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
        <pathelement location="${ant.library.dir}/ant-contrib-1.0b3.jar" />
    </classpath>
</taskdef>

为了支持 ant-contrib ; ...我正在使用的构造。然而,Eclipse 对此非常暴躁。将此部分放在 build.xml 的顶部,无论是从 Eclipse 外部的命令行还是 Eclipse 内部,一切都可以完美运行,尽管脾气暴躁:

在此处输入图像描述

什么“名称”实际上是“未定义”?我非常想了解如何解决这个问题。谷歌搜索,我看到其他人也有相同或类似的问题,但没有人给出好的答案,至少不适合我的情况。

非常感谢您对这个问题的任何评论,

Russ

I find I need the following in build.xml:

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
        <pathelement location="${ant.library.dir}/ant-contrib-1.0b3.jar" />
    </classpath>
</taskdef>

in order to support the ant-contrib <if> ... </if> construct I'm using. However, Eclipse is very grumpy about this. With this section at the top of build.xml, everything works perfectly, whether from the command line outside of Eclipse or inside Eclipse, despite the grumpiness:

enter image description here

What "name" is in fact "undefined"? I would dearly like to understand what to do about this problem. Googling, I see others have had identical or similar problems, but no one's given a good answer, at least not that fits my situation.

Profuse thanks for any comments on this problem,

Russ

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贩梦商人 2024-12-26 20:42:08

我发现了这里描述的问题和简单的解决方法: http:// www.mail-archive.com/[email protected]/msg39536.html

我使用以下构建文件确认了这一点:

<project default="test">

  <!-- Eclipse complains if you comment this out   -->
  <property name="dummy" value="dummy"/>

  <taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
      <pathelement location="C:/lib/ant-contrib/ant-contrib-1.0b3.jar"/>
    </classpath>
  </taskdef>

  <target name="test">
  </target>

</project>

如果在 taskdef 之前没有属性声明,Eclipse 会抱怨。

我尝试的另一个解决方法是将任务定义移动到目标中。这也有效:

  <target name="test" depends="init">
  </target>

  <target name="init">
    <taskdef resource="net/sf/antcontrib/antlib.xml">
      <classpath>
        <pathelement location="C:/lib/ant-contrib/ant-contrib-1.0b3.jar"/>
      </classpath>
    </taskdef>
  </target>

I found the issue and simple work around described here: http://www.mail-archive.com/[email protected]/msg39536.html

I confirmed that with the following build file:

<project default="test">

  <!-- Eclipse complains if you comment this out   -->
  <property name="dummy" value="dummy"/>

  <taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
      <pathelement location="C:/lib/ant-contrib/ant-contrib-1.0b3.jar"/>
    </classpath>
  </taskdef>

  <target name="test">
  </target>

</project>

If you don't have a property declaration before the taskdef, Eclipse complains.

Another work around I tried was to move the taskdef into a target. That worked too:

  <target name="test" depends="init">
  </target>

  <target name="init">
    <taskdef resource="net/sf/antcontrib/antlib.xml">
      <classpath>
        <pathelement location="C:/lib/ant-contrib/ant-contrib-1.0b3.jar"/>
      </classpath>
    </taskdef>
  </target>
筱果果 2024-12-26 20:42:08

我不知道我这样做的方式是否只是样式,但是如果您做了类似为类路径创建一个单独的元素之类的事情,例如:

<path id="ant.classpath">
    <fileset dir="${ant.library.dir}">
        <include name="ant-contrib-1.0b3.jar"/>
    </fileset>
</path>

然后在类似 @FailedDev 的行中建议利用 classpathref< /code> 属性?:

<taskdef resource="net/sf/antcontrib/antcontrib.properties" 
    classpathref="ant.classpath"/>

?

或者,我发现另一件事说对于 ANT 版本 1.6+ 使用 antlib.xml 而不是 antcontrib.properties

编辑:

我很难确定此链接在哪个产品中解决了该问题,但如果没有其他问题,此特定评论中的一些片段可能会为您提供合适的解决方法 - 尽管也许它们就是您上面所说的

没有人给出一个好的答案,至少不适合[您的]解决方案。

https://bugzilla.redhat.com/show_bug.cgi?id=663236#c2

I don't know if the way I do it is just style or not, but what if you did something like creating a separate element for the classpath like:

<path id="ant.classpath">
    <fileset dir="${ant.library.dir}">
        <include name="ant-contrib-1.0b3.jar"/>
    </fileset>
</path>

And then later on a line like @FailedDev suggested leveraging the classpathref attribute?:

<taskdef resource="net/sf/antcontrib/antcontrib.properties" 
    classpathref="ant.classpath"/>

?

Or, I found one other thing which says to use antlib.xml instead of antcontrib.properties for ANT versions 1.6+?

Edit:

I'm having a hard time determining in which product this link fixed the issue, but if nothing else there are a couple snippets in this specific comment which may provide a suitable workaround for you -- although maybe they're what you're referring to above when you say

no one's given a good answer, at least not that fits [your] solution.

https://bugzilla.redhat.com/show_bug.cgi?id=663236#c2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文