ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chassande-Barrioz Sebastien <Sebastien.Chassa...@inrialpes.fr>
Subject Re: short file name of the current build xml file
Date Fri, 21 Sep 2001 17:56:51 GMT
Le Vendredi 21 Septembre 2001 18:25, Diane Holt a écrit :
> --- Chassande-Barrioz Sebastien <Sebastien.Chassande@inrialpes.fr> wrote:
> > I would like to know how it's possible to find the file name of the
> > current build file. I found in the documentation that there is a
> > file.ant property,
> 
> Actually, it's "ant.file".
> 
> > but this field gives the absolute path. And I would like set in a
> > property the short name of the file: the name without the path and
> > without the .xml extension. Does ant provide tools to format string ?
> 
> There's some string manipulation available in certain tasks, but it's not
> generally available outside of those tasks. 

In fact I would like to build a jar file and make a directory with the base 
name of the xml file. I didn't find solution in both target.

>   <target name="getBasename">
>     <script language="javascript"> <![CDATA[
>       importClass(java.io.File);
>       file = new File(projname.getProperty("ant.file"));
>       basename = file.getName();
>       if (basename.endsWith(".xml")) {
>         pos = basename.indexOf('.');
>         basename = basename.substring(0, pos);
>       }
>       projname.setProperty("basename", basename) ;
>       ]]>
>     </script>
>   </target>

thanks for the script, I will try to use this solution. 

Seb
-- 
Chassande-Barrioz Sebastien
INRIALPES - SIRAC/SARDES Team - ObjectWeb initiative
Mail job : sebastien.chassande@inrialpes.fr
Phone : 04.76.61.55.16

Mime
View raw message