Anuerin Diaz
2018-04-19 01:58:13 UTC
Hi,
I am trying to selectively load properties using the LoadProperties and
FilterChain+LineContains tasks. However based on my test if the Filterchain
starts to contain any "<contains/>" element then it will start discarding
all contents of the property file being read. This was tested using ant
1.10.1 adn 1.10.3 in a Java 1.8 VM hosted in a Windows 10 64-bit machine.
Below is my build xml and sample.properties file. The initialize target
has different variations that I tried to do to isolate the problem. What
could be the problem in this instance? Thanks.
-- build.xml ---
<project name="MyProject" basedir=".">
<target name="initialize">
<echo>Starting load...</echo>
<loadproperties srcFile="${basedir}/01_PropertyFiles/sample.properties">
<filterchain>
<linecontains>
<contains value="ws.user" />
<contains value="ws.password" />
<contains value="wl.user" />
<contains value="wl.password" />
</linecontains>
</filterchain>
<!--filterchain>
<filterreader classname="org.apache.tools.ant.filters.LineContains">
<param type="contains" value="user"/>
<param type="contains" value="password"/>
</filterreader>
</filterchain-->
</loadproperties>
<echo>${ws.user} - ${ws.password}</echo>
<echo>${wl.user} - ${wl.password}</echo>
<echo>${placebo.prop} should be printed as a literal. </echo>
</target>
</project>
-- end of build.xml ---
---- sample.properties ----
placebo.prop=dontprintme
ws.user=dilbert
ws.password=washere
wl.user=felix
wl.password=lantern
ps.xser=dummy
---- end of sample.properties ----
I am trying to selectively load properties using the LoadProperties and
FilterChain+LineContains tasks. However based on my test if the Filterchain
starts to contain any "<contains/>" element then it will start discarding
all contents of the property file being read. This was tested using ant
1.10.1 adn 1.10.3 in a Java 1.8 VM hosted in a Windows 10 64-bit machine.
Below is my build xml and sample.properties file. The initialize target
has different variations that I tried to do to isolate the problem. What
could be the problem in this instance? Thanks.
-- build.xml ---
<project name="MyProject" basedir=".">
<target name="initialize">
<echo>Starting load...</echo>
<loadproperties srcFile="${basedir}/01_PropertyFiles/sample.properties">
<filterchain>
<linecontains>
<contains value="ws.user" />
<contains value="ws.password" />
<contains value="wl.user" />
<contains value="wl.password" />
</linecontains>
</filterchain>
<!--filterchain>
<filterreader classname="org.apache.tools.ant.filters.LineContains">
<param type="contains" value="user"/>
<param type="contains" value="password"/>
</filterreader>
</filterchain-->
</loadproperties>
<echo>${ws.user} - ${ws.password}</echo>
<echo>${wl.user} - ${wl.password}</echo>
<echo>${placebo.prop} should be printed as a literal. </echo>
</target>
</project>
-- end of build.xml ---
---- sample.properties ----
placebo.prop=dontprintme
ws.user=dilbert
ws.password=washere
wl.user=felix
wl.password=lantern
ps.xser=dummy
---- end of sample.properties ----
--
"Programming, an artform that fights back"
Anuerin G. Diaz
Registered Linux User #246176
http://ramfree17.net/capsule , when you absolutely have nothing else better
to do
"Programming, an artform that fights back"
Anuerin G. Diaz
Registered Linux User #246176
http://ramfree17.net/capsule , when you absolutely have nothing else better
to do