Browse Source

PR 54026 Zip task on <mappedresources> that excludes certain files by way of the mapper results in a NullPointerException

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1429613 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 12 years ago
parent
commit
0282d8fe2e
5 changed files with 36 additions and 7 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +12
    -7
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  5. +15
    -0
      src/tests/antunit/taskdefs/zip-test.xml

+ 1
- 0
CONTRIBUTORS View File

@@ -74,6 +74,7 @@ Dan Armbrust
Daniel Henrique
Daniel Ribagnac
Daniel Spilker
Daniel Trebbien
Danno Ferrin
Danny Yates
Dante Briones


+ 4
- 0
WHATSNEW View File

@@ -62,6 +62,10 @@ Fixed bugs:
* ssh tasks prompt for kerberos username/password under Java 7
Bugzilla Report 53437.

* Zip task on <mappedresources> that excludes certain files by way of the mapper resulted in a NullPointerException
Bugzilla Report 54026


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



+ 4
- 0
contributors.xml View File

@@ -319,6 +319,10 @@
<first>Daniel</first>
<last>Spilker</last>
</name>
<name>
<first>Daniel</first>
<last>Trebbien</last>
</name>
<name>
<first>Danno</first>
<last>Ferrin</last>


+ 12
- 7
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -1068,22 +1068,27 @@ public class Zip extends MatchingTask {
return;
}
for (int i = 0; i < resources.length; i++) {
String name = resources[i].getName().replace(File.separatorChar,
'/');
final Resource resource = resources[i];
String name = resource.getName();
if (name == null) {
continue;
}
name = name.replace(File.separatorChar, '/');

if ("".equals(name)) {
continue;
}
if (resources[i].isDirectory() && doFilesonly) {
if (resource.isDirectory() && doFilesonly) {
continue;
}
File base = null;
FileProvider fp = resources[i].as(FileProvider.class);
FileProvider fp = resource.as(FileProvider.class);
if (fp != null) {
base = ResourceUtils.asFileResource(fp).getBaseDir();
}

if (resources[i].isDirectory()) {
addDirectoryResource(resources[i], name, "", base, zOut,
if (resource.isDirectory()) {
addDirectoryResource(resource, name, "", base, zOut,
ArchiveFileSet.DEFAULT_DIR_MODE,
ArchiveFileSet.DEFAULT_DIR_MODE);

@@ -1095,7 +1100,7 @@ public class Zip extends MatchingTask {
File f = (fp).getFile();
zipFile(f, zOut, name, ArchiveFileSet.DEFAULT_FILE_MODE);
} else {
addResource(resources[i], name, "", zOut,
addResource(resource, name, "", zOut,
ArchiveFileSet.DEFAULT_FILE_MODE,
null, null);
}


+ 15
- 0
src/tests/antunit/taskdefs/zip-test.xml View File

@@ -45,6 +45,21 @@
actual="${output}/out/bar.txt"/>
</target>

<target name="test-54026">
<mkdir dir="${input}"/>
<touch file="${input}/test1"/>
<mkdir dir="${input}/subdir"/>
<touch file="${input}/subdir/test2"/>
<zip destfile="${output}/br54026-destzip.zip">
<mappedresources>
<fileset dir="${input}"/>
<globmapper from="subdir/*" to="subdir.orig/*"/>
</mappedresources>
</zip>

<au:assertFileExists file="${output}/br54026-destzip.zip"/>
</target>

<target name="testMappedClasspath">
<mkdir dir="${input}"/>
<mkdir dir="${output}/out"/>


Loading…
Cancel
Save