ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <sflo...@nc.rr.com>
Subject Re: [ant] Determining relative paths resp. substring?
Date Fri, 16 Jan 2009 23:32:41 GMT

Oh I completely understand :)  No worries :)

I tend to go overboard with Ant.  To be honest, I use it as more than a 
build environment...I use it as a cross platform scripting language :)

Anyway, you can probably do the same thing with beanshell or another 
scripting language directly from within your Ant script.  The simplest 
thing I found was to use regular expressions (which is what my example 
does).  I used a macrodef as a kind of reusable function I can call...

I am unaware of a substring task at all.  Ant Contrib (a third party Ant 
library) has some fairly useful features...I really use the heck out of 
it...

Again, if you want substring or the like you can, perhaps, write your own 
Ant task in Java...or as I mentioned do so using a scripting language...

I find Beanshell really useful and do some stuff with it on occasion...

On Fri, 16 Jan 2009, Georg-Johann Lay wrote:

> Scot P. Floess schrieb:
>
>> I am enclosing my macrodef to compute a branch:
>>
>>     <macrodef
>>         name        = "compute-branch"
>>         description = "Compute the branch based upon a root dir, @{root}, 
>> and full path, @{full-path}.  The branch represents the full path minus the 
>> root dir.  Please note:  if @{root} does not exist in @{full-path}, 
>> @{property} will be set with an empty value."
>>         uri         = "http://keros.sourceforge.net">
>>
>>         <attribute  name = "root"         description = "The root of the 
>> path defined in @{full-path}."/>
>>         <attribute  name = "full-path"    description = "The absolute path 
>> for which @{root} is the root of the path and the branch computed is this 
>> path minus the root."/>
>>         <attribute  name = "property"     description = "The property to 
>> set with the branch."/>
>>         <attribute  name = "description"  default = ""  description = 
>> "Information about this macro call."/>
>>
>>         <sequential>
>>             <!--
>>
>>                 Grab data past @{root} in @{full-path}.
>>
>>             -->
>>             <ant-contrib:propertyregex  property = 
>> "keros.compute-branch.COMPUTE_BRANCH"  override = "true"  input = 
>> "@{full-path}"  regexp = "@{root}(.*)"  select = "\1"  description = "Parse 
>> out the branch from the value contained in @{root}"/>
>>
>>             <!--
>>
>>                 Remove the leading file separator (if it is there).  If it 
>> is not there,
>>                 simply use the value as is.
>>
>>             -->
>>             <ant-contrib:propertyregex  property = "@{property}"  override 
>> = "true"  input = "${keros.compute-branch.COMPUTE_BRANCH}"  regexp = 
>> "^[${file.separator}](.*)"  replace = "\1" defaultValue = 
>> "${keros.compute-branch.COMPUTE_BRANCH}"  description = "Remove the leading 
>> file separator if its there"/>
>>         </sequential>
>>     </macrodef>
>
> Hi, thanks for your answer.
>
> Uhhh, I am an absolute ant newbie.
>
> I do not believe it. All this is needed just to remove a prefix prom a 
> string?!
>
>> Let me know if you have any questions...
>
> Ant proper really is not capable to perform things that look in C like
>
>>> char * prefix;
>>> char * path;
>>> char * suffix = path + strlen (prefix);
>
> or like
>
>>> String prefix;
>>> String path;
>>> String suffix = path.substring (prefix.length());
>
> in Java?
>
> I am trying to *simplify* Makefiles by using ant. And not to make things even 
> more complex and harder to understand and to maintain.
> If ant cannot do it, it is not what I am looking for...
>
> All I could find is a strlen:
>
>>> <length property="prefix.length" string="${prefix}" />
>
> So what is missing is something like substring or an analogon to basename 
> that can remove a prefix instead of a suffix.
>
>> I am using Ant Contrib's propertyregex task to do this...  Adjust URI's, 
>> etc for your needs :)
>
> The URI in your macrodef?
> To that value must it be set? To kerberos zip?
> Or to one of the jars in it?
>
> Please be kind, I am just trying ant to look if it can make things simpler.
>
> Regards, Georg-Johann
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros

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


Mime
View raw message