http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1543

*** shadow/1543 Thu Apr 26 13:54:11 2001
--- shadow/1543.tmp.16389       Thu Apr 26 13:54:11 2001
***************
*** 0 ****
--- 1,66 ----
+ +============================================================================+
+ | tar builtin task doesn't handle tarfilesets correctly                      |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 1543                        Product: Ant                     |
+ |       Status: NEW                         Version: 1.3                     |
+ |   Resolution:                            Platform: PC                      |
+ |     Severity: Normal                   OS/Version:                         |
+ |     Priority:                           Component: Core tasks              |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: [EMAIL PROTECTED]                                   |
+ |  Reported By: [EMAIL PROTECTED]                                   |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ In the tar task you would normally expect to *either* use the "basedir" 
+ attribute (to tar an entire directory) or nested "tarfileset" elements to 
+ specify a more complicated set of files. However, it turns out that the code 
+ does the wrong thing for tarfilesets; rather than using the "dir" parameter 
+ from each tarfileset it is using the "basedir" value as the root directory 
when 
+ searching for files. 
+ 
+ For example, take a simple case like this:
+ 
+ <tar tarfile="outdir/myTar.tar" >
+       <tarfileset dir="sourcedir" mode="755" > 
+               <include name="aaa.csh"/>
+               <include name="bbb.csh"/>
+               <include name="ccc.csh"/>
+       </tarfileset>
+ </tar>
+ 
+ You would like the 3 files in the tarfileset to come from "sourcedir", but 
+ instead they come from the value of basedir (which is null) so they are 
+ searched for in the current directory.
+ 
+ Here's a workaround:
+ 
+ <tar tarfile="outdir/myTar.tar" basedir="sourcedir" excludes="**" >
+       <tarfileset dir="sourcedir" mode="755" > 
+               <include name="aaa.csh"/>
+               <include name="bbb.csh"/>
+               <include name="ccc.csh"/>
+       </tarfileset>
+ </tar>
+ 
+ Setting basedir makes the tarfileset work; setting excludes="**" makes sure 
+ that *only* files mentioned in the tarfileset are included. (Otherwise you 
+ would get *all* the files in sourcedir, plus a second copy of the three 
+ explicit files.)
+ 
+ I also believe I know where the bug is in the code and how to fix it. If you 
+ look in org/apache/tools/ant/taskdefs/Tar.java at around line 216 (in the 
+ execute() method) you will see a line of code that looks like this:
+ 
+    File f = new File(baseDir,files[i]);
+ 
+ Note that the directory is set from baseDir; I believe it should actually 
look 
+ like this:
+ 
+    File f = new File(fs.getDir(project),files[i]);
+ 
+ When I made this change I got the result I expected; I didn't need the 
basedir 
+ or exclude attributes and only my 3 files ended up in the tar. (It looks like 
+ this code is still the same in the current (4/25/2001) nightly builds.)

Reply via email to