Browse Source

make packagemapper take handledirsep into account. Submitted by Anthony Wat. PR 51086

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1203181 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 13 years ago
parent
commit
e995f38a73
5 changed files with 52 additions and 1 deletions
  1. +3
    -0
      WHATSNEW
  2. +9
    -0
      src/main/org/apache/tools/ant/util/GlobPatternMapper.java
  3. +3
    -0
      src/main/org/apache/tools/ant/util/PackageNameMapper.java
  4. +1
    -1
      src/tests/antunit/types/mappers/glob-test.xml
  5. +36
    -0
      src/tests/antunit/types/mappers/packagemapper-test.xml

+ 3
- 0
WHATSNEW View File

@@ -101,6 +101,9 @@ Fixed bugs:
specify the destDir attribute.
Bugzilla Report 51947.

* packagemapper now honors the handleDirSep attribute.
Bugzilla Report 51068.

Other changes:
--------------



+ 9
- 0
src/main/org/apache/tools/ant/util/GlobPatternMapper.java View File

@@ -83,6 +83,15 @@ public class GlobPatternMapper implements FileNameMapper {
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
* in the names.


+ 3
- 0
src/main/org/apache/tools/ant/util/PackageNameMapper.java View File

@@ -40,6 +40,9 @@ public class PackageNameMapper extends GlobPatternMapper {
protected String extractVariablePart(String name) {
String var = name.substring(prefixLength,
name.length() - postfixLength);
if (getHandleDirSep()) {
var = name.replace('/', '.').replace('\\', '.');
}
return var.replace(File.separatorChar, '.');
}
}


src/tests/antunit/types/glob-test.xml → src/tests/antunit/types/mappers/glob-test.xml View File

@@ -20,7 +20,7 @@
name="glob-test"
default="antunit">

<import file="../antunit-base.xml" />
<import file="../../antunit-base.xml" />

<target name="setUp">
<mkdir dir="${input}"/>

+ 36
- 0
src/tests/antunit/types/mappers/packagemapper-test.xml View File

@@ -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>

Loading…
Cancel
Save