【问题标题】:how to configure ivy to resolve dependecies of htmlunit如何配置 ivy 以解决 htmlunit 的依赖关系
【发布时间】:2013-02-14 23:58:58
【问题描述】:

ivy 可以解析依赖关系,文档说可以使用模块配置告诉 ivy 配置依赖于给定的依赖配置。

我想在一个项目中使用 htmlunit,在它的 sourceforge page 依赖信息中我找到了依赖设置,我将 maven 规范翻译成 ivy:

<dependency org="net.sourceforge.htmlunit" name="htmlunit" rev="2.11"/>

我写了一个测试,编译它,当试图运行它时,我有一个 ClassNotFoundException,我再次回到 sourceforge,并查找有关 htmlunit 依赖项的信息,在这个 page 我找到了我要找的东西,所以我认为我需要的一切都是使用模块配置的魔力,所以我补充说:

<dependency org="net.sourceforge.htmlunit" name="htmlunit" rev="2.11" conf="test->compile; test->test"/>

但我有这个错误告诉我在 net.sourceforge.htmlunit#htmlunit;2.11, 'compile' 中找不到配置

【问题讨论】:

    标签: dependencies ivy htmlunit


    【解决方案1】:

    编译配置确实存在....

    在尝试重现您的问题时,我发现了以下错误消息:

    [ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
    [ivy:resolve]       ::          UNRESOLVED DEPENDENCIES         ::
    [ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
    [ivy:resolve]       :: net.sourceforge.htmlunit#htmlunit;2.11: 
        configuration not public in net.sourceforge.htmlunit#htmlunit;2.11: 'test'......
    

    当 ivy 将 Maven 模块转换为配置时,它以不允许解析传递测试依赖项的方式进行。

    这个推理有一些逻辑,毕竟所有的测试依赖都是为了支持 htmlunit 模块的测试而设计的。你的模块应该明确声明它自己的测试依赖....

    我通常建议将您的“测试”配置映射到远程“运行时”Maven 范围,以便获取额外的 jar:

    <dependency org="net.sourceforge.htmlunit" 
                name="htmlunit" 
                rev="2.11" 
                conf="compile->default;test->runtime"/>
    

    问题是 htmlunit 模块中没有“运行时”依赖项,这意味着这没有任何帮助。

    总之,您没有指出缺少哪个课程。如果它是像 junit 这样明显的东西,那么我建议这是应该在你的常春藤文件中明确声明的东西。

    【讨论】:

      猜你喜欢
      • 2015-06-04
      • 2017-03-08
      • 2011-12-11
      • 2012-12-24
      • 2014-09-19
      • 2016-01-06
      • 2013-02-11
      • 2016-10-11
      • 1970-01-01
      相关资源
      最近更新 更多