git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@818389 13f79535-47bb-0310-9956-ffa450edef68master
@@ -134,10 +134,11 @@ Changes that could break older environments: | |||||
versions of Ant. | versions of Ant. | ||||
Bugzilla Report 36748. | Bugzilla Report 36748. | ||||
* globmapper didn't work properly if the "to" pattern didn't contain | |||||
a "*". In particular it implicitly added a * to the end of the | |||||
pattern. This is no longer the case. If you relied on this | |||||
behavior you will now need to explicitly specify the trailing *. | |||||
* globmapper didn't work properly if the "to" or "from" patterns | |||||
didn't contain a "*". In particular it implicitly added a * to the | |||||
end of the pattern(s). This is no longer the case. If you relied | |||||
on this behavior you will now need to explicitly specify the | |||||
trailing "*". | |||||
Bugzilla Report 46506. | Bugzilla Report 46506. | ||||
* <copy> silently ignored missing resources even with | * <copy> silently ignored missing resources even with | ||||
@@ -31,7 +31,7 @@ | |||||
<target name="testmapper"> | <target name="testmapper"> | ||||
<pathconvert property="result" dirsep="#"> | <pathconvert property="result" dirsep="#"> | ||||
<path refid="testpath" /> | <path refid="testpath" /> | ||||
<mapper type="glob" from="${basedir}" to="test*" /> | |||||
<mapper type="glob" from="${basedir}*" to="test*" /> | |||||
</pathconvert> | </pathconvert> | ||||
</target> | </target> | ||||
@@ -68,6 +68,7 @@ public class GlobPatternMapper implements FileNameMapper { | |||||
// CheckStyle:VisibilityModifier ON | // CheckStyle:VisibilityModifier ON | ||||
private boolean fromContainsStar = false; | |||||
private boolean toContainsStar = false; | private boolean toContainsStar = false; | ||||
private boolean handleDirSep = false; | private boolean handleDirSep = false; | ||||
private boolean caseSensitive = true; | private boolean caseSensitive = true; | ||||
@@ -106,6 +107,7 @@ public class GlobPatternMapper implements FileNameMapper { | |||||
} else { | } else { | ||||
fromPrefix = from.substring(0, index); | fromPrefix = from.substring(0, index); | ||||
fromPostfix = from.substring(index + 1); | fromPostfix = from.substring(index + 1); | ||||
fromContainsStar = true; | |||||
} | } | ||||
prefixLength = fromPrefix.length(); | prefixLength = fromPrefix.length(); | ||||
postfixLength = fromPostfix.length(); | postfixLength = fromPostfix.length(); | ||||
@@ -142,10 +144,16 @@ public class GlobPatternMapper implements FileNameMapper { | |||||
* @return a list of converted filenames | * @return a list of converted filenames | ||||
*/ | */ | ||||
public String[] mapFileName(String sourceFileName) { | public String[] mapFileName(String sourceFileName) { | ||||
String modName = modifyName(sourceFileName); | |||||
if (fromPrefix == null | if (fromPrefix == null | ||||
|| !modifyName(sourceFileName).startsWith(modifyName(fromPrefix)) | |||||
|| !modifyName(sourceFileName).endsWith(modifyName(fromPostfix)) | |||||
|| (sourceFileName.length() < (prefixLength + postfixLength)) | || (sourceFileName.length() < (prefixLength + postfixLength)) | ||||
|| (!fromContainsStar | |||||
&& !modName.equals(modifyName(fromPrefix)) | |||||
) | |||||
|| (fromContainsStar | |||||
&& (!modName.startsWith(modifyName(fromPrefix)) | |||||
|| !modName.endsWith(modifyName(fromPostfix))) | |||||
) | |||||
) { | ) { | ||||
return null; | return null; | ||||
} | } | ||||
@@ -68,4 +68,13 @@ | |||||
<au:assertFileExists file="${output}/c.jar-b"/> | <au:assertFileExists file="${output}/c.jar-b"/> | ||||
</target> | </target> | ||||
<target name="test-no-*-in-from" depends="setUp"> | |||||
<touch file="${input}/a-b.jar"/> | |||||
<copy todir="${output}"> | |||||
<fileset dir="${input}"/> | |||||
<mapper type="glob" from="a-b" to="c.jar"/> | |||||
</copy> | |||||
<au:assertFileDoesntExist file="${output}/c.jar"/> | |||||
</target> | |||||
</project> | </project> |