- Apache IVY 教程
- Apache IVY - 主頁
- Apache IVY - 概述
- Apache IVY - 環境設定
- Apache IVY - 術語
- Apache IVY - 設定檔案
- Apache IVY - Eclipse Ivy 外掛
- ANT Ivy 任務
- Apache IVY - 解析
- Apache IVY - 安裝
- Apache IVY - 檢索
- Apache IVY - 快取路徑
- Apache IVY - 釋出
- Apache IVY - 資訊
- 儲存庫
- Apache IVY - 解析器
- Apache IVY - 本地庫
- Apache IVY - 共享庫
- Apache IVY - 公共庫
- Apache IVY 有用資源
- Apache IVY - 快速指南
- Apache IVY - 有用資源
- Apache IVY - 討論
Apache IVY - Cachepath 任務
cachepath 任務用於建立一個 ANT 類路徑,其中包含已解析且存在於快取中的工件。由於 ANT 需要 jar 成為編譯 Java 檔案的類路徑,因此 Ivy cachepath 構建類路徑。
按照 IVY - 解析任務 一章中描述的那樣,建立 Tester.java、build.xml 和 ivy.xml。
更新 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:cachepath pathid="new.classpath" />
</target>
<target name="compile" depends="resolve" description="Compile">
<mkdir dir="build/classes" />
<javac srcdir="src" destdir="build/classes">
<classpath refid="new.classpath" />
</javac>
</target>
</project>
以下是重要術語。
pathid − 快取的 jar 存在的類路徑 ID。
檢索任務預設將解析的依賴項複製到專案的 lib 目錄,並可以使用模式屬性進行更改。
構建專案
由於我們已經準備好所有檔案。只需轉到控制檯。導航到 E: > ivy 資料夾並執行 ant 命令。
E:\ivy > ant compile
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 2314ms :: artifacts dl 15ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 2 | 2 | 0 | 0 || 4 | 0 |
---------------------------------------------------------------------
compile:
[javac] E:\ivy\build.xml:13: warning: 'includeantruntime' was not set, defau
lting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to E:\ivy\build\classes
BUILD SUCCESSFUL
Total time: 3 seconds
您可以在專案構建目錄中驗證已編譯的類檔案。
廣告