ant 在构建之前打印环境信息
示例
在构建日志中可以方便地识别出构建机器和一些参数;只需使您的main任务依赖此任务即可在每次构建之前将其打印出来。
<!-- Print Environment Info -->
<target name="environment">
<!-- Get the current timestamp -->
<tstamp>
<format property="TODAY_UK" pattern="yyyy-MM-dd HH:mm:ss:sss zzz" locale="cn,CN" />
</tstamp>
<!-- Get the hostname of the system -->
<exec executable="hostname" outputproperty="os.hostname" />
<!-- Print a bunch of information -->
<echo message="" />
<echo message=" Build Information" />
<echo message="" />
<echo message=" OS Information" />
<echo message="" />
<echo message=" User : ${user.name}" />
<echo message=" Hostname : ${os.hostname}" />
<echo message="" />
<echo message=" Name : ${os.name}" />
<echo message=" Version : ${os.version}" />
<echo message=" Build : ${os.arch}" />
<echo message="" />
<echo message="" />
<echo message=" Java Information" />
<echo message="" />
<echo message=" Version : ${ant.java.version} / ${java.version}" />
<echo message=" Java Home : ${java.home}" />
<echo message="" />
<echo message="" />
<echo message=" Current Time : ${TODAY_UK}" />
<echo message="" />
</target>这将导致以下输出,
environment:
[echo]
[echo] Build Information
[echo]
[echo] OS Information
[echo]
[echo] User : <User Name>
[echo] Hostname : <Host Name>
[echo]
[echo] Name : Windows 8.1
[echo] Version : 6.3
[echo] Build : amd64
[echo]
[echo]
[echo] Java Information
[echo]
[echo] Version : 1.8 / 1.8.0_45
[echo] Java Home : C:\Program Files\Java\jdk1.8.0_45\jre
[echo]
[echo]
[echo] Current Time : 2016-04-18 00:40:11:011 EDT
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短