You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2009/01/09 23:37:11 UTC
DO NOT REPLY [Bug 46506] New: Unexpected results from globmapper
https://issues.apache.org/bugzilla/show_bug.cgi?id=46506
Summary: Unexpected results from globmapper
Product: Ant
Version: 1.7.1
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Core
AssignedTo: notifications@ant.apache.org
ReportedBy: fyang@praxalogic.org
In a build process, I want to move a file named in the pattern of a-[x.x].jar
to a.jar, where [x.x] is a version number of the library. I used the following
globmapper as a nested element in the move task.
<mapper type="glob" from="a*.jar" to="a.jar"/>
I would expect the result as a.jar. Instead, it turns out to be a.jar-[x.x].
I looked into the source code and found that the code always expect the
variable part also exists in the "to" file name. Not sure if it is by design
spec or just a missing case.
The fix should be easy by introducing a flag: hasVarInTo initialized to true.
Then modify the two methods as following.
public void setTo(String to) {
int index = to.lastIndexOf("*");
if (index == -1) {
toPrefix = to;
toPostfix = "";
hasVarInTo = false; // THIS IS ADDED FOR THE FIX
} else {
toPrefix = to.substring(0, index);
toPostfix = to.substring(index + 1);
}
}
public String[] mapFileName(String sourceFileName) {
if (fromPrefix == null
|| !modifyName(sourceFileName).startsWith(modifyName(fromPrefix))
|| !modifyName(sourceFileName).endsWith(modifyName(fromPostfix))) {
return null;
}
return new String[] {toPrefix
+ (hasVarInTo?
extractVariablePart(sourceFileName)
+ toPostfix : "")}; // THIS IS MODIFIED TO
// FIX THE ISSUE
}
For the "from" part, we can always assume there will be a variable since it is
what globmapper is used for.
If it is by design spec, it should be noted in the document at the minimum.
Thanks,
Feng
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 46506] Unexpected results from globmapper
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46506
--- Comment #1 from Stefan Bodewig <bo...@apache.org> 2009-01-12 03:48:42 PST ---
before looking further into globmapper and how to prevent this surprise: if you
don't use a * in globmapper's "to", you really want to use a mergemapper.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 46506] Unexpected results from globmapper
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46506
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #5 from Stefan Bodewig <bo...@apache.org> 2009-01-30 04:16:47 PST ---
marked the change as backwards incompatible change and live with.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
DO NOT REPLY [Bug 46506] Unexpected results from globmapper
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46506
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |notifications@ant.apache.org
AssignedTo|notifications@ant.apache.org|bodewig@apache.org
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
You are the assignee for the bug.
DO NOT REPLY [Bug 46506] Unexpected results from globmapper
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46506
--- Comment #3 from Feng Yang <fy...@praxalogic.org> 2009-01-12 08:12:34 PST ---
Hi Stefan,
Thanks a lot for referring me to the mergemapper in this case. It really works
in my case. Somehow, I missed the variety of the usage of mergemapper.
As far as the fix goes, I do not see the backwards incompatibility. Can you
please notify me with the URL to the discussion thread once you have set it up?
I would like to join in the discussion.
Thanks,
Feng
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
DO NOT REPLY [Bug 46506] Unexpected results from globmapper
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46506
--- Comment #4 from Stefan Bodewig <bo...@apache.org> 2009-01-12 08:19:21 PST ---
It's on the Ant developer mailing list, see
http://marc.info/?l=ant-dev&m=123176768705110&w=2
The issue is that there may be code out there that relies on the old behavior
where the * was appended to the to pattern implicitly. I wouldn't expect this
to be common, but already found one such case in Ant's very own unit tests.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
DO NOT REPLY [Bug 46506] Unexpected results from globmapper
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46506
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |1.8.0
--- Comment #2 from Stefan Bodewig <bo...@apache.org> 2009-01-12 05:19:32 PST ---
fixed via svn revision 733729 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=733729 )
the change means we are breaking backwards compatibility and I'll start a
thread
to discuss the issue before closing this report.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.