antでダイアログを使う

開発中に環境にあわせてDB接続先を替えたりしたい場合ってよくあります。
大体、関連ファイルを差し替えて・・・とかなるんだけど、複数ファイルだったり、複数ディレクトリだったりすると必ず間違える人が出てくるんですよね。
じゃあ、ant使って設定ファイルをコピーするtask作りましょって話になると思うんですが、taskの並び順でコピータスクとマイグレーションタスクが並んでたりすると選択ミスりそうでドキドキ。というか間違えたこと有ります。
そんなミスを解消する方法として、antで選択Dialog出せないものかと。

探せばあるもんです。
ant-dialog download | SourceForge.net

ただ、使い方が探せなかった。
サンプル載せときます。
注意点は2点。
・外部ツール構成で「ワークスペースと同じJREで実行」じゃないとうまく動かず。
・完了時にリソースをリフレッシュをONに。

<project name="dialog" default="execute-change-env" basedir=".">

	<!-- パス設定 -->
	<property name="classpathdir" value="WEB-INF/classes"/>
	<path id="classpath">
		<fileset dir="lib" />
	</path>
	<taskdef resource="dialog-task.properties" classpathref="classpath"/>
<!--
	Doltengを使用してる場合用
	<taskdef resource="s2jdbc-gen-task.properties" classpathref="classpath"/>
-->


	<!-- 起動タスク -->
	<target name="execute-change-env" description="設定ファイル変更">
		<dialog dialogtitle="設定ファイル変更">
			<textfield property="selectedprojectname" defaultvalue="実行後はAPサーバを再起動して下さい。" label="説明: " required="true" size="24"/>
			<combobox property="selected.item" label="環境">
				<comboboxitem value="develop"/>
				<comboboxitem value="release"/>
			</combobox>
		</dialog>
		<fail unless="selected.item" message="環境が選択されていないか、処理がキャンセルされました。ダイアログを閉じて下さい。" />
		<property name="execute.flag" value="true"/>
		<antcall target="${selected.item}" />
<!--
		Doltengを使用してる場合はこれで自動リフレッシュ
		<refresh projectName="dialogProject"/>
-->
	</target>

	<target name="develop" if="execute.flag" description="環境を開発環境に設定します。">
		<copy overwrite="true"
			file="src/main/resources/s2jdbc-h2.dicon"
			tofile="src/main/resources/s2jdbc.dicon"
		/>
		<!-- classesにコピーしてくれないので強制的に上書き -->
		<copy overwrite="true"
			file="src/main/resources/s2jdbc-h2.dicon"
			tofile="${classpathdir}/s2jdbc.dicon"
		/>
	</target>

	<target name="release" if="execute.flag" description="環境を本番環境に変更します。">
		<copy overwrite="true"
			file="src/main/resources/s2jdbc-oracle.dicon"
			tofile="src/main/resources/s2jdbc.dicon"
		/>
		<!-- classesにコピーしてくれないので強制的に上書き -->
		<copy overwrite="true"
			file="src/main/resources/s2jdbc-oracle.dicon"
			tofile="${classpathdir}/s2jdbc.dicon"
		/>
	</target>
</project>

これで、環境設定ミスや選択ミスをだいぶ減らせるかと。

他の人はこういうミス対策どうやってるんですかね?