【问题标题】:IVY Extends via ivy:resolveIVY 通过 ivy:resolve 扩展
【发布时间】:2014-09-28 10:46:14
【问题描述】:

我们最近在我们的构建系统中引入了一个通用依赖项,它在每个单独的 ivy.xml 中使用ivy:extends 选项。常见的ivy.xml内容如下;

common-ivy.xml

<?xml-stylesheet type="text/xsl" href="http://repository.xyz.com/xsl/version-doc.xsl"?>
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    <info organisation="XYZ" branch="MAIN" module="CommonDependencies" revision="1.0.0" />

    <configurations defaultconfmapping="test->test(*);compile->compile(*);package->package(*)">
        <conf name="test" description="Test Time dependencies"/>
        <conf name="compile" description="Build Time dependencies"/>
        <conf name="package" description="Distributable dependencies" />
    </configurations>

    <dependencies>
        <dependency org="junit" name="junit" rev="4.8.2" conf="compile,test"/>
        <dependency org="apache" name="wss4j" rev="1.5.10" conf="compile,test" />
        <dependency org="spring" name="spring" rev="2.5.6" conf="compile" />
        <dependency org="apache" name="commons-pool" rev="1.5.5" conf="compile" />
        <dependency org="google" name="gtest" rev="1.5.0" conf="test" >
            <artifact name="gtest" type="" ext="zip" conf="test" />
        </dependency>
        <dependency org="NUnit" name="NUnit" rev="2.6" conf="test">
            <artifact name="NUnit" type="" ext="zip" conf="test" />
        </dependency>
        <dependency org="javax" name="javaee-api" rev="6.0" conf="compile,test" />
    </dependencies>
</ivy-module>

我有大约 120 个项目扩展了上面显示的常见 ivy 以获得它们的依赖关系,如下所示;

ivy.xml

<?xml-stylesheet type="text/xsl" href="http://repository.xyz.com/xsl/version-doc.xsl"?>
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    <info module="Module1" >
        <extends extendType="all"
                     organisation="XYZ"
                     module="CommonDependencies"
                     revision="1.0.0" />
    </info>

    <publications />

    <!-- Define Additional Dependencies Below -->
    <dependencies />
</ivy-module>

如果您观察到要求是不要使用extendslocation 属性,因为这需要路径解析,这使得所有子项目都具有一定的顺序等。为了实现这一点,我们在开始时解析公共依赖项,这会产生resolved-* .xml 到我们的本地 IVY 缓存中,现在希望 IVY 为所有因以下消息而崩溃的子项目解决相同的问题;

Override ignored for property "ivy.buildlist.dir"
Overriding previous definition of property "ivy.version"
[ivy:buildlist] WARN: Unable to parse included ivy file ../ivy.xml: D:\Source\RTC-DS\Dev\ivy.xml (The system cannot find the file specified) in fil
e:/D:/Source/RTC-DS/ivy.xml
[ivy:buildlist] main: Checking cache for: dependency: XYZ#CommonDependencies;1.0.0 {}
[ivy:buildlist] don't use cache for XYZ#CommonDependencies;1.0.0: checkModified=true
[ivy:buildlist] don't use cache for XYZ#CommonDependencies;1.0.0: checkModified=true
[ivy:buildlist]                 tried C:\Users\sjunejo\.ivy2/publish/ivys/XYZ/CommonDependencies-1.0.0.xml
[ivy:buildlist]                 tried C:\Users\sjunejo\.ivy2/publish/XYZ/CommonDependencies/CommonDependencies-1.0.0-jar.jar
[ivy:buildlist]         publisher: no ivy file nor artifact found for XYZ#CommonDependencies;1.0.0
[ivy:buildlist] don't use cache for XYZ#CommonDependencies;1.0.0: checkModified=true
[ivy:buildlist]                 tried C:\Users\sjunejo/external/XYZ/CommonDependencies/CommonDependencies-1.0.0.jar
[ivy:buildlist]         external-local-resolver: no ivy file nor artifact found for XYZ#CommonDependencies;1.0.0
[ivy:buildlist] don't use cache for XYZ#CommonDependencies;1.0.0: checkModified=true
[ivy:buildlist]                 tried http://repository.XYZ.com/ivyrep/ivys/XYZ//CommonDependencies-1.0.0.xml
[ivy:buildlist] CLIENT ERROR: Not Found url=http://repository.XYZ.com/ivyrep/ivys/XYZ//CommonDependencies-1.0.0.xml
[ivy:buildlist]                 tried http://repository.XYZ.com/ivyrep/XYZ//CommonDependencies/CommonDependencies-1.0.0-jar.jar
[ivy:buildlist] CLIENT ERROR: Not Found url=http://repository.XYZ.com/ivyrep/XYZ//CommonDependencies/CommonDependencies-1.0.0-jar.j
ar
[ivy:buildlist]         XYZ-http-resolver: no ivy file nor artifact found for XYZ#CommonDependencies;1.0.0
[ivy:buildlist] don't use cache for XYZ#CommonDependencies;1.0.0: checkModified=true
[ivy:buildlist]                 tried http://repository.XYZgroup.com/external/XYZ/CommonDependencies/CommonDependencies-1.0.0.jar
[ivy:buildlist] CLIENT ERROR: Not Found url=http://repository.XYZgroup.com/external/XYZ/CommonDependencies/CommonDependencies-1.0.0.jar
[ivy:buildlist]         external-http-resolver: no ivy file nor artifact found for XYZ#CommonDependencies;1.0.0
[ivy:buildlist] WARN: Unable to parse included ivy file for XYZ#CommonDependencies;1.0.0

BUILD FAILED

我可以清楚地看到公共依赖项已成功解决并在本地缓存中可用.....我怎样才能让&lt;ivy:resolve /&gt; 在本地缓存中查找这个...我到处搜索,似乎我有使用location :( 属性而不是依赖IVY缓存。

此外,当我从公共依赖项中删除revision 时,它会解析为working@...,IVY 2.2.0 似乎以某种方式解决,我的所有项目都可以正常工作,但 IVY 2.3.0 抱怨,因为它正在尝试解决 revision=1.0.0 在子项目的 ivy.xml 中定义,否则 IVY 会立即崩溃,说明 revisionextends 的强制属性。

【问题讨论】:

  • 您对这种方法有信心吗?对替代品持开放态度?我不喜欢 Maven 或 Ivy 中的父子模块关系。我的偏好是使用共享属性或动态修订来捕获模块之间的相互依赖关系。查看相关问题:stackoverflow.com/questions/7019618/…
  • 不,我愿意接受替代方案,但不确定 ivysettings 中的常用属性在这种情况下有何帮助,我已经在常用设置中定义了一些属性,并且我可以完全控制定义更多属性。只是为了让您知道,在这种情况下,常见 ivy 中定义的依赖项将永远被覆盖。在单独的 ivy.xml 中定义的依赖空间仅用于满足项目在构建时相互依赖的情况,这似乎是最好的方式!
  • 就像我说的,我不喜欢父子模块关系。它始于良好的意图。我只是强烈认为每个模块都应该明确列出它自己的依赖项。好的,....再次查看您的错误,我想知道...您是否已将父模块发布到本地存储库中?看起来 ivy 无法在运行时解决它。
  • 不,我还没有发布它...我像&lt;ivy:resolve file="common-ivy.xml" /&gt;一样解决了它...你认为我应该发布它而不是解决它吗?
  • 是的,我纯粹是在猜测,但我认为它正在寻找一个名为“XYZ#CommonDependencies;1.0.0”的模块(以便继承)。我猜如果你首先发布这个父模块,子 ivy 模块的分辨率会起作用。

标签: caching ivy extends


【解决方案1】:

好的,除了使用extends 中的location 属性外,没有其他方法可以解决此问题。我通过提供像location=${common.ivy.location} 这样的属性解决了这个问题,并在我的常春藤设置中声明了这个属性,它就像一个魅力。

此解决方案适用于 IVY 2.2、2.3 和 2.4。

【讨论】:

    【解决方案2】:

    同意 SJunejo 的回复。在我的情况下,我在从 2.2.0 移动到 2.3.0 后遇到了同样的错误,并且我使用了 location 属性。但是,我使用的是相对路径。当我更新为使用绝对路径时,错误就消失了。

    编辑:深入挖掘 Ivy 的源代码级别。 2.3.0 不能使用相对路径,只有绝对路径,2.2.0 没有对此位置属性进行属性替换,因此必须保留 2.2 的相对路径,因为它不会替换我的根路径属性。有点难以来回尝试升级是否可行:-(

    【讨论】:

    • 我使用了完整的绝对路径而不是相对路径,它目前在 IVY 2.3.0 上运行良好,但我也用 IVY 2.2 和 2.4 进行了测试,它的工作也正常。所以只需切换到 IVY 2.3 以确保安全
    猜你喜欢
    • 2020-06-07
    • 2014-07-19
    • 2021-10-26
    • 2018-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    • 1970-01-01
    相关资源
    最近更新 更多