mag*_*ter 7 java ant timestamp
我想在Ant属性中存储UNIX时间戳(即自纪元以来的秒数),以便稍后在几个构建目标中使用.这似乎是不可能的:
<tstamp>
<format property="build.time" />
</tstamp>`
Run Code Online (Sandbox Code Playgroud)
...生成格式化的时间戳.
<propertyfile file="foo.properties">
<entry key="build.time" type="date" default="now" />
</propertyfile>
Run Code Online (Sandbox Code Playgroud)
...还会生成格式化的时间戳.
我希望这可以不使用<exec>或类似(因为我们有时会在Windows上运行构建).
一个快速谷歌提出:
http://www.norio.be/blog/2010/08/getting-unix-time-epoch-ant-build-file
<target name="print-epoch">
<script language="javascript">
<![CDATA[
property = project.setProperty("now",Math.floor((new Date()).getTime()/1000));
]]>
</script>
<echo message="${now}" />
</target>
Run Code Online (Sandbox Code Playgroud)
其他方法将是更清洁的IMO
创建自己的自定义anttask.这真的不那么难; http://ant.apache.org/manual/develop.html
使用Maven exec插件执行Java来执行此操作:http: //mojo.codehaus.org/exec-maven-plugin/
| 归档时间: |
|
| 查看次数: |
2062 次 |
| 最近记录: |