<!-- complicated way to set the oracle.app.username from the
version.platform property
by writing a property file, then hacking it with replaceregexp
and then rereading it.
TODO: find simpler way to do this
-->
<target name="create-oracle-username" unless="oracle.app.username">
<mkdir dir="${basedir}/build"/>
<delete file="${oracle.app.username.file}"/>
<propertyfile file="${oracle.app.username.file}">
<entry key="changeme" value="user_${version.platform}"/>
</propertyfile>
<replaceregexp file="${oracle.app.username.file}" match="\."
replace="_" flags="g"/>
<replaceregexp file="${oracle.app.username.file}" match="changeme"
replace="oracle.app.username"/>
<property file="${oracle.app.username.file}"/>
<delete file="${oracle.app.username.file}"/>
Is there some simpler way of setting the oracle.app.username property
from the value of version.platform? This would be one line in a
makefile.
> I've come across the following Ant task:
>
> <!-- complicated way to set the oracle.app.username from the
> version.platform property
> by writing a property file, then hacking it with replaceregexp
> and then rereading it.
> TODO: find simpler way to do this
> -->
> <target name="create-oracle-username" unless="oracle.app.username">
> <mkdir dir="${basedir}/build"/>
> <delete file="${oracle.app.username.file}"/>
> <propertyfile file="${oracle.app.username.file+}">
> <entry key="changeme" value="user_${version.platform}"/>
> </propertyfile>
> <replaceregexp file="${oracle.app.username.file}" match="\."
> replace="_" flags="g"/>
> <replaceregexp file="${oracle.app.username.file}" match="changeme"
> replace="oracle.app.username"/>
> <property file="${oracle.app.username.file}"/>
> <delete file="${oracle.app.username.file}"/>
>
> Is there some simpler way of setting the oracle.app.username property
> from the value of version.platform? This would be one line in a
> makefile.
Can't think of a way to get this to one line, but you might could try
something like:
<loadresource property="oracle.app.username">
<propertyresource name="version.platform" />
<filterchain>
<concat>
<header>_user</header>
<replacestring from="." to="_" />
</concat>
</filterchain>
</loadresource>
While I haven't actually tried that, loadresource + a filterchain may make
the logic a bit more clear.
HTH,
-Zig
Thanks. It's still ugly, but definitely an improvement over the
gratuitous introduction of a temporary file just to do a string
replacement.
use a scripting language and make use of the ant api,
method project.setProperty(String name, String value).
something like f.e.
if ${version.platform} is already set before, it's
as easy as =
<script language="ruby">
<![CDATA[
$project.setProperty "oracle.app.username",
"user_"+$project.getProperty('$version.platform').gsub!(/\./,'_')
]]>
</script>
you could use any scripting language that runs via bsf in VM,f.e.
(J)ruby), groovy, beanshell, javascript(rhino from Mozilla) ...
Regards, Gilbert