如何从命令行上的属性文件加载Ant属性?

如何从命令行上的属性文件加载Ant属性?,ant,properties,build,Ant,Properties,Build,我有两个属性文件[one.properties和two.properties]。我想从命令行将属性文件动态加载到Ant项目中 我的构建文件名是build.xml 命令行: > ant build [How do I pass the property file names here?] 可以在命令行上使用-D标志定义各个属性: ant -Dmy.property=42 从Ant项目中加载属性文件 解决方案结合了: 生成这样一个生成:如果为生成提供了所需的系统参数,则只允许下

我有两个属性文件[
one.properties
two.properties
]。我想从命令行将属性文件动态加载到Ant项目中

我的构建文件名是build.xml

命令行:

> ant build [How do I pass the property file names here?]
可以在命令行上使用
-D
标志定义各个属性:

ant -Dmy.property=42

从Ant项目中加载属性文件


解决方案结合了:


生成这样一个生成:如果为生成提供了所需的系统参数,则只允许下一个目标else生成失败

 Pass CMD: ant -DclientName=Name1 -Dtarget.profile.evn=dev
 Fail CMD: ant


要创建文件还是加载文件?我想使用ant build运行属性文件。我已经创建了两个属性文件,但不知道如何从cmd运行。我正在运行->蚂蚁构建。这将运行build.xml文件和我在构建文件中提到的属性文件,但我有多个属性文件,需要在ant命令build.Thaks中动态传递属性文件名,请回答。我觉得您误解了我的问题。我需要通过'cmd'运行,并需要动态传递属性文件名。请指教@Muthukumar,我扩展了我的答案,以说明如何在命令行上传递属性文件的名称[在命令行上指定属性文件]。在windows中,您可能需要添加引号,“-Dmy.property=42”
<property file="one.properties" />
<property file="two.properties" />
<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>
 Pass CMD: ant -DclientName=Name1 -Dtarget.profile.evn=dev
 Fail CMD: ant