Yes it is my designated patch day! Bear with me...
I noticed that when using the new <zip><fileset
src="..../foo.zip"/></zip> (cool by the way!), the src attribute to the
<fileset> is passed as a String and is thus not resolved against the
project basedir. Instead it might be resolved against the VM's working
directory, wherever that may be. So I changed a couple classes to use
File instead of String and it seems to work better (the project resolves
it when setting the attribute, like you would expect).
(A suggestion: have the Ant startup script set the CWD to something
deliberately ridiculous, like /tmp, so that we find these problems
earlier rather than later and fix them...ideally no part of Ant's
behavior would be affected by the CWD. E.g. when running inside NetBeans
the CWD is something quite arbitrary, no relation to your Ant project at
all.)
-Jesse
--
Jesse Glick <mailto:[EMAIL PROTECTED]>
NetBeans, Open APIs <http://www.netbeans.org/>
tel (+4202) 3300-9161 Sun Micro x49161 Praha CR
Index: src/main/org/apache/tools/ant/taskdefs/Zip.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
retrieving revision 1.27
diff -u -r1.27 Zip.java
--- src/main/org/apache/tools/ant/taskdefs/Zip.java 2001/01/16 13:16:46
1.27
+++ src/main/org/apache/tools/ant/taskdefs/Zip.java 2001/01/25 09:55:26
@@ -267,10 +267,10 @@
throws IOException
{
ZipScanner zipScanner = (ZipScanner) ds;
- String zipSrc = fs.getSrc();
+ File zipSrc = fs.getSrc();
ZipEntry entry;
- ZipInputStream in = new ZipInputStream(new FileInputStream(new
File(zipSrc)));
+ ZipInputStream in = new ZipInputStream(new FileInputStream(zipSrc));
while ((entry = in.getNextEntry()) != null) {
String vPath = entry.getName();
if (zipScanner.match(vPath)) {
Index: src/main/org/apache/tools/ant/types/ZipFileSet.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/types/ZipFileSet.java,v
retrieving revision 1.1
diff -u -r1.1 ZipFileSet.java
--- src/main/org/apache/tools/ant/types/ZipFileSet.java 2001/01/16 13:21:57
1.1
+++ src/main/org/apache/tools/ant/types/ZipFileSet.java 2001/01/25 09:55:26
@@ -79,7 +79,7 @@
*/
public class ZipFileSet extends FileSet {
- private String srcFileName = null;
+ private File srcFile = null;
private String prefix = "";
private String fullpath = "";
private boolean hasDir = false;
@@ -89,7 +89,7 @@
* from being specified.
*/
public void setDir(File dir) throws BuildException {
- if (srcFileName != null) {
+ if (srcFile != null) {
throw new BuildException("Cannot set both dir and src attributes");
} else {
super.setDir(dir);
@@ -101,13 +101,13 @@
* Set the source Zip file for the zipfileset. Prevents both "dir" and
"src"
* from being specified.
*
- * @param srcFileName The zip file from which to extract entries.
+ * @param srcFile The zip file from which to extract entries.
*/
- public void setSrc(String srcFileName) {
+ public void setSrc(File srcFile) {
if (hasDir) {
throw new BuildException("Cannot set both dir and src attributes");
}
- this.srcFileName = srcFileName;
+ this.srcFile = srcFile;
}
/**
@@ -115,8 +115,8 @@
* References are not followed, since it is not possible
* to have a reference to a ZipFileSet, only to a FileSet.
*/
- public String getSrc() {
- return srcFileName;
+ public File getSrc() {
+ return srcFile;
}
/**
@@ -162,9 +162,9 @@
if (isReference()) {
return getRef(p).getDirectoryScanner(p);
}
- if (srcFileName != null) {
+ if (srcFile != null) {
ZipScanner zs = new ZipScanner();
- zs.setSrc(srcFileName);
+ zs.setSrc(srcFile);
if (getDir(p) == null) {
super.setDir(new File("."));
}
Index: src/main/org/apache/tools/ant/types/ZipScanner.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/types/ZipScanner.java,v
retrieving revision 1.1
diff -u -r1.1 ZipScanner.java
--- src/main/org/apache/tools/ant/types/ZipScanner.java 2001/01/16 13:21:57
1.1
+++ src/main/org/apache/tools/ant/types/ZipScanner.java 2001/01/25 09:55:26
@@ -74,15 +74,15 @@
/**
* The zip file which should be scanned.
*/
- protected String srcFile;
+ protected File srcFile;
/**
* Sets the srcFile for scanning. This is the jar or zip file that is
scanned
* for matching entries.
*
- * @param srcFile the (non-null) zip file name for scanning
+ * @param srcFile the (non-null) zip file for scanning
*/
- public void setSrc(String srcFile) {
+ public void setSrc(File srcFile) {
this.srcFile = srcFile;
}
@@ -95,7 +95,7 @@
*/
public String[] getIncludedFiles() {
String[] result = new String[1];
- result[0] = srcFile;
+ result[0] = srcFile.getAbsolutePath();
return result;
}