您的位置:首页 > 其它

ant 使用笔记

2012-08-01 15:47 246 查看
一、常见的ant自带task

1.echo 显示在console或者是file中

<echo message="hello">

<echo message="Good morning!" file="log.txt" append="true">

2.mkdir 创建文件

<mkdir dir="${dist}/lib">

3.copy 拷贝文件(执行copy条件,源文件新于目标文件or目标文件不存在)

<copy todir="${dist}/conf" overwrite="true">

  <fileset dir="${src}/WEB-INF">

    <include name="*.xml">

  </fileset>

<copy>

4.自动打jar包和zip源码包

<target name="adbrandFacadeJarZip" depends="compile, pages" description="package adBrandFacade into jar and zip files">
  <jar jarfile="${dist.dir}/${ead_name}.jar" compress="true" basedir="${build.dir}">
    <include name="**/IAdBrandDao.class" />
    <include name="**/AdBrandDaoImpl.class" />
  </jar>
  <zip destfile="${dist.dir}/${ead_name}-src.zip">
    <fileset dir="${src.dir}">
      <include name="**/IAdBrandDao.java" />
      <include name="**/AdBrandDaoImpl.java" />
    </fileset>
  </zip>
</target>

5.scp 远程拷贝

<scp todir="user:password@somehost:/home/">

  <fileset dir="src_dir">

    <include name="**/*.java"/>

  </fileset>

</scp>

二、target下的task自定义

1.java文件(jar)

public class HelloWorld {

  String msg;

  public void execute() {

    System.out.println(msg);

  }

  public void setMsg(String msg) {

    this.msg = msg;

  }

}

2.build.xml配置

<target description="Use the Task">

  <taskdef name="helloworld" classname="HelloWorld" classpath="helloworld.jar"/>

  <helloworld msg="Hello World"/>

</target>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: