ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Goss" <cg...@madriver.com>
Subject ant apply and file.separator
Date Mon, 13 Jan 2003 17:18:29 GMT
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 <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"/>
  <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 <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:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message