- Apache IVY 教程
- Apache IVY - 主页
- Apache IVY - 概览
- Apache IVY - 环境设置
- Apache IVY - 术语
- Apache IVY - 设置文件
- Apache IVY - Eclipse Ivy 插件
- ANT Ivy 任务
- Apache IVY - resolve
- Apache IVY - install
- Apache IVY - retrieve
- Apache IVY - cachepath
- Apache IVY - publish
- Apache IVY - info
- 仓库
- Apache IVY - 解析器
- Apache IVY - 本地仓库
- Apache IVY - 共享仓库
- Apache IVY - 公共仓库
- Apache IVY 有用资源
- Apache IVY - 快速指南
- Apache IVY - 有用资源
- Apache IVY - 讨论
Apache IVY - 检索任务
retrieve 任务用于将依赖关系解析到项目工作区中的指定位置。
让我们创建 Tester.java、build.xml 和 ivy.xml,如 IVY - 解析任务 章节中所述。
更新 build.xml 以使用 ivy 检索任务。
build.xml
<project name="test" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
<target name="resolve" description="resolve dependencies">
<ivy:resolve />
<ivy:retrieve sync="true" type="jar" />
</target>
</project>
以下术语很重要。
sync − sync true 确保 lib 目录是最新的,并删除任何额外文件。
type − type 引导 ivy 只复制指定类型的工件,如 jar。源 jar、javadoc jar 将被忽略。源 jar 的类型是 src 或 source,javadoc jar 的类型是 doc 或 bundle。
retrieve 任务默认情况下将已解析的依赖关系复制到项目的 lib 目录中,并可以使用 pattern 属性对其进行更改。
构建项目
当我们准备好了所有文件。只要进入控制台。导航到 E: > ivy 文件夹并运行 ant 命令。
E:\ivy > ant
Ivy 将开始运行,解析依赖关系,您将看到以下结果。
Buildfile: E:\ivy\build.xml
resolve:
[ivy:resolve] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy
/ ::
[ivy:resolve] :: loading settings :: url = jar:file:/E:/Apache/apache-ant-1.9.14
/lib/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:resolve] :: resolving dependencies :: com.tutorialspoint#test;working@Acer-
PC
[ivy:resolve] confs: [default]
[ivy:resolve] found commons-lang#commons-lang;2.6 in public
[ivy:resolve] found junit#junit;3.8.1 in public
[ivy:resolve] :: resolution report :: resolve 316ms :: artifacts dl 18ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 2 | 2 | 0 | 0 || 4 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: com.tutorialspoint#test [sync]
[ivy:retrieve] confs: [default]
[ivy:retrieve] 0 artifacts copied, 2 already retrieved (0kB/2756ms)
BUILD SUCCESSFUL
Total time: 31 seconds
您可以在项目 lib 目录中验证下载的文件。
广告