■概要
AntのBuildサンプルを紹介。
■前提
- 配置ファイル
<?xml version="1.0" ?> <project name="antBuild" default="main"> <target name="main" depends="clear, compile, compress"> <echo>Building the .jar file</echo> </target> <target name="clear" description="前回ビルド結果ファイルを削除"> <delete file="Ant.class" /> <delete file="Project.jar" /> </target> <target name="compile" description="コンパイル"> <javac srcdir="." includeantruntime="false" /> </target> <target name="compress" description="圧縮"> <jar jarfile="Project.jar" basedir="." includes="*.class" /> </target> </project>
- build.xml中身について
- 実行時コンソール出力内容
C:\antSample>ant Buildfile: C:\antSample\build.xml clear: [delete] Deleting: C:\antSample\Ant.class [delete] Deleting: C:\antSample\Project.jar compile: [javac] Compiling 1 source file compress: [jar] Building jar: C:\antSample\Project.jar main: [echo] Building the .jar file BUILD SUCCESSFUL Total time: 0 seconds
- 実行結果ファイル