Bugs item #1305673, was opened at 2005-09-27 18:11 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=402868&aid=1305673&group_id=31650
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core Group: None Status: Open Resolution: None Priority: 5 Submitted By: Henry (henryl) Assigned to: Nobody/Anonymous (nobody) Summary: Adding a regex filter Initial Comment: Attached is a build file to enable a regular expression filter to be used as part of a filter chain. It gives far more powerful filtering of data than (for example) replacetokens. Enable it by including it in your nant config file... <include buildfile="regex.build" /> Here is an example bit of a task to copy (and filter) a version.h header file to include build information: <copy file="${source_filename}" tofile="${version_header_filename}"> <filterchain> <regex pattern="(MAJOR_FILE_VER)(.*)" replacement="$1 ${version::get-major(build::get-version())}" /> <regex pattern="(MINOR_FILE_VER)(.*)" replacement="$1 ${version::get-minor(build::get-version()) / 10}" /> <regex pattern="(PRIVATE_FILE_VER)(.*)" replacement="$1 ${version::get-minor(build::get-version()) % 10}" /> <regex pattern="(BUILD_FILE_VER)(.*)" replacement="$1 ${version::get-build(build::get-version())}" /> <regex pattern="(PRODUCT_COMMENTS)(.*)" replacement='$1 "Release of ${ReleaseName} built on ${environment::get-machine-name()} by ${environment::get-user-name()}\r\nBuild started on ${datetime::now()}"' /> <!-- Strip out comments. Note that we want to strip out the entire line, so we include the new line characters. --> <regex pattern="[\r\n]+//.*" replacement="" /> <!-- Add a note before the initial header guard that this is the generated copy. Note the new line characters. --> <regex pattern="(.*ifndef.*)" replacement="// This is an automatically generated copy of the file at ${source_filename}
$1" /> </filterchain> </copy> Note that this is using a custom build::get-version() function, but you get the idea. The code can be trivially extraced from the build file and put directly in the nant source (I put it in a script so I wouldn't have to update everybody's copy of nant). Hope someone will find it useful (possibly for inclusion as a default filter in nant). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=402868&aid=1305673&group_id=31650 ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ nant-developers mailing list nant-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nant-developers