简体   繁体   English

如何使用ant build更改配置文件变量?

[英]How can I change a config file variable using ant build?

I'm using Jboss 4/5 and have some .war .properties files with default configuration settings 我正在使用Jboss 4/5,并具有一些具有默认配置设置的.war .properties文件

I want to update these settings using information from the windows xp environment variables. 我想使用Windows XP环境变量中的信息更新这些设置。

${env} in ant $ {env} in ant

Import enviroment variables before including your property file: 在包含属性文件之前,请导入环境变量:

build.xml file: build.xml文件:

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

test.properties file: test.properties文件:

test = ${env.TEMP}

I needed to up the build number in several files. 我需要在几个文件中增加内部版本号。 Since I needed to keep the formatting of the file as well as the comments, I used replaceregexp . 由于我需要保留文件的格式以及注释,因此我使用了replaceregexp Be careful when writing your regular expressions that you limit the expression to only find the instances that you care about. 在编写正则表达式时要小心,将表达式限制为仅查找所需的实例。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在ANT build.xml文件中,如何遍历$ {env}变量中的项目? - In an ANT build.xml file, how can I iterate over the items in the ${env} variable? 如何在Windows上的环境变量中设置Jenkins ant构建中的build.xml文件的路径 - How do I set the path to the build.xml file in a Jenkins ant build from an environment variable on Windows 蚂蚁文件调用批处理文件时如何使构建失败 - How to fail a build when an ant file calls a batch file which calls an ant file 如何在输出重定向中使用vbscript变量从批处理脚本写入配置文件 - How can I write a config file from batch script using vbscript variables in output redirect 如何使用vba更改扩展文件属性 - How can I change extended file properties using vba 如何正确编写 Invoke-Expression 命令以根据配置文件值构建变量值 - How to correctly compose Invoke-Expression command to build variable value based on config file values 我的程序有一个保存配置文件的 GUI,如何双击此配置文件以直接使用配置数据加载 GUI? - I have a GUI for my program that saves a config file, how can I double click on this config file to load the GUI directly with the config data? ANT 构建脚本如何终止 Windows 进程? - How can an ANT build script kill a Windows process? 如何编辑我的.git / config文件? - How can I edit my .git/config file? 如何在使用带有文件监视的堆栈构建之前清除控制台 - How can I clear console before build using stack with file watch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM