IVY Extends via ivy:resolve

一曲冷凌霜 提交于 2020-01-03 05:58:05

问题


We have recently introduced a common dependency in our build system which uses ivy:extends option within each individual ivy.xml. Common ivy.xml contents are as follows;

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>

I have around 120 projects extending the common ivy shown above to get their dependencies as follows;

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>

If you observe requirement is not to use location attribute of extends because this requires path resolution which makes all child project to be certain order etc. To achieve that we resolve common dependency once in start which produces resolved-*.xml into our local IVY cache and now want IVY to resolve the same for all child projects where it crashes with following messages;

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

Where I can clearly see that common dependency is successfully resolved and available in local cache.....how can I make <ivy:resolve /> look in local cache to find this...I have searched everywhere and it seems I have to use location :( attribute instead of relying in IVY cache.

Also when I remove the revision from common-dependency it get resolve as working@... which IVY 2.2.0 seems to resolve somehow and all my projects works OK but IVY 2.3.0 complains because it is trying to resolve revision=1.0.0 as defined in ivy.xml of child project and its mandatory otherwise IVY crashes straight away stating revision is a mandatory attribute for extends.


回答1:


OK there is no other way to solve this issue but to use the location attribute in extends. I have solved this issue by providing a property like location=${common.ivy.location} and declare this property in my ivy settings and it work like a charm.

This solution works with IVY 2.2, 2.3 and 2.4.




回答2:


Agree with SJunejo's reply. In my case I was getting this same error after moving from 2.2.0 to 2.3.0 and I was using the location attribute. I was however using a relative path. When I updated to use an absolute path, then the error went away.

EDIT: Dug down to the source level of Ivy. 2.3.0 did not work with a relative path, only an absolute one and 2.2.0 did not do property substitution for this location attribute, so had to stay with relative path for 2.2 since it would not property substitute my root path property. Kind of makes it hard to try back and forth to see if the upgrading would work :-(



来源:https://stackoverflow.com/questions/25144464/ivy-extends-via-ivyresolve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!