问题描述
我们最近在构建系统中引入了一个通用依赖项,该依赖项在每个单独的ivy.xml中使用ivy:extends
选项.常见的ivy.xml内容如下;
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>
我有大约120个项目,它们扩展了上面显示的常见常春藤,从而获得了它们的依存关系;
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>
如果您发现要求不要使用extends
的location
属性,因为这需要路径解析,这会使所有子项目保持一定顺序,等等.要实现这一点,我们从一开始就解决了公共依赖项,从而产生了resolve- * .xml到我们本地的IVY缓存中,现在希望IVY为所有子项目解析相同的内容,并在出现以下消息时崩溃;
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
在哪里我可以清楚地看到常见的依赖关系已成功解决并且可以在本地缓存中使用.....我怎样才能使<ivy:resolve />
在本地缓存中查找以找到此...我到处搜索了,看来我已经使用location
:(属性,而不是依赖IVY缓存.
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.
此外,当我从公共依赖关系中删除revision
时,它得到的解析为working@...
,IVY 2.2.0似乎以某种方式解决了该问题,我的所有项目都可以正常工作,但是IVY 2.3.0抱怨是因为它试图解决 revision = 1.0.0 及其强制性,否则IVY崩溃会立即指出revision
是extends
的强制属性.
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
.
推荐答案
确定没有其他方法可以解决此问题,只能使用extends
中的location
属性.我已经通过提供类似location=${common.ivy.location}
的属性并在我的常春藤设置中声明了此属性来解决了此问题,它的工作原理就像一个魅力.
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.
此解决方案适用于IVY 2.2、2.3和2.4.
This solution works with IVY 2.2, 2.3 and 2.4.
这篇关于IVY通过ivy:resolve扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!