Bug 54026 - Zip task on <mappedresources> that excludes certain files by way of the mapper results in a NullPointerException
Zip task on <mappedresources> that excludes certain files by way of the mappe...
Status: RESOLVED FIXED
Product: Ant
Classification: Unclassified
Component: Core tasks
1.8.2
All All
: P2 normal with 1 vote (vote)
: 1.9.0
Assigned To: Ant Notifications List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-10-18 22:15 UTC by Daniel Trebbien
Modified: 2013-01-06 23:38 UTC (History)
1 user (show)



Attachments
Patch (3.33 KB, patch)
2012-10-18 23:02 UTC, Daniel Trebbien
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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