首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

一个完整的ant-j2se事例

2012-12-18 
一个完整的ant-j2se例子?xml version1.0 ?project namestructured defaultall basedir.!

一个完整的ant-j2se例子

<?xml version="1.0" ?><project name="structured" default="all" basedir=".">   <!-- all 代表执行 target为all 的任务 , 如果 all中 execute 任务没有包含,则不会执行--><description>Compiles and runs a simple program</description><property name="app.name" value="AntProject" /><property name="app.jar" value="${app.name}.jar" /><property name="lib.dir" value="lib" /><property name="src.dir" location="src" /><property name="build.dir" location="build" /><property name="dist.dir" location="dist" /><target name="init"><mkdir dir="${build.dir}" /><mkdir dir="${dist.dir}" /><mkdir dir="${build.dir}/lib" /></target><target name="compile" depends="init" description="Compiles the source code"><javac srcdir="${src.dir}" destdir="${build.dir}" source="1.6" target="1.6" debug="on" />  <!-- 调试模式开启 --><copy todir="${build.dir}">  <!-- 拷贝文件 todir 目标文件 --><fileset dir="${src.dir}"><include name="*.xml" /><include name="*.properties" /></fileset></copy><copy todir="${build.dir}/lib"><fileset dir="${lib.dir}"><include name="**/*.jar" /></fileset></copy></target><target name="dist" depends="compile" description="generate the distribution"><jar jarfile="${dist.dir}/${app.jar}" basedir="${build.dir}" >  <manifest>    <attribute name="Main-class" value="com.tyler4life.ant.HelloWorld"/>  </manifest></jar>  <!-- 打包 --></target><target name="clean" description="Removes the temporary directories used"><delete dir="${build.dir}/lib"></delete><delete dir="${build.dir}" /><delete dir="${dist.dir}" /></target><target name="execute" depends="compile" description="Runs the program"><echo level="warning" message="running" /><java classname="com.tyler4life.ant.HelloWorld" classpath="${build.dir}"><arg value="a" /><arg value="b" /><arg file="." /></java></target><target name="all" depends="clean,init,dist,execute" description="Clean,build,dist" /></project>

热点排行