ant常用task

http://ant.apache.org/manual/index.html ANT常用任务


设置classpath
<path id="project.classpath">

    <!-- 第1种方式 -->
    <pathelement path="${basedir}/lib/aa.jar" />


    <!-- 第2种方式 与1的区别在于location可以去当前路径,当然可以使用绝对路径-->
    <pathelement location="aa.jar" />
   

    <!-- 第3种方式 -->

    <filelist id="file" dir="${basedir}/lib">
        <file name="a.jar" />
        <file name="d:lib/b.jar" />
    </filelist>


    <!-- 第4种方式 -->
    <fileset dir="d:/lib">
        <include name="**/*.jar" />
    </fileset>

</path>

使用classpath
<javac scdir="./src" destdir="./classes">
    <classpath refid="project.classpath" />
</javac>

拷贝文件

拷贝一个文件
<copy file="myfile.txt" tofile="mycopy.txt" />

拷贝文件到目录
<copy file="myfile.txt" todir="../some/other/dir" />

拷贝目录到另一目录
<copy todir="../new/dir">
    <fileset dir="sir_dir" />
</copy>

拷贝文件集合到目录
<copy todir="../dest/dir">
    <fileset dir="src_dir">
        <exclude name="**/*.java" />
    </fileset>
</copy>
<copy todir="../dest/dir">
    <fileset dir="src_dir" excludes="**/*.java" />
</copy>

删除文件,目录
<delete file="/lib/ant.jar" />
<delete dir="lib" />
<delete>
    <fileset dir="." includes="**/*.bak" />
</delete>

移动文件,目录
<move todir="some/new/dir">
    <fileset dir="my/src/dir">
        <include name="**/*.jar" />
        <exclude name="**/ant.jar" />
    </fileset>
</move>

创建文件,目录
<touch file="myfile" />
<mkdir dir="${dist}/lib" />

设置property 读取环境变量
<property environment="env" />

读取属性文件中的属性
<property file="foo.peoperties" />

设置属性name-value
<property name="foo.dist" value="dist" />

读取文件中的属性配置
<property resource="foo.properties" />

jar包
<jar destfile="${dist}/lib/app.jar" basedir="{build}/classes"
    includes="mypackage/test/**" excludes="**/Test.class" />
   
Ear包
<ear destfile="build/myapp.ear" appxml="src/metadata/application.xml">
    <fileset dir="build" includes="*.jar,*.war" />
</ear>

执行程序
<target name="help">
    <exec executable="cmd">
        <arg value="/c" />
        <arg value="ant.bat" />
        <arg value="-p" />
    </exec>
</target>

运行jar包
<java classname="test.Main">
    <arg value="-h" />
    <classpath>
        <pathelement location="dist/test.jar" />
    </classpath>
</java>

编译程序
<javac srcdir="${src}" destdir="${build}" classpath="xyz.jar" debug="on" source="1.4" />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值