Apache IVY 釋出任務



publish 任務用於對當前製品及其已解析描述檔案釋出到所述儲存庫。

讓我們建立 Tester.java、build.xml 和 ivy.xml,如 IVY - 解析任務 章節中所述。

更新 build.xml 以使用 ivy publish 任務。首先,我們將建立一個 jar 檔案,然後將其釋出。

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:resolve />
      <ivy:publish resolver="local" pubrevision="1.0" overwrite="true">
         <artifacts pattern="${build.dir}/lib/[artifact].[ext]" />
      </ivy:publish>   
   </target>
</project>

以下是重要術語。

  • resolver − 要用於釋出的解析器。

  • pattern − 定位製品的模式。

在這裡,publish 任務先構建 jar,然後解析依賴項,設定資訊,再將製品釋出到本地倉庫。

構建專案

由於我們已經準備好了所有檔案。只要轉到控制檯。導航到 E: \ >ivy 資料夾並執行 ant 命令。

E:\ivy > ant publish

Ivy 將投入使用,解析依賴項,您將看到以下結果。

E:\ivy > ant publish
Buildfile: E:\ivy\build.xml

jar:

publish:
[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;1.0.0
[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 121ms :: artifacts dl 15ms
      ---------------------------------------------------------------------
      |                  |            modules            ||   artifacts   |
      |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
      ---------------------------------------------------------------------
      |      default     |   2   |   2   |   0   |   0   ||   4   |   0   |
      ---------------------------------------------------------------------
[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: 1 second

您可以在本地倉庫中驗證釋出的 ivy 製品。

廣告
© . All rights reserved.