- 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 - 資訊任務
資訊任務用於在檔案設定 ivy 特定資訊,並且無需任何依賴項解析即可使用。
讓我們建立 Tester.java、build.xml 和 ivy.xm,如 IVY - 解析任務 章節所述。
更新 build.xm,以使用 ivy publish 任務。首先,我們將建立一個 JAR 檔案,然後釋出它。在釋出任務之前,我們已經使用資訊任務設定了所需的 ivy 資訊。
build.xml
<project name="test" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name = "build.dir" value = "build"/>
<target name="resolve" description="resolve dependencies">
<ivy:resolve />
</target>
<target name = "jar">
<jar destfile = "${build.dir}/lib/application.jar"
basedir = "${build.dir}/classes">
<manifest>
<attribute name = "Main-Class" value = "com.tutorialspoint.Application"/>
</manifest>
</jar>
</target>
<target name="publish" depends="jar">
<ivy:info file="ivy.xml" />
<ivy:publish resolver="local" pubrevision="1.0" overwrite="true">
<artifacts pattern="${build.dir}/lib/[artifact].[ext]" />
</ivy:publish>
</target>
</project>
在此,釋出任務首先構建 JAR,然後使用 ivy:info 任務設定資訊,再將製品釋出到本地儲存庫。
構建專案
由於我們已準備好所有檔案。只需轉到控制檯。導航到 E: > ivy 資料夾並執行 ant 命令。
E:\ivy > ant publish
Ivy 將開始執行操作,解析依賴項,您將看到以下結果。
Buildfile: E:\ivy\build.xml jar: publish: [ivy:info] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy/ :: [ivy:info] :: loading settings :: url = jar:file:/E:/Apache/apache-ant-1.9.14/l ib/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml [ivy:publish] :: publishing :: com.tutorialspoint#test [ivy:publish] published application to C:\Users\Acer\.ivy2\local\com.tutorials point\test\1.0\jars\application.jar [ivy:publish] published ivy to C:\Users\Acer\.ivy2\local\com.tutorialspoint\te st\1.0\ivys\ivy.xml BUILD SUCCESSFUL Total time: 0 seconds
如果我們沒有放置資訊任務,釋出任務將無法正常工作。使用下面修改的 build.xm,檢視缺少組織屬性等錯誤。
build.xml
<project name="test" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name = "build.dir" value = "build"/>
<target name="resolve" description="resolve dependencies">
<ivy:resolve />
</target>
<target name = "jar">
<jar destfile = "${build.dir}/lib/application.jar"
basedir = "${build.dir}/classes">
<manifest>
<attribute name = "Main-Class" value = "com.tutorialspoint.Application"/>
</manifest>
</jar>
</target>
<target name="publish" depends="jar">
<ivy:publish resolver="local" pubrevision="1.0" overwrite="true">
<artifacts pattern="${build.dir}/lib/[artifact].[ext]" />
</ivy:publish>
</target>
</project>
導航到 E: > ivy 資料夾並執行 ant 命令。
E:\ivy > ant publish
Ivy 將開始執行操作,解析依賴項,您將看到以下結果。
Buildfile: E:\ivy\build.xml jar: publish: [ivy:publish] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy / :: [ivy:publish] :: 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 BUILD FAILED E:\ivy\build.xml:28: no organisation provided for ivy publish task: It can eithe r be set explicitly via the attribute 'organisation' or via 'ivy.organisation' p roperty or a prior call to <resolve/> Total time: 3 seconds
廣告