`
dsotbs936
  • 浏览: 38016 次
  • 性别: Icon_minigender_1
  • 来自: 浙江
文章分类
社区版块
存档分类
最新评论

Ivy's Multiple Resolvers

阅读更多

This example is an illustration of how modules can be retrieved by multiple resolvers. Using multiple resolvers can be useful in many contexts, here are some examples:

  • separate integration builds from releases
  • use a public repository for third party modules and a private one for internal modules
  • use a repository for storing modules which are not accurate in an unmanaged public repository
  • use a local repository to expose builds made on one developer's station

In Ivy, the use of multiple resolvers is supported by one compound resolver called a chain resolver.

In our example, we will simply show how to use two resolvers, one on a local repository and one using maven2 repository.

project description

the project: chained-resolvers

The project is very simple and contains only one simple class: example.Hello.

It depends on two libraries: Apache commons-lang and a little test library (sources are included in jar file). The test library is used by the project to uppercase a string, and commons-lang is used to capitalize the same string.

Here is the content of the project:

  • build.xml: the ant build file for the project
  • ivy.xml: the ivy project file
  • src\example\Hello.java: the only class of the project

Let's have a look at the ivy.xml file:

<ivy-module version="1.0">
<info organisation="org.apache" module="chained-resolvers"/>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.0"/>
<dependency name="test" rev="1.0"/>
</dependencies>
</ivy-module>

As we expect, the ivy file declares to be dependent on the two libraries that the project use: commons-lang and test. Note that we don't specify the organisation for the dependency test, in this case Ivy assumes the same org as the declaring module, ie org.apache in this case.

the ivy settings

The ivy settings is made in the settings directory it contains only one file: ivysettings.xml.

<ivysettings>
<settings defaultResolver="chain-example"/>
<resolvers>
<chain name="chain-example">
<filesystem name="libraries">
<artifact pattern="${ivy.settings.dir}/repository/[artifact]-[revision].[ext]" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" />
</chain>
</resolvers>
</ivysettings>

the settings tag

This tag initializes ivy with some parameters. Here only one is used, the name of the resolver to use by default.

the resolvers tag

Under this tag, we can find the description of the resolvers that ivy will use. In our example, we have only one resolver, called "chain-example", which is quite special as it defines a list (a chain) of resolvers.
The resolvers put in the chain are :

  • libraries : it is a file resolver. This one is configured to look for artifacts in the "repository" sub directory of the directory that contains the ivysettings.xml file.
  • ibiblio : this resolver is a special one. It looks in the ibiblio maven repository to retrieve the libraries.

That's it, we have configured a chain of resolvers!

walkthrough

step 1: preparation

Open a DOS or shell window, and go to the "chained-resolvers" directory.

step 2: clean directory tree

On the prompt type: ant
This will clean up the entire project directory tree and ivy cache. You can do it each time you want to clean up this example.
In almost all examples, we provide a clean target as default target. Since most examples use the same Ivy cache, you will clean the whole Ivy cache each time you call this target.

Cleaning Ivy cache is something you can do with no fear (except performance): it's only a cache, everything can be (and should be) obtained again from repositories. For those coming from maven 2 land, this may sounds strange, but remember that in Ivy, the cache is not a local repository, things are kept cleanly isolated.

step 3: run the project

Go to chainedresolvers-project directory. And simply run ant.
I:\chained-resolvers\chainedresolvers-project>ant
Buildfile: src\example\chained-resolvers\chainedresolvers-project\build.xml resolve: [ivy:retrieve] :: Ivy 2.0.0-beta1-local-20071104204849 - 20071104204849 :: http://ant.apache.org/ivy/ :: [ivy:retrieve] :: loading settings :: file = C:\dev\data\opensource_workspace\ivy\src\example\chained-resolvers\config\ivysettings.xml [ivy:retrieve] :: resolving dependencies :: [ org.apache | chained-resolvers | working@BEN-ScokartG ] [ivy:retrieve] confs: [default] [ivy:retrieve] found [ commons-lang | commons-lang | 2.0 ] in ibiblio [ivy:retrieve] found [ org.apache | test | 1.0 ] in libraries [ivy:retrieve] downloading http://www.ibiblio.org/maven/commons-lang/jars/commons-lang-2.0.jar ... [ivy:retrieve] ............................................................. [ivy:retrieve] ......................................................... (165kB) [ivy:retrieve] .. (0kB) [ivy:retrieve] [SUCCESSFUL ] [ commons-lang | commons-lang | 2.0 ]/commons-lang.jar[jar] (5928ms) [ivy:retrieve] downloading C:\dev\data\opensource_workspace\ivy\src\example\chained-resolvers\config\repository\test-1.0.jar ... [ivy:retrieve] .. (1kB) [ivy:retrieve] [SUCCESSFUL ] [ org.apache | test | 1.0 ]/test.jar[jar] (10ms) [ivy:retrieve] :: resolution report :: --------------------------------------------------------------------- | | modules || artifacts | | conf | number| search|dwnlded|evicted|| number|dwnlded| --------------------------------------------------------------------- | default | 2 | 2 | 0 | 0 || 2 | 2 | --------------------------------------------------------------------- [ivy:retrieve] :: retrieving :: [ org.apache | chained-resolvers ] [ivy:retrieve] confs: [default] [ivy:retrieve] 2 artifacts copied, 0 already retrieved run: [mkdir] Created dir: C:\dev\data\opensource_workspace\ivy\src\example\chained-resolvers\chainedresolvers-project\build [javac] Compiling 1 source file to C:\dev\data\opensource_workspace\ivy\src\example\chained-resolvers\chainedresolvers-project\build [java] standard message :example world ! [java] capitalized by org.apache.commons.lang.WordUtils : Example World ! [java] upperCased by test.StringUtils : EXAMPLE WORLD ! BUILD SUCCESSFUL Total time: 12 seconds

We can see in the log of the resolve task, that the two dependencies have been retrieved (2 artifacts) and copied to the ivy cache directory (2 downloaded).

The run target succeed in using both commons-lang.jar comming from ibiblio repository and test.jar coming from the local repository.

Going further

This very simple example helps to see how to make a basic setting of two resolvers in a chain. The chain resolver's reference documentation is available for those who would like to know all the features offered by this resolver.

The most interesting things to know that you can try out from this basic example are:

  • a chain is not limited to two nested resolvers, you can use the number you want
  • by setting returnFirst="true", you can have a chain which stops as soon as it has found a result for a given module
  • by setting dual="true", the full chain will be used both for module descriptors and artifacts, while with dual="false", the resolver in the chain which found the module descriptor (if any) is also used for artifacts

go http://ant.apache.org/ivy/history/2.1.0-rc2/tutorial/multiple.html

分享到:
评论

相关推荐

    liferay开发需下载的.ivy

    - `resolvers`:配置依赖的来源,如远程仓库或本地文件系统。 总的来说,`liferay开发需下载的.ivy`意味着在Liferay开发环境中,使用Ivy作为依赖管理工具,通过`.ivy`文件配置项目依赖,以实现自动化下载和管理,...

    ant+ivy+nexus的使用

    在IT行业中,构建管理和依赖管理是软件开发流程中的重要环节,Ant、Ivy和Nexus是其中的关键工具。Ant是一个基于Java的任务驱动的构建工具,它允许开发者自定义构建脚本来自动化项目的构建过程。Ivy则是一个依赖管理...

    resolvers:定期验证的公共DNS解析器列表

    resolvers.txt定期验证的公共DNS解析器的新列表。 $ wget https://raw.githubusercontent.com/janmasarik/resolvers/master/resolvers.txt$ massdns -r resolvers.txt domains_to_resolve.txt为什么?人们需要一个好...

    resolvers

    在IT行业中,"resolvers"通常指的是在软件开发中用于处理数据获取和转换的组件,尤其是在GraphQL或某些特定框架(如React Apollo)中。这里,我们深入探讨一下resolvers的相关知识。 1. **什么是Resolvers**: ...

    resolvers::clipboard:验证解析器

    $ npm install @hookform/resolvers 原料药 resolver(schema: object, config?: object) 类型 必需的 描述 图式 object ✓ 验证模式 配置 object 验证架构配置对象 快速开始 无效的简单对象架构验证。 import ...

    graphql-merge-resolvers:轻巧而功能强大的软件包使您可以轻松地模块化和合并解析器

    @ wiicamp / graphql-merge-resolvers 轻巧而功能强大的软件包使您可以轻松地模块化和合并您的解析器。 目录 特征 易于使用 纯JavaScript 轻量级软件包,无依赖 ES6课程 安装 npm i --save @wiicamp/graphql-merge...

    dnscrypt-resolvers:公共 DNSCrypt DoH DNS 服务器和 DNS 中继列表

    公共 DNSCrypt 和 DoH 服务器列表 公共 DNS 服务器的交互式列表: 公共DNS服务器互动图: 稳定下载地址: 更多 DNS 服务器来源: DNSCrypt 中继列表 匿名 DNS 中继: ODoH 服务器和中继列表 ...

    find_open_resolvers:查找开放递归域名服务器

    find_open_resolvers -- 在给定的 IP 范围内查找开放的 DNS 解析器。 概要 find_open_resolvers [选项] [IP 范围] Options: --queries simultaneous queries to perform (100) --retries number of retries of ...

    graphql-resolvers:GraphQL的解析器组成库

    该软件包在上可用: graphql-resolvers npm install graphql-resolvers 不过,您应该考虑使用 。 动机 很多时候,我们最终在解析器上重复很多逻辑。 例如,访问控制是可以在解析器级别完成的操作,但是即使在为此类...

    Fresh-Resolvers:每小时更新一次的最新DNS解析器列表

    《Fresh-Resolvers:每小时更新的最新DNS解析器列表详解》 DNS(Domain Name System)是互联网上的一项核心服务,它将人类易读的域名转换为计算机可识别的IP地址。在日常网络活动中,DNS解析器起着至关重要的作用,...

    apollo-resolvers:Apollostack 的 GraphQL 服务器的富有表现力和可组合的解析器

    apollo-resolvers的目标是通过将许多这些决策抽象成一个漂亮的、富有表现力的设计模式来简化开发人员在使用 GraphQL 时的体验。 apollo-resolvers提供了一种创建解析器的模式,这些解析器本质上类似于React式中间件...

    dsa-resolvers

    标题 "dsa-resolvers" 暗示我们正在讨论一个与分布式系统架构(DSA)相关的项目,特别是关于解析器的部分。这个解析器可能用于处理特定的数据请求或操作,以支持智能合约的功能。描述中的“智能合约可简化读取操作”...

    fresh-resolvers

    "Fresh Resolvers" 是一个专为React开发设计的解析器列表,它专注于提供无毒、可靠的解决方案,以满足开发者在项目中枚举各种需求时的需求。这个项目利用GitHub的自动化功能,每两小时进行一次更新,确保所列出的...

    dmut-resolvers:dmut项目的公共DNS服务器列表

    此仓库使用github动作生成resolvers.txt。 该任务每天运行一次。 该过程包括: 从下载公共列表 使用检查此列表 更新此仓库回购结果。 生成此文件以供 top20.txt 排名前20位的公共dns服务器,以防您需要小型快速...

    sbt-artifactory:一个小巧的sbt插件,可简化向JFrog Artifactory的发布

    用法添加到您的project/plugins.sbt resolvers + = Resolver .url( " ivy-release-local " , url( s " https://jrouly.jfrog.io/artifactory/ivy-release-local " ))( Resolver .ivyStylePatterns)addSbtPlugin( " ...

    mvel 2.0.15

    MVEL supports that too, and there is both and easy way and a more advanced way (dealing with resolvers – which we won't get to here). The easy way simply involves passing in a Map of variables ...

    react_form_with_multiple_steps:培训项目,多步骤React形式

    具有多个步骤的高级 React 表单项目的工作链接: ...js React五彩纸屑React区React钩形甜蜜警报2 是的细微差别安装@hookform/resolvers 的问题是只能通过npm 安装,通过yarn 没用。

    fresh-resolvers:每天更新的新DNS解析器列表

    新鲜的解析器 使用程序每天生成新的可用DNS解析程序的列表。 列表应该通过使用计划的Github操作可靠地保持更新,而不必依赖外部VPS之类的东西。

    用sbt构造好的Intellij版的spark工程

    resolvers += "Typesafe Ivy Releases" at "http://repo.typesafe.com/typesafe/ivy-releases" resolvers += "Maven Central" at "https://repo1.maven.org/maven2" ``` - 使用本地Maven仓库缓存依赖:在`build....

    scalaz-stream-contrib:scalaz-stream 的附加进程

    scalaz-stream-贡献 ...resolvers + = " Frank's Bintray " at " https://dl.bintray.com/fthomas/maven " libraryDependencies + = " eu.timepit " %% " scalaz-stream-contrib " % " &lt;version&gt;

Global site tag (gtag.js) - Google Analytics