我有一个实用程序项目,我使用 Ivy 和 Ant 构建并发布到 Artifactory:
用于 utils 项目的 ivy.xml:
<ivy-module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://ant.apache.org/ivy/maven"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
version="2.0">
<info organisation="org.abc" module="utils"/>
<configurations defaultconfmapping="%->default,sources">
<conf name="default"/>
<conf name="sources"/>
<conf name="compile-main" extends="default" visibility="private" transitive="false"/>
<conf name="compile-test" extends="compile-main" visibility="private" transitive="false"/>
<conf name="run-test" extends="compile-test" visibility="private" transitive="true"/>
</configurations>
<publications>
<artifact name="utils" type="jar"/>
<artifact name="utils-src" type="source" ext="zip" conf="sources" m:classifier="sources"/>
</publications>
<dependencies>
<--snip... -->
</dependencies>
</ivy-module>
这工作正常。我可以看到 JAR、the-sources.zip
和 Ivy 描述符很好地发布到 Artifactory。
然后我尝试在依赖项目中使用这个 JAR:
ivy.xml 用于依赖项目:
<ivy-module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://ant.apache.org/ivy/maven"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
version="2.0">
<info organisation="org.abc" module="dependent"/>
<configurations defaultconfmapping="%->default,sources">
<conf name="default"/>
<conf name="compile-main" extends="default" visibility="private" transitive="false"/>
<conf name="compile-test" extends="compile-main" visibility="private" transitive="false"/>
<conf name="run-test" extends="compile-test" visibility="private" transitive="true"/>
</configurations>
<dependencies>
<dependency org="org.abc" name="utils" rev="latest.integration" conf="default"/>
<!-- snip... -->
</dependencies>
</ivy-module>
如果我defaultconfmapping
将依赖项目的 更改为%->default
,一切正常。当我设置为defaultconfmapping
时%->default,sources
,其他依赖项(JUnit、log4j 等)的源可以正常下载,但我的 utils 项目的源出现错误:
[ivy:resolve] :: problems summary ::
[ivy:resolve] :::: WARNINGS
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve] :: UNRESOLVED DEPENDENCIES ::
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve] :: org.abc#utils;20120611153645: configuration not found in org.abc#utils;20120611153645: 'sources'. It was required from org.abc#dependent;working@blah.abc.org default
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
有趣的是,如果我查看 Ivy 缓存内部,Ivy XML 文件如下所示:
<ivy-module version="2.0">
<info organisation="org.abc"
module="utils"
revision="20120611153645"
status="release"
publication="20120611154459"
default="true"
/>
<configurations>
<conf name="default" visibility="public"/>
</configurations>
<publications>
<artifact name="utils" type="jar" ext="jar" conf="default"/>
</publications>
</ivy-module>
因此,出于某种原因,Ivy 决定在解析过程中从描述符中删除所有私有 conf(有意义)+ 源 conf + 源工件。我终其一生都无法理解为什么。我可以看到 XML 文件在 Artifactory 中很好——就像我写的一样。那么,为什么 Ivy 在解决它时会放弃源信息呢?
作为参考,这是我的 Ant 脚本的早期部分:
<ivy:configure url="http://repo:8081/artifactory/simple/bootstrap-local/ivysettings.xml"/>
<ivy:resolve log="downloadOnly"/>
<fail message="Go check out the cache file now"/> <!-- added to find out whether resolve or retrieve broke it -->
使困惑!