Mut*_*mar 11 ant properties build
我有两个属性文件[ one.properties和two.properties].我想从命令行动态地将属性文件加载到我的Ant项目中.
我的构建文件名是build.xml.
命令行:
> ant build [How do I pass the property file names here?]
Run Code Online (Sandbox Code Playgroud)
Chr*_*ert 21
ant -propertyfile one.properties -propertyfile two.properties
Run Code Online (Sandbox Code Playgroud)
可以在命令行上使用-D标志定义各个属性:
ant -Dmy.property=42
Run Code Online (Sandbox Code Playgroud)
<loadproperties srcfile="one.properties" />
<loadproperties srcfile="two.properties" />
Run Code Online (Sandbox Code Playgroud)
<property file="one.properties" />
<property file="two.properties" />
Run Code Online (Sandbox Code Playgroud)
JB Nizet的解决方案结合了concat和fileset:
<target name="init" description="Initialize the project.">
<mkdir dir="temp" />
<concat destfile="temp/combined.properties" fixlastline="true">
<fileset dir="." includes="*.properties" />
</concat>
<property file="temp/combined.properties" />
</target>
Run Code Online (Sandbox Code Playgroud)