• ant 使用笔记


    一、常见的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>

  • 相关阅读:
    ThreadPoolExecutor的corePoolSize、maximumPoolSize和poolSize
    ThreadPoolExecutor线程池的一个面试题
    SpringBoot 集成Jedis操作set
    死磕JVM之类中各部分的加载顺序
    ThreadLocal为什么会内存泄漏
    有趣的RPC理解
    MQ如何解决消息的顺序性
    Collections.sort排序
    对象的内存分析
    类与对象的分析
  • 原文地址:https://www.cnblogs.com/yanghuahui/p/2618447.html
Copyright © 2020-2023  润新知