Apache-ivy-publish

提供:Dev Guides
移動先:案内検索

Apache IVY-公開タスク

公開タスクは、現在のアーティファクトとその解決済み記述子ファイルを上記のリポジトリに公開するために使用されます。

link:/apache_ivy/apache_ivy_resolve [IVY-タスクの解決]の章で説明されているように、Tester.java、build.xml、ivy.xmlを作成してみましょう。

ivy publishタスクを使用するようにbuild.xmlを更新します。 まず、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.finddevguides.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 -アーティファクトを見つけるためのパターン。

ここで、公開タスクは最初に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.finddevguides#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.finddevguides#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.finddevguides\te
st\1.0\ivys\ivy.xml

BUILD SUCCESSFUL
Total time: 1 second

ローカルリポジトリで公開ivyアーティファクトを確認できます。