【问题标题】:java: generating a properties file that contains the svn version numberjava:生成一个包含svn版本号的属性文件
【发布时间】:2010-03-31 16:24:19
【问题描述】:

我想从我的 ant 脚本生成一个包含我项目的 svn 版本号的属性文件。我已经完成了 1/3:

为此,我需要:

  1. 使用 svnversion

    1a。 define the svn task

    1b。使用<svn><wcVersion></svn>

  2. 将结果放入一个 .properties 文件中,该文件最终位于我的构建路径中

我对 1a 和 2 有点迷茫。有什么想法吗?

【问题讨论】:

    标签: svn ant


    【解决方案1】:

    没关系,我搞定了:

    <target name="svnversion">
      <echo file="${srcDir}/${packagePath}/svnversion.properties">svnversion=</echo>
      <exec executable="svnversion"
          output="${srcDir}/${packagePath}/svnversion.properties" append="true">
      </exec>
    </target>   
    

    【讨论】:

      【解决方案2】:

      我使用的是执行svn info --xml,然后使用&lt;XmlProperty&gt; task 加载生成的xml 文件,最后只是替换属性文件中的一个标记,即构建路径的路径。

      所以是这样的:

      <target name="svn-build-number">
        <tempfile property="svninfo.file"/>
        <exec dir="." executable="svn" output="${svninfo.file}">
          <arg line="info --xml"/>
        </exec>
        <echo message="${svninfo.file}" />
        <xmlproperty file="${svninfo.file}" collapseAttributes="true" />
        <echo message="${info.entry.revision}" />
      </target>
      

      ${info.entry.revision} 中是当前目录中存储库的修订版。

      【讨论】:

      • 而不是温度。文件,你可以使用一个属性:
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-24
      • 2020-06-24
      • 2019-06-20
      • 2014-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多