ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Skeet" <Jon.Sk...@clearswift.com>
Subject RE: Changing the "leading directory" path on a directory tree
Date Thu, 16 Mar 2006 08:14:09 GMT
> I am not sure if I can explain this correctly, so I will show 
> you the target text and then explain the problem

<snip>

> The problem I am having is in the <propertyregex> task (the 
> first task afterthe <sequential>), what I want to do is 
> convert filepaths that are provided in the @{file} attribute from
>   C:\dir_viewer\Since_Last_changes\abc\yada yada\yada\Bob.doc
>     to
>   ${output.root.dir}\abc\yada yada\yada\Bob.pdf

If you don't mind using Groovy, this becomes pretty simple.
(Just dealing with the filename bit at the moment - using Groovy's
File.eachLine along with AntBuilder would make doing the whole chunk in
Groovy pretty simple. Groovy+Ant is a *really* powerful combination...)

<groovy>
String changesPath = project.resolveFile
(properties["changes.dir"]).getAbsolutePath()
String outputPath = project.resolveFile
(properties["output.root.dir"]).getAbsolutePath()
String sourcePath = project.resolveFile
(properties["whatever-file-property"])

if (!sourcePath.startsWith(changesPath))
{
    ant.fail (message: "${sourcePath} not within ${changesPath}"))
}

String finalPath = outputPath+"/"+sourcePath.substring
(changesPath.length())
</groovy>

Jon


Clearswift monitors, controls and protects all its messaging traffic in compliance with its
corporate email policy using Clearswift products.
Find out more about Clearswift, its solutions and services at http://www.clearswift.com

This communication is confidential and may contain privileged information intended solely
for the named addressee(s). It may not be used or disclosed except for the purpose for which
it has been sent. If you are not the intended recipient, you must not copy, distribute or
take any action in reliance on it. Unless expressly stated, opinions in this message are those
of the individual sender and not of Clearswift. If you have received this communication in
error, please notify Clearswift by emailing support@clearswift.com quoting the sender and
delete the message and any attached documents. Clearswift accepts no liability or responsibility
for any onward transmission or use of emails and attachments having left the Clearswift domain.

This footnote confirms that this email message has been swept by MIMEsweeper for Content Security
threats, including computer viruses.

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


Mime
View raw message