【问题标题】:org/apache/commons/codec/DecoderException when integrating Ant-Contrib into Eclipse将 Ant-Contrib 集成到 Eclipse 时出现 org/apache/commons/codec/DecoderException
【发布时间】:2009-10-23 08:42:32
【问题描述】:

我尝试将 Ant-Contrib 1.0b3 集成到 Eclipse 中,方法是将 libs 目录中的 ant-contrib-1.0b3.jar 和附加 jar 文件添加到 Ant- 的“全局条目”部分。 Eclipse 中的运行时首选项页面。

对于不需要库的任务,例如propertyregex,这可以正常工作。 但是当我尝试使用 postMethod 任务时,我收到以下错误:

java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException

关于如何解决此问题的任何建议?

【问题讨论】:

    标签: eclipse ant ant-contrib


    【解决方案1】:

    您的装备似乎不包含 Apache Commons Codec,它必须是 ant-contrib 的依赖项。

    根据依赖项here,您可能还需要commons-logging,但您可能已经得到了。

    【讨论】:

      【解决方案2】:

      在构建文件中定义 3rd-party 任务时指定类路径会更简洁。 提供单个 jar 或将依赖 jar 的 <fileset> 添加到类路径,例如

      <taskdef
        resource="net/sf/antcontrib/antlib.xml"
        uri="http://ant-contrib.sourceforge.net"
      >
        <classpath>
          <pathelement location="${ant-contrib.jar}"/>
          <fileset dir="${ant-contrib-dependency.lib}">
            <include name="*.jar"/>
          </fileset>    
        </classpath>
      </taskdef>
      

      您可以在此构建文件中定义默认的 ant-contrib.jarant-contrib-dependency.lib 属性,并在 ant 构建工具 VM 参数中提供项目特定的覆盖。这意味着您不必将这些文件复制到系统上的各个目录中。

      【讨论】:

        猜你喜欢
        • 2013-03-12
        • 2013-03-19
        • 1970-01-01
        • 2017-10-16
        • 2017-04-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-04
        相关资源
        最近更新 更多