【问题标题】:How can I change a config file variable using ant build?如何使用 ant build 更改配置文件变量?
【发布时间】:2010-12-04 08:10:24
【问题描述】:

我使用的是 Jboss 4/5,并且有一些带有默认配置设置的 .war .properties 文件

我想使用来自 windows xp 环境变量的信息来更新这些设置。

${env} 在 ant 中

【问题讨论】:

    标签: windows ant jboss properties build


    【解决方案1】:

    在包含您的属性文件之前导入环境变量:

    build.xml 文件:

    <target name="build">
       <!-- load enviroment properties -->
       <property environment="env" />
       <property file="test.properties" />
       <echo>test: ${test}</echo>
    </target>
    

    test.properties 文件:

    test = ${env.TEMP}
    

    【讨论】:

      【解决方案2】:

      我需要在几个文件中增加内部版本号。因为我需要保留文件的格式以及 cmets,所以我使用了replaceregexp。编写正则表达式时要小心,将表达式限制为仅查找您关心的实例。

      <replaceregexp 
          file="${dir.project}/build.properties"
          match="(build\.number[ \t]*=).*"
          replace="\1${build.number}"
          flags="g"
      />
      

      【讨论】:

      • 我需要知道正则表达式才能打开 project.propreties 文件中的变量。 proguard.config=proguard.cfg 打开 proguard,删除将其关闭。为此我需要什么正则表达式。
      • 在这里查看我的问题:stackoverflow.com/questions/10629726/…
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多