#freeze
* [[ANT]]

javaをキーワードにいろいろ探していると、よくANTというキーワードを目にします。
こりゃなんでしょうか。
Another Neat Toolの略で、直訳するともうひとつのすてきなツールになります。
windowsでいえばバッチファイルみたいなものです。
eclipseでもちゃんとサポートしているし、なかなか便利そうなので覚えておいて損はなさそうです。
では環境を作ります。
http://ant.apache.org/からDownloadしましょう。

ターゲット単位で実行します。 Eclipse3.1からデバッグできるようになりました!

#contents

** プロパティの設定
 <property name="doc.dir" value="./doc" />
doc.dirというプロパティに"./doc"という値をセットしています。
セットした値は ${doc.dir}で参照することができます。

** 環境変数の取得
 <property environment="env" />
と定義しておけば、
 <fileset dir="${env.CATALINA_HOME}/common/lib">
といった感じでOSの環境変数が取得できます。

** パスの設定
 <path id="catalina.classpath">
  <fileset dir="${env.CATALINA_HOME}/common/lib">
    <include name="*.jar" />
  </fileset>
 </path>
としておけば ${env.CATALINA_HOME}/common/libにあるjarがcatalina.classpathで参照できます。
 <target name="compile" depends="init">
  <javac encoding="${encode}" srcdir="${src}" destdir="${build}" deprecation="true" debug="true">
    <classpath refid="catalina.classpath" />
  </javac>
 </target> 

** コンパイル
javacを使います。
 <target name="compile" depends="init">
  <javac encoding="${encode}" srcdir="${src}" destdir="${build}" deprecation="true" debug="true">
    <classpath refid="catalina.classpath" />
  </javac>
 </target> 

** JAVAクラスを起動
arg valueの使い方はスペースまででひとつ<arg value=""/>を作りましょう。fork="yes"で別VMで動きます。
 <target name="deploy.wsdd" depends="init" description="deploy.wsddコンパイル">
  <java classname="org.apache.axis.client.AdminClient" fork="yes">
    <arg value="-p"/>
    <arg value="8086"/>
    <arg value="${src}/deploy.wsdd"/>
    <classpath refid="main.compilation.classpath" />
    <classpath refid="axis.classpath" />
    <classpath refid="catalina.classpath" />
  </java>
  <echo message="完了" /> 
 </target>

** 依存
 <target name="deploy.wsdd" depends="init" description="deploy.wsddコンパイル">
このターゲットdeploy.wsddはinitというターゲットを実行してから、実行されます。dependsで指定します。


** メッセージ
メッセージを出力します。
 <echo message="完了" /> 

** コピー
 <!-- コピー -->
 <copy todir="${env.CATALINA_HOME}/webapps/axis/WEB-INF/classes/test">
 <fileset dir="${build}/test">
 <include name="**/*" />
 </fileset>
 </copy>

これは${env.CATALINA_HOME}/webapps/axis/WEB-INF/classes/testに"${build}/test以下のすべてのファイルをコピーします。**でディレクトリ以下もすべてコピーします。<include name="c:\test.txt" />とかを追加すると、c:\test.txtがtodirにコピーされます。

** JAR
JARをつくります。
 <target name="jar">
  <jar jarfile="${app.jar}" basedir="${destdir}">
   <fileset dir="${axis.libdir}">
    <include name="*.jar" />
   </fileset>
  </jar>
 </target>

** GET(HTTP) 
HTTPからファイルをGETします。
 <target name= "get">
  <echo message="${wsdl.location}/urn:${wsdl.urn}?wsdl" /> 
   <get src="${wsdl.location}/urn:${wsdl.urn}?wsdl" dest="${wsdl.urn}.wsdl"/>
   <get src="${wsdl.location}/urn:${wsdl.urn2}?wsdl" dest="${wsdl.urn2}.wsdl"/>
 </target>

** 削除
 <target name= "delete">
  <delete dir="${james.home}james" />
  <delete file="${james.home}${james.sar}" />
 </target>


* リンク
[[マニュアル>http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/index.html]]

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS