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
以上是 ant 在构建之前打印环境信息 的全部内容, 来源链接: utcz.com/z/326210.html