No.1 declare propeties on command line
ant -DpropertyName=value...
No.2 declare properties in build.xml
<property name="foo.dist" value="dist"/>
No.3 generate the properties file and load the properties into build.xml
<property file="prop1.properties" />Or
<loadproperties>
<file file="prop2.properties"/>
</loadproperties>
But if you use multiple ways above at the same time and there are duplicated properties, which one will win?
Scenario 1: Duplicated properties in one property file, the one appears later will win.
name=abc
...
name=test
The value of property "name" will be "test".
Scenario 2: Duplicated properties in different property file or in build.xml itself.
The one appears earlier will win.
build.xml
<property file="prop1.properties" />
<loadproperties>
<file file="prop2.properties"/>
</loadproperties>
prop1.properties
name=abc
prop2.properties
name=test
This time, the value of property "name" will be "abc".
Or
build.xml
<property name="name" value="AAA"/>
<property file="prop1.properties" />
The value of "name" will be "AAA"
Scenario 3:The property on the command line will always win.
build.xml
<property name="name" value="AAA"/>
and you run it like this
ant -Dname=fromCommandLine
This time, the value of "name" is "fromCommandLine".
No comments:
Post a Comment