ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject Re: Splitting full filename into package and filename
Date Wed, 18 Feb 2004 12:01:49 GMT
F. Da Costa wrote:

> Peter Reilly wrote:
>
>> Hi,
>> You have ran into one of the currently weak areas of ant - mapping of 
>> paths and filenames.
>> The easiest solution I can think of is to use a script:
>>
> Following is another solution just using Ant (& the contrib lib). Or 
> am i missing something that makes it unusable on an ..x platform?
>
> <property name="src" value="${src.dir}" />
> <propertyregex property="src" override="yes" input="${src}" 
> regexp="\\" replace="~" global="true" />
> <echo message=" source: ${src}" />
>
> <propertyregex property="tmpdir" input="${dir}" regexp="\\" 
> replace="~" global="true" />
> <echo message="temp: ${tmpdir}" />
>
> <propertyregex property="tmpdir" override="yes" input="${tmpdir}" 
> regexp="${src}~" replace="" />
> <echo message="temp2: ${tmpdir}" />
>
> <propertyregex property="package.dir" input="${tmpdir}" regexp="~" 
> replace="\." global="true" defaultValue="${tmpdir}"/>
> <echo>dir= ${dir} and package dir=${package.dir}</echo>
> <!-- ---------------------------------------------------- -->

Using ~ is a good idea  !
For unix you would need a
<propertyregex property="tmpdir" input="${dir}" regexp="/" replace="~" 
global="true" />
As well.


>
> On another note, the bsf lib is (or should be) on the classpath so 
> where does one look in case of a classNotFoundException for 
> bsh.util.BeanShellBSFEngine?

You need the beanshell jar as well for the beanshell language.
I use bsf-2.0b1.jar.


>
> There is something else i wonder about though.
> Is it correct that i cannot strip|replace the \ or / from the path 
> using a map (or any other way for that matter)? I've been trying using 
> the following code.
>
> <!-- scan the project directories and get the testsuite files to be 
> taken care off-->
> <path id="unittestsuites.path">
>  <fileset dir="${src.dir}" casesensitive="yes">
>   <include name="**/*TestSuite.java" />
>  </fileset>
> </path>
>        
> <!-- Create a list with the filenames without the path prefixes -->
> <pathconvert property="unittestsuites.files" 
> refid="unittestsuites.path" dirsep="/" pathsep=" ">
>  <map from="/" to="~" />
>  <map from="//" to="~" />
>  <map from="\\" to="~" />
>  <map from="c:" to="@" />
>  <map from="temp" to="@" />
> </pathconvert>


The dir sep character is used  after the maps are processed.

Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message