Try this:

Instead of "hard-coding" the slash in the ant code, use ${file.separator}. It makes the statement longer but always works.

For example instead of:
${cygwin.path}/bin/bash.exe

you type:
${cygwin.path}${file.separator}bin${file.separator}bash.exe


At 12:18 PM 1/13/2003 -0500, you wrote:
It doesn't appear that there's an easy way to convert file separators from
'\' to '/' within an Ant apply task. Am I wrong about that?

The following invokes an executable compiled under Cygwin on Windows XP.
Java knows I'm a Windows user and always returns a backslash in the
<sourcefile> and <targetfile> parameters which isn't OK with Cygwin which
expects unix format forward slashes. The obvious thing is to convert the
slashes before calling my executable ... simple, right? If so, I'm having
trouble saying how.

The simplest fix would be to tell Ant and/or Java that file.separator is
actually '/' prior to invocation. Perhaps I'm being dense here, but I don't
seem to be able to make this work. I've set 'ANT_OPS=-Dfile.separator=/' to
no effect. Perhaps I'm doing something incorrectly?

The other easy solution would be to supply throw in a <pathconvert> but far
as I can tell that isn't allowed inside an <DEFANGED_apply>. A <mapper> allows me to
fudge the format to some extent but it isn't flexible enough. The 'glob'
type only allows a single '*' for myriad of different path configuration, so
that isn't good enough. The 'regexp' type is another possibility but unless
I'm missing something Ant's regex implementation doesn't offer a means to
globally replace every '\' with '/'.

Suggestions anyone?

<target name="translate_xml" depends="init, configure">
<echo message="translate_xml"/>
<DEFANGED_apply executable="${cygwin.path}/bin/bash.exe" dir="${src.dir}"
relative="true" dest="${src.dir}" vmlauncher="true">
<arg value="-c"/>
<!-- quote insures that ':' in path isn't misinterpeted by cygwin
bash'-->
<arg value="&quot;${cygwin.path}/usr/local/bin/xsltproc"/>
<arg value="-o"/>
<targetfile/>
<arg value="xml/stylesheets/copyxml.xsl"/>
<srcfile/>
<!-- end quote-->
<arg value="&quot;"/>
<fileset dir="${src.dir}" id="templates.id">
<include name="xml/templates/**/*.xml"/>
</fileset>
<mapper type="glob" from="xml\templates\*.xml"
to="xmlgen/translations/*.xml"/>
</apply>
</target>

For the record, I also tried this using 'foreach' from the contrib. Once
again path manipulations are hampered by the fact that <pathconvert> is not
allowed. I'd prefer to stick with <DEFANGED_apply> if there's any way to do it, but
other solutions that process multiple files in varying formats ... and allow
path conversion ... are appreciated.




--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to