ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: How to get sub string of a property value ?
Date Wed, 06 Feb 2002 23:10:31 GMT
--- Barry Jia <> wrote:
> for example, I define a property, value is, how
> could I to get the sub string xxxx from that value in ant scripts?

If you've got 'basename' on all the machines you run your build on:
  <target name="runBasename">
    <exec executable="basename" outputproperty="basename">
      <arg line="${} .java"/>
    <echo message="basename = ${basename}"/>

Otherwise, you could use the <script> task:
  <target name="getBasename" depends="genBasename">
    <echo message="basename = ${basename}"/>
  <target name="genBasename">
    <script language="javascript"> <![CDATA[
      file = new File(projname.getProperty(""));
      basename = file.getName();
      pos = basename.indexOf('.');
      basename = basename.substring(0, pos);
      projname.setProperty("basename", basename);

Or you could write a task to do it.



Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message