嗯,${buildtat} 可以取自 Ant 中的 <tstamp> 任务。其他的可以通过svn log --xml 解析,然后使用<xmlproperties> 任务生成的XML。就在我的脑海中(即没有错误检查):
<!-- Gets the Time Stamp -->
<tstamp>
<format property="buildtat" pattern="MM/dd/yyyy HH:MM"/>
</tstamp>
<!-- Generates the revision information you need-->
<exec
executable="svn"
output="${svn.log.file}">
<arg line="log --xml -rHEAD/>
</exec>
<!-- Reads that information into a Property -->
<xmlproperty file="${svn.log.file}"/>
<echo message="Subversion Rev: ${log.logentry{revision}}"/>
但是,我建议您查看像 Jenkins 这样的持续构建系统。每当您在 Subversion 存储库中进行更改时,Jenkins 都会获取更改并自动进行新的构建。这不仅允许您验证您的更改不会破坏您的构建,而且 Jenkins 还可以执行其他操作,例如运行 JUnit 测试。然后,Jenkins 将您的构建和测试结果以及整个构建日志存储在一个易于访问的 HTML 页面中。
Jenkins 适合您的地方在于,Jenkins 会在构建过程中自动公开诸如 Subversion Revision 之类的内容。您可以获取 Subversion 版本、Jenkins 内部版本号、Jenkins 项目的名称以及许多其他内容作为环境变量。然后,您可以这样做:
<property env="env."/>
<propertyfile file="${dist.dir}\deploymentManifest.txt"
comment="This file is automatically generated - DO NOT EDIT">
<entry key="buildtime" value="${env.BUILD_ID}"/>
<entry key="build" value="${env.SVN_REVISION}"/>
<entry key="version" value="${BUILD_NUMBER}"/>
<entry key="systemLocation" value="${directory/filename.ext}"/>
</propertyfile>
看看詹金斯。它相当容易理解和使用。
下载大约需要 5 分钟,在 Linux 系统上启动和运行可能需要 10 分钟。 Windows 更复杂,可能需要 15 到 20 分钟才能启动和运行。你现在可以在你的桌面系统上运行它,然后玩弄它。
您可能需要再花半个小时来弄清楚如何设置一个可以在有人提交时自动构建的项目。
Jenkins 是基于 Web 的,但带有自己的基于 Web 的轻量级应用程序引擎。您只需要 Java 1.6 即可运行它。 (而且,如果您使用的是 Eclipse,那么您应该已经拥有它)。