S-JIS[2003-12-31/2010-01-09] 変更履歴

Ant:echo

画面(コンソール)にメッセージを表示するコアタスク。
(org.apache.tools.ant.taskdefs.Echo extends Task


属性

属性 説明 備考 更新日
message="メッセージ" メッセージ。    
level="レベル" メッセージレベル。
指定しない場合、warningとなる。
ログ出力
error
warning
info
verbose
debug
2007-08-16
file="ファイル名" 指定すると、コンソールでなくファイルへ出力する。   2009-02-06
append="yes" yesにすると、出力ファイルが存在している場合に追加する。   2009-02-06
encoding="文字コード" ファイル出力の際のエンコーディング。 Ant1.7以降 2009-02-06

<project name="ant.test"  basedir="." default="echo">

  <property name="test" value="プロパティ"/>

  <target name="echo">
    <echo message="test"/>
    <echo message="${test}"/>
    <echo>改行も
      空白も関係ある
    </echo>
    <echo>${test}</echo>
  </target>

</project>

実行例

$ ant echo
Buildfile: build.xml

echo:
     [echo] test
     [echo] プロパティ
     [echo] 改行も
     [echo]       空白も関係ある
     [echo]
     [echo] プロパティ

BUILD SUCCESSFUL

クラスパスを表示する例

idの付いているクラスパスの内容を表示するには、一旦プロパティーに保持してやるとよい。[2008-11-08]

	<path id="class.path">
		<pathelement location="C:\" />
		<pathelement location="D:\" />
	</path>
	<property name="class-path" refid="class.path" />
	<echo>${class-path}</echo>

プロパティーへの変換にはpathconvertを使うという手もある。[2010-01-09]

	<pathconvert property="convert-path" refid="class.path" />
	<echo message="${convert-path}" />

Ant:echoproperties

コンソールにプロパティーの内容(一覧)を表示するオプションタスク。[2008-10-25]
(org.apache.tools.ant.taskdefs.optional.EchoProperties extends Task

最新echoproperties

	<target name="all" description="全プロパティーを出力">
		<echoproperties />
	</target>
	<target name="prefix" description="特定のプレフィクスのプロパティーを全て出力">
		<echoproperties>
			<propertyset>
				<propertyref prefix="ant." />
				<propertyref prefix="user." />
			</propertyset>
		</echoproperties>
	</target>

Ant目次へ戻る / 技術メモへ戻る
メールの送信先:ひしだま