• Ant


    Apache Ant™ 1.8.2 手册

    绪论

    Apache Ant是基于Java的构建工具 (build tool) 。从理论上讲,它类似于make (without make’s wrinkles)。

    为什么使用?

    已经有make, gnumake, nmake, jam等其他构建工具了,为什么还要Ant?因为Ant的原始作者在开发跨平台软件时不能容忍所有这些构建工具的局限性。类似于make的构建工具本质上是基于shell的,它们评估 (evaluate) 一组依赖,然后就像你在shell上发布一个命令一样执行 (execute) 命令。这就意味着你可以很容易地扩展这些为当前操作系统 (OS) 使用或者编写的构建工具脚本,但是这也意味这你限制了你的操作系统 (OS) ,或者至少说操作系统类型,比如你正在使用的Unix。

    Makefiles本质上也是evil(邪恶的)。某些使用过它们一段时间的人或许已经陷入可怕的标签问题(tab problem)。Ant的原作者曾经多次说过,“我的命令没有执行是不是因为在我的tab前面有一个空格啊?!!”像Jam这样的构建工具很大程度上关注到这个问题,但是仍然需要使用和记得另一种格式。

    Ant不同于它们。Ant并非使用基于shell命令的模式,而是基于扩展Java类的模式。Ant使用基于XML的配置文件来替代shell命令,通过调用目标树(target tree)来执行各种任务(task)。每一个任务都会运行一个实现了特定接口的对象。

    考虑到构建脚本的跨平台运行,Ant去除了跟平台shell命令紧密相关的表达能力,比如`find . -name foo -exec rm {}`。但是如果你真的需要执行这些shell命令的话,Ant有一个<exec>的任务允许你执行与OS平台相关的命令。

    安装Apache Ant

    1. 下载Ant (http://apache.mirrors.tds.net//ant/binaries/apache-ant-1.8.4-bin.zip)
    2. 配置好环境变量

    ANT_HOME     (Ant的安装目录)

    JAVA_HOME   (Jdk的安装目录)

    PATH               (Ant的安装目录/bin; Jdk的安装目录/bin)

    安装好以后在命令行中 敲下 ant –version 测试下

    Apache Ant(TM) version 1.8.4 compiled on May 22 2012

    Installing Ant (ANT_HOME is set incorrectly…) on Windows 7

    http://stackoverflow.com/questions/5607664/installing-ant-ant-home-is-set-incorrectly-on-windows-7

    使用 Apache Ant

    写一个简单的构建文件 (Buildfile)

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="inkco-mobile" default="dist" basedir=".">
      <description>
        simple example build file
      </description>
      
      <!-- set global properties for this build -->
      <property name="src" location="src"/>
      <property name="build" location="build"/>
      <property name="dist" location="dist"/>
      
      <target name="init">
        <!-- Create the time stamp -->
        <tstamp/>
        <!-- Create the build directory structure used by compile -->
        <mkdir dir="${build}"/>
      </target>
      
      <target name="compile" depends="init" description="compile the source">
        <!-- Compile the java code from ${src} into ${build} -->
        <javac srcdir="${src}" destdir="${build}"/>
      </target>
      
      <target name="dist" depends="compile" description="Generate the distribution">
        <!-- Create the distribution directory -->
        <mkdir dir="${dist}/lib"/>
        <!-- Put everything in ${build} into the inkco-${DSTAMP}.jar file -->
        <jar jarfile="${dist}/lib/inkco-${DSTAMP}.jar" basedir="${build}"/>
      </target>
      
      <target name="clean" description="clean up">
        <!-- Delete the ${build} and ${dist} directory trees -->
        <delete dir="${build}"/>
        <delete dir="${dist}"/>
      </target>
    </project>
  • 相关阅读:
    monkey Test 环境配置
    python +ps 三方面库整理
    python +selenium +chrome/firefox 环境配置
    react-webpack config webpack@3.4.1
    解决reportNG中文乱码(转:http://www.it610.com/article/3626590.htm)
    (转)Maven的pom.xml文件配置使用
    Maven使用基础
    Myeclipse下配置SVN报错问题 svn: E175002: java.lang.RuntimeException: Could not generate DH keypair(转)
    [转]华为离职副总裁徐家骏的工作感悟
    【转】应用宝基于Robotium自动化测试
  • 原文地址:https://www.cnblogs.com/youngC/p/2814431.html
Copyright © 2020-2023  润新知