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

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

问题描述

我要下载取决于使用的URL解析。的depends是JS,或XML文件。所以,我用:


 < URL的名称=urlresolver>
  <神器模式=HTTP:// [机构] / [模块] - [修改] [转]/>
< / URL>



 <常春藤:检索模式=$ {}建立/ [模块]  -  [修改] [转]。/>


该文件保存在.jar扩展名。


解决方案

这是值得挖掘围绕以下常春藤文档:

第一个问题是,你的URL解析未配置为读取ivy文件远程模块(忽略第一个建议,在常春藤最佳实践,用每个模块的ivy文件)。如果没有模块的元数据常春藤将假设你正在尝试下载JAR文件。

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

 <依赖有机=yourorgNAME =模块1REV =9.1/>

将被翻译成下面的网址,使用您的当前设置:

  HTTP://yourorg/module1-9.1.jar

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

我怀疑你不是在建立档案的储存库很感兴趣,只是想说服常春藤下载并缓存文件?在这种情况下,我建议你阅读下面的答案是使用额外的属性的在dependency文物的做同样的事情:

示例

的ivy.xml

 <常春藤模块版本=2.0的xmlns:E =htt​​p://ant.apache.org/ivy/extra>
    ..
    ..
    <依赖有机=yourorgNAME =yourmodule1REV =9.1>
       <工件名称=文件1E:主机名=www.server1.comTYPE =XML/>
       <工件名称=文件2E:主机名=www.server1.comTYPE =XML/>
    < /依赖性>    <依赖有机=yourorgNAME =yourmodule2REV =9.1>
       <工件名称=文件3E:主机名=www.server2.comTYPE =XML/>
       <工件名称=file4将E:主机名=www.server2.comTYPE =XML/>
    < /依赖性>
    ..

注意:


  • 每个依赖性声明每个工件的种类,再加上额外的主机名属性。

  • 如果远程模块过的ivy.xml中,出版物部分会或者存储这些神器的信息。

  • 附加文物展示常春藤的权力使任何类型的自定义属性的元数据。

ivysettings.xml

  ..
< URL的名称=urlresolver>
      <神器模式=HTTP:// [主机名] /文件/ [机构] / [模块] - [修改] [转]。/>
< / URL>
..

演示解析如何利用这两个标准属性和自定义的主机名。

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天全站免登陆