Hi guys,
I am using the following targets to read the Windows registry.
<target name="ADSVersion" depends="rawADSVersion" if="exists.ADSVersion"
unless="ADSVersion">
<pathconvert property="ADSVersion">
<path path="${rawADSVersion}"/>
<mapper type="regexp" from=".*REG_SZ[ ]*(.*)\b" to="\1"/>
</pathconvert>
<echo level="info" message="ADSVersion=${ADSVersion}"/>
</target>
<target name="rawADSVersion" depends="REGExe,ADSKeyString,VersionValueString"
unless="rawADSVersion">
<exec executable="${REGExe}" failonerror="false" resultproperty="rcodeADS"
outputproperty="rawADSVersion">
<arg value="QUERY"/>
<arg value=""${ADSKeyString}""/>
<arg value="/v"/>
<arg value="${VersionValueString}"/>
</exec>
<condition property="exists.ADSVersion">
<not>
<isfailure code="${rcodeADS}"></isfailure>
</not>
</condition>
</target>
These work fine for most registry keys that I require. My problem is that when
I try to read the InstallDir registry key the regexp does not return
'D:\temp\ADS' as expected but 'D'.
It seems as though The ':' acts as a line terminator. I have tried
<mapper type="regexp" from=".*REG_SZ[ ]*(.*)$" to="\1"/>
which worked when the supplied path was a property (pre-) defined in build.xml
but failed when the identical(?) string was read from the registry.
Could some regexp guru refactor my expression so that it works, or an ant guru
point me at a better way of parsing the rawADSVersion
Thanks,
Graham