git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1203181 13f79535-47bb-0310-9956-ffa450edef68master
@@ -101,6 +101,9 @@ Fixed bugs: | |||||
specify the destDir attribute. | specify the destDir attribute. | ||||
Bugzilla Report 51947. | Bugzilla Report 51947. | ||||
* packagemapper now honors the handleDirSep attribute. | |||||
Bugzilla Report 51068. | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -83,6 +83,15 @@ public class GlobPatternMapper implements FileNameMapper { | |||||
this.handleDirSep = handleDirSep; | this.handleDirSep = handleDirSep; | ||||
} | } | ||||
/** | |||||
* Attribute specifying whether to ignore the difference | |||||
* between / and \ (the two common directory characters). | |||||
* @since Ant 1.8.3 | |||||
*/ | |||||
public boolean getHandleDirSep() { | |||||
return handleDirSep; | |||||
} | |||||
/** | /** | ||||
* Attribute specifying whether to ignore the case difference | * Attribute specifying whether to ignore the case difference | ||||
* in the names. | * in the names. | ||||
@@ -40,6 +40,9 @@ public class PackageNameMapper extends GlobPatternMapper { | |||||
protected String extractVariablePart(String name) { | protected String extractVariablePart(String name) { | ||||
String var = name.substring(prefixLength, | String var = name.substring(prefixLength, | ||||
name.length() - postfixLength); | name.length() - postfixLength); | ||||
if (getHandleDirSep()) { | |||||
var = name.replace('/', '.').replace('\\', '.'); | |||||
} | |||||
return var.replace(File.separatorChar, '.'); | return var.replace(File.separatorChar, '.'); | ||||
} | } | ||||
} | } | ||||
@@ -20,7 +20,7 @@ | |||||
name="glob-test" | name="glob-test" | ||||
default="antunit"> | default="antunit"> | ||||
<import file="../antunit-base.xml" /> | |||||
<import file="../../antunit-base.xml" /> | |||||
<target name="setUp"> | <target name="setUp"> | ||||
<mkdir dir="${input}"/> | <mkdir dir="${input}"/> |
@@ -0,0 +1,36 @@ | |||||
<?xml version="1.0"?> | |||||
<!-- | |||||
Licensed to the Apache Software Foundation (ASF) under one or more | |||||
contributor license agreements. See the NOTICE file distributed with | |||||
this work for additional information regarding copyright ownership. | |||||
The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
(the "License"); you may not use this file except in compliance with | |||||
the License. You may obtain a copy of the License at | |||||
http://www.apache.org/licenses/LICENSE-2.0 | |||||
Unless required by applicable law or agreed to in writing, software | |||||
distributed under the License is distributed on an "AS IS" BASIS, | |||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
See the License for the specific language governing permissions and | |||||
limitations under the License. | |||||
--> | |||||
<project xmlns:au="antlib:org.apache.ant.antunit" | |||||
default="antunit"> | |||||
<import file="../../antunit-base.xml" /> | |||||
<target name="testHandleDirSep" | |||||
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=51086"> | |||||
<pathconvert property="p1"> | |||||
<string>foo/bar</string> | |||||
<packagemapper from="*" to="*" handledirsep="true"/> | |||||
</pathconvert> | |||||
<au:assertPropertyEquals name="p1" value="foo.bar"/> | |||||
<pathconvert property="p2"> | |||||
<string>foo\bar</string> | |||||
<packagemapper from="*" to="*" handledirsep="true"/> | |||||
</pathconvert> | |||||
<au:assertPropertyEquals name="p1" value="foo.bar"/> | |||||
</target> | |||||
</project> |