Ant开发四(只求最好)
看后要回帖的(绝对经典)
下面我们继续我们的ant开发旅程。。。。。
这篇文章讲述的是ant的核心任务 。。。很强大的希望大家看后能给我留言。。。
核心任务按顺序介绍:
好了Ant的核心任务介绍完了,那么我们就实现一下个别我感觉重点的任务。。。。嘻嘻如果想深入了解请给我留言。。。
那么我们开始了:
?
1.ant和antcall连用
首先我的调用格式为
build.xml---------test.xml-----------buildtest.xml
然后下面的是构建文件的配置:
<?xml version="1.0" encoding="UTF-8"?><project name="build" basedir="." default="all"><!--Set the property of the dir --><property name="testdir" value="testdir" /><property name="buildlib" value="build/lib" /><ant dir="build" target="create" antfile="buildtest.xml"/><ant antfile="test.xml" target="test" ><property name="builddir" value="transfer" /></ant><ant antfile="test.xml" target="testinheritall" /><target name="all"><mkdir dir="testdir" /></target><target name="clean"><delete dir="${testdir}" /><delete dir="test" /></target><target name="cleanlib" ><antcall target="clean" inheritall="false"><param name="testdir" value="build/lib" /> </antcall></target></project>?<?xml version="1.0" encoding="UTF-8"?><project name="test" basedir="." default="test" ><target name="all" ><mkdir dir="test" /></target><target name="test" ><echo message="${builddir} is the branch of the build " /><echo message="${builddir} is comming" /></target><target name="testinheritall" ><antcall target="all" inheritall="false" /></target></project>?<?xml version="1.0" encoding="UTF-8"?><project name="buildtest" basedir="." default="create" ><target name="create" ><mkdir dir="lib" /></target><target name="clean" ><delete dir="lib" /></target></project>
?好了然后我们运行下,看看结果:
Buildfile: E:\JavaPortlet\AntDemo5\build.xml
create:
??? [mkdir] Created dir: E:\JavaPortlet\AntDemo5\build\lib
test:
???? [echo] transfer is the branch of the build
???? [echo] transfer is comming
testinheritall:
all:
??? [mkdir] Created dir: E:\JavaPortlet\AntDemo5\test
all:
??? [mkdir] Created dir: E:\JavaPortlet\AntDemo5\testdir
BUILD SUCCESSFUL
Total time: 453 milliseconds
创建了3个文件夹。。。。成功。
2.antstructure和apply
举了个小例子如下:
<?xml version="1.0" encoding="UTF-8"?><project name="creatDTD" basedir="." default="create" ><target name="create" ><mkdir dir="build" /></target><apply executable="type" vmlauncher="false" os="Windows XP" ><fileset dir="."><include name="build.xml" /></fileset></apply><echo file="project.log">this is a project log</echo><target name="createDTD" ><antstructure output="project.dtd"/></target></project>
?Buildfile: E:\JavaPortlet\AntDemo6\build.xml
??? [apply] <?xml version="1.0" encoding="UTF-8"?>
??? [apply] <project name="creatDTD" basedir="." default="create" >
??? [apply] ?? ?<target name="create" >
??? [apply] ?? ??? ?<mkdir dir="build" />
??? [apply] ?? ?</target>
??? [apply] ?? ?<apply executable="type" vmlauncher="false" os="Windows XP" >
??? [apply] ?? ??? ?<fileset dir=".">
??? [apply] ?? ??? ??? ?<include name="build.xml" />
??? [apply] ?? ??? ?</fileset>
??? [apply] ?? ?</apply>
??? [apply] ?? ?<echo file="project.log">this is a project log</echo>
??? [apply] ?? ?<target name="createDTD" >
??? [apply] ?? ??? ?<antstructure output="project.dtd"/>
??? [apply] ?? ?</target>?? ?
??? [apply] </project>
create:
BUILD SUCCESSFUL
Total time: 922 milliseconds
好了。。下一篇文章将继续我们的旅程。。。。。。
?