Apache-ivy-info
提供:Dev Guides
Apache IVY-情報タスク
infoタスクは、ファイルにivy固有の情報を設定するために使用され、依存関係の解決なしで使用できます。
link:/apache_ivy/ivy_resolve [IVY-解決タスク]の章で説明されているように、Tester.java、build.xml、ivy.xmlを作成してみましょう。
ivy publishタスクを使用するようにbuild.xmlを更新します。 まず、jarファイルを作成してから公開します。 タスクを公開する前に、infoタスクを使用して必要な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.finddevguides.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.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: 0 seconds
infoタスクを配置しない場合、publishタスクは機能しません。 以下の変更されたbuild.xmlを使用して、組織属性がないなどのエラーを確認します。
*_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: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