https://issues.apache.org/bugzilla/show_bug.cgi?id=47984
Summary: Ant's regexp mapper expects that the regex matches the
whole input string, and munges file names if it
doesn't match
Product: Ant
Version: 1.7.1
Platform: PC
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: Core tasks
AssignedTo: [email protected]
ReportedBy: [email protected]
This is using the default regex engine. Example build file demonstrating the
problem:
----
bu...@build ~ $ cat build.xml
<project name="testme" default="doit" basedir=".">
<target name="check">
<uptodate property="noneed">
<srcfiles dir="." includes="t.xml"/>
<mapper type="regexp" from="xml$" to="txt"/>
</uptodate>
</target>
<target name="doit" depends="check" unless="noneed">
<copy file="t.xml" tofile="t.txt" overwrite="true"/>
</target>
</project>
----
Say that t.txt doesn't exist. On the first run, it is created. So far, so good.
But on the second run, the copy is _also_ executed, and that is totally
unexpected. This has been verified with ant 1.6.5 and ant 1.7.1. If I
run ant -v, here's what I see in the output:
---
check:
[uptodate] t.xml added as txt doesn't exist.
----
Two bugs here:
* the regex /xml$/ didn't match t.xml, it should have matched;
* the resulting file name is garbled: at the very least, the mapper should have
left it untouched.
A simple sed command returns the expected result:
----
f...@erwin ~ $ echo t.xml | sed 's,xml$,txt,'
t.txt
----
This is especially frustrating since the documentation says:
----
If the source file name matches the from pattern, the target file name will be
constructed from the to pattern
----
And /xml$/ DOES match t.xml. Nothing has ever said that regexes had to match
their whole input!
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.