Bug 54026

Summary: Zip task on <mappedresources> that excludes certain files by way of the mapper results in a NullPointerException
Product: Ant Reporter: Daniel Trebbien <dtrebbien>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: normal CC: dtrebbien
Priority: P2    
Version: 1.8.2   
Target Milestone: 1.9.0   
Hardware: All   
OS: All   
Attachments: Patch

Description Daniel Trebbien 2012-10-18 22:15:04 UTC
Steps to reproduce:

1. Create a folder named `test' with the following:

   test/
   test/test1
   test/subdir/
   test/subdir/test2

   (`test1' and `test2' are regular files.)

2. Create a `build.xml' with the following:

<project name="testcase" default="go" basedir=".">
    <target name="go">
        <zip destfile="destzip.zip">
            <mappedresources>
                <fileset dir="test"/>
                <globmapper from="subdir/*" to="subdir.orig/*"/>
            </mappedresources>
        </zip>
    </target>
</project>

3. Run `ant'.



Actual result:
NullPointerException thrown in org.apache.tools.ant.taskdefs.Zip.addResources.



Expected result:
`ant' finishes without error and there is a new ZIP file called `destzip.zip' in the current directory. `zip -sf destzip.zip' should print:

Archive contains:
  subdir.orig/
  subdir.orig/test2
Total 2 entries



Tested in:
Ant 1.8.2 and 1.8.4 on Mac OS 10.7.5.



Known work-around:
Add an `excludes' attribute to the <fileset> to exclude all files not matched by the "from" glob. For the given example, `excludes="test1"'.
Comment 1 Daniel Trebbien 2012-10-18 23:02:07 UTC
Created attachment 29496 [details]
Patch
Comment 2 Antoine Levy-Lambert 2013-01-06 23:38:50 UTC
Patch submitted, thanks