如何在常春藤中使用 [ext] 变量? [英] how to use the [ext] variable in ivy?

查看:27
本文介绍了如何在常春藤中使用 [ext] 变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 url 解析器来下载依赖.依赖是 JS 或 XML 文件.所以,我用过:

<块引用>

<artifact pattern="http://[organisation]/[module]-[revision].[ext]"/>

<块引用>

<ivy:retrieve pattern="${build}/[module]-[revision].[ext]"/>

文件以 .jar 扩展名保存.

解决方案

以下 ivy 文档值得挖掘:

第一个问题是您的 url 解析器未配置为读取远程模块的 ivy 文件(忽略第一个建议,在 ivy 最佳实践中,为每个模块使用一个 ivy 文件).如果没有模块元数据,ivy 会假设您正在尝试下载 JAR 文件.

第二个问题是您似乎没有使用常春藤存储库来存储您的文件.以下依赖声明:

将被翻译成以下 URL,使用您当前的设置:

http://yourorg/module1-9.1.jar

org"字段旨在指定发布模块的组织单位,而不是服务器主机名.

我怀疑您对构建文件存储库并不真正感兴趣,只是想说服 ivy 下载和缓存文件?在这种情况下,我建议阅读以下使用 的答案依赖工件上的额外属性a> 做类似的事情:

示例

ivy.xml

....<dependency org="yourorg" name="yourmodule1" rev="9.1"><artifact name="file1" e:hostname="www.server1.com" type="xml"/><artifact name="file2" e:hostname="www.server1.com" type="xml"/></依赖><dependency org="yourorg" name="yourmodule2" rev="9.1"><artifact name="file3" e:hostname="www.server2.com" type="xml"/><artifact name="file4" e:hostname="www.server2.com" type="xml"/></依赖>..

注意:

  • 每个依赖项都声明了每个工件的类型,以及额外的主机名"属性.
  • 如果远程模块有 ivy.xml,出版物 部分将替代地存储此工件信息.
  • 额外的工件展示了 ivy 在启用任何类型的自定义属性元数据方面的能力.

ivysettings.xml

<代码>..<url name="urlresolver"><artifact pattern="http://[hostname]/files/[organisation]/[module]-[revision].[ext]"/>..

演示解析器如何同时使用标准属性和自定义主机名".

I want to use the url resolver to download depends. The depends are JS, or XML files. So, I used:

<url name="urlresolver">
  <artifact pattern="http://[organisation]/[module]-[revision].[ext]" />
</url>

And

<ivy:retrieve pattern="${build}/[module]-[revision].[ext]"/>

the file is saved in .jar extension.

解决方案

It's worth digging around the following ivy docs:

The first problem is that your url resolver is not configured to read ivy files for the remote modules (ignoring the first recommendation, in the ivy best practices, to use an ivy file with each module). Without module meta-data ivy will assume you're attempting to download JAR files.

A second problem is that you don't appear to be using an ivy repository to store your files. The following dependency declaration:

<dependency org="yourorg" name="module1" rev="9.1"/>

would be translated into the following URL, using your current settings:

http://yourorg/module1-9.1.jar

The "org" field is designed to specify the organisational unit publishing the module, not the server hostname.

I suspect that you're not really interested in building a repository of files and just want to persuade ivy to download and cache the files? In that case I'd recommend reading the following answer which is using extra attributes on the dependency artifacts to do something similar:

Example

ivy.xml

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    ..
    ..
    <dependency org="yourorg" name="yourmodule1" rev="9.1">
       <artifact name="file1"  e:hostname="www.server1.com" type="xml"/>
       <artifact name="file2"  e:hostname="www.server1.com" type="xml"/>
    </dependency>

    <dependency org="yourorg" name="yourmodule2" rev="9.1">
       <artifact name="file3"  e:hostname="www.server2.com" type="xml"/>
       <artifact name="file4"  e:hostname="www.server2.com" type="xml"/>
    </dependency>
    ..

Note:

  • Each dependency declares the type of each artifact, plus the additional "hostname" attribute.
  • If the remote modules had ivy.xml, the publications section would alternatively store this artifact information.
  • Extra artifacts demonstrate ivy's power in enabling any sort of custom attribute meta-data.

ivysettings.xml

..
<url name="urlresolver">
      <artifact pattern="http://[hostname]/files/[organisation]/[module]-[revision].[ext]" />
</url>
..

Demonstrates how the resolver makes use of both the standard attributes and the custom "hostname".

这篇关于如何在常春藤中使用 [ext] 变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆