ant 学习 1

1.读取系统环境变量 以及echo命令

  <property environment="env"/>
  <property name="env.home" location="${env.HOME}"/>
  <echo message="env.home=${env.home}" />

2. <tstamp/>:

Sets the DSTAMP, TSTAMP, and TODAY properties in the current project, based on the current date and time.

  <target name="init">
    <tstamp/>
    <echo message="DSTAMP=${DSTAMP}" />
    <echo message="${DSTAMP}" />
    <echo message="${TSTAMP}" />
  </target>

结果:

init:
     [echo] DSTAMP=20210803
     [echo] 20210803
     [echo] 1136

3.target依次调用

<?xml version="1.0" encoding="UTF-8"?>
<project default="setup" basedir=".">
  <property name="dir.lib" location="${basedir}/lib"/>
  <property name="dir.lib.main" location="${dir.lib}/main"/>
  <property name="dir.antlib" location="${user.home}/.ant/lib"/>
  <property name="overwrite.deps" value="true"/>
  <property name="ant-contrib.jar" location="${dir.lib.main}/ant-contrib-1.0b3.jar"/>
  <property name="maven-artifact-ant.jar" location="${dir.lib.main}/maven-artifact-ant-2.0.4.jar"/>

  <target name="init">
    <tstamp/>
  </target>

  <target
    name="setup"
    depends="init"
    description="Set up build environment."
   >
    <antcall target="setup.deps"/>
  </target>

  <target
    name="setup.deps"
    depends="init"
    description="Set up dependencies."
   >
    <mkdir dir="${dir.antlib}"/>
    <copy
      tofile="${dir.antlib}/ant-contrib.jar"
      file="${ant-contrib.jar}"
      overwrite="${overwrite.deps}"
     />
    <copy
      tofile="${dir.antlib}/maven-artifact-ant.jar"
      file="${maven-artifact-ant.jar}"
      overwrite="${overwrite.deps}"
     />
  </target>
</project>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值