我想使用ivy:resolve下载工件,但使用的是使用[conf]属性的模式。所以我在下面定义了以下内容 的 IvySettings.xml
<caches defaultCacheDir="${env.IvyLib}\cache" artifactPattern="[conf]\[artifact].[ext]" checkUpToDate="false" />
注意模式
artifactPattern="[conf]\[artifact].[ext]",所以我想解决依赖关系并根据其配置将它们放在一个文件夹中。我在中定义了以下配置 的的ivy.xml
<configurations>
<conf name="ConfGroup1" description="First group of dependencies"/>
<conf name="ConfGroup2" description="Second group of dependencies"/>
</configurations>
<dependencies>
<dependency org="derby-db" name="derby-db" rev="10.2.2.0" conf="ConfGroup1->default">
<artifact name="derby-db" type="zip" ext="zip" />
</dependency>
<dependency org="derby-db" name="derby-db" rev="10.4.1.3" conf="ConfGroup2->default">
<artifact name="derby-db" type="zip" ext="zip" />
</dependency>
</dependencies>
现在依赖关系得到了很好的解决,但是只为配置创建了一个文件夹:默认。没有为ConfGroup1&amp;创建任何文件夹。 ConfGroup2配置。如何在解析期间根据我定义的配置创建多个文件夹?
PS,我知道这可以使用常春藤实现:检索,但我不想使用它,因为它会涉及将常春藤缓存中的工件复制到常春藤后的另一个地方:解决,而且我有几千兆字节的价值文物。单独复制它们会在构建期间产生额外的开销,由于项目要求,我无法负担。答案 0 :(得分:0)
常春藤retrieve task有一个符号链接选项,可用于节省空间。
├── build.xml
├── ivysettings.xml
├── ivy.xml
└── target
├── ivy-reports
│ ├── ivy-report.css
│ ├── myorg-mymod-ConfGroup1.html
│ └── myorg-mymod-ConfGroup2.html
└── lib
├── ConfGroup1
│ └── db-derby-10.12.1.1.zip -> /home/mark/.ivy2/cache/db-derby/db-derby/zips/db-derby-10.12.1.1.zip
└── ConfGroup2
└── db-derby-10.11.1.1.zip -> /home/mark/.ivy2/cache/db-derby/db-derby/zips/db-derby-10.11.1.1.zip
<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="build.dir" location="target"/>
<target name="resolve">
<ivy:resolve/>
<ivy:report todir='${build.dir}/ivy-reports' graph='false' xml='false'/>
<ivy:retrieve pattern='${build.dir}/lib/[conf]/[module]-[revision].[ext]' symlink="true"/>
</target>
</project>
<ivy-module version="2.0">
<info organisation="myorg" module="mymod"/>
<configurations>
<conf name="ConfGroup1" description="First group of dependencies"/>
<conf name="ConfGroup2" description="Second group of dependencies"/>
</configurations>
<dependencies>
<dependency org="db-derby" name="db-derby" rev="10.12.1.1" conf="ConfGroup1->default">
<artifact name="db-derby" type="zip" ext="zip" />
</dependency>
<dependency org="db-derby" name="db-derby" rev="10.11.1.1" conf="ConfGroup2->default">
<artifact name="db-derby" type="zip" ext="zip" />
</dependency>
</dependencies>
</ivy-module>
<ivysettings>
<settings defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true" />
<url name="db-derby">
<artifact pattern="http://ftp.heanet.ie/mirrors/www.apache.org/dist//db/derby/[module]-[revision]/[module]-[revision]-bin.[ext]"/>
</url>
</resolvers>
<modules>
<module organisation="db-derby" resolver="db-derby" />
</modules>
</ivysettings>