bodewig 01/01/30 02:56:10
Modified: src/main/org/apache/tools/ant/taskdefs Zip.java
src/main/org/apache/tools/ant/types FileSet.java
ZipFileSet.java ZipScanner.java
Log:
Make ZipFileSet resolve srcfile relative to project's basedir.
Submitted by: Jesse Glick <[EMAIL PROTECTED]>
Revision Changes Path
1.28 +2 -2
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
Index: Zip.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- Zip.java 2001/01/16 13:16:46 1.27
+++ Zip.java 2001/01/30 10:56:05 1.28
@@ -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)) {
1.12 +1 -1
jakarta-ant/src/main/org/apache/tools/ant/types/FileSet.java
Index: FileSet.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/FileSet.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- FileSet.java 2001/01/03 14:18:46 1.11
+++ FileSet.java 2001/01/30 10:56:07 1.12
@@ -260,7 +260,7 @@
* Performs the check for circular references and returns the
* referenced FileSet.
*/
- private FileSet getRef(Project p) {
+ protected FileSet getRef(Project p) {
if (!checked) {
Stack stk = new Stack();
stk.push(this);
1.2 +12 -34
jakarta-ant/src/main/org/apache/tools/ant/types/ZipFileSet.java
Index: ZipFileSet.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/ZipFileSet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ZipFileSet.java 2001/01/16 13:21:57 1.1
+++ ZipFileSet.java 2001/01/30 10:56:08 1.2
@@ -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);
@@ -98,16 +98,16 @@
}
/**
- * Set the source Zip file for the zipfileset. Prevents both "dir" and
"src"
- * from being specified.
+ * 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,12 +162,10 @@
if (isReference()) {
return getRef(p).getDirectoryScanner(p);
}
- if (srcFileName != null) {
+ if (srcFile != null) {
ZipScanner zs = new ZipScanner();
- zs.setSrc(srcFileName);
- if (getDir(p) == null) {
- super.setDir(new File("."));
- }
+ zs.setSrc(srcFile);
+ super.setDir(new File("."));
setupDirectoryScanner(zs, p);
zs.init();
return zs;
@@ -176,24 +174,4 @@
}
}
- /**
- * Performs the check for circular references and returns the
- * referenced FileSet.
- */
- private FileSet getRef(Project p) {
- if (!checked) {
- Stack stk = new Stack();
- stk.push(this);
- dieOnCircularReference(stk, p);
- }
-
- Object o = ref.getReferencedObject(p);
- if (!(o instanceof FileSet)) {
- String msg = ref.getRefId()+" doesn\'t denote a fileset";
- throw new BuildException(msg);
- } else {
- return (FileSet) o;
- }
- }
-
}
1.2 +3 -3
jakarta-ant/src/main/org/apache/tools/ant/types/ZipScanner.java
Index: ZipScanner.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/ZipScanner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ZipScanner.java 2001/01/16 13:21:57 1.1
+++ ZipScanner.java 2001/01/30 10:56:08 1.2
@@ -74,7 +74,7 @@
/**
* 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
@@ -82,7 +82,7 @@
*
* @param srcFile the (non-null) zip file name 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;
}