Apache-ivy-cachepath

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

Apache IVY-キャッシュパスタスク

cachepathタスクは、キャッシュに存在するアーティファクトが解決されたANTクラスパスを作成するために使用されます。 ANTはJavaファイルをコンパイルするためにjarをクラスパスにする必要があるため、Ivy cachepathはクラスパスを構築します。

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

ivy取得タスクを使用するようにbuild.xmlを更新します。

*_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.finddevguides#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

プロジェクトのビルドディレクトリでコンパイル済みクラスファイルを確認できます。