cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java
jkf 2005/07/21 13:25:25 Modified:.WHATSNEW src/main/org/apache/tools/ant/types ZipFileSet.java Log: PR:35824 Adding removed public methods Revision ChangesPath 1.846 +2 -0 ant/WHATSNEW Index: WHATSNEW === RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.845 retrieving revision 1.846 diff -u -r1.845 -r1.846 --- WHATSNEW 8 Jul 2005 14:27:03 - 1.845 +++ WHATSNEW 21 Jul 2005 20:25:25 - 1.846 @@ -59,6 +59,8 @@ Fixed bugs: --- +* Backward incompatible change in ZipFileSet, Bugzilla Report 35824. + * Wrong replacement of file separator chars prevens junitbatchtest from running correctly on files from a zipfileset. Bugzilla Report 35499 1.31 +48 -2 ant/src/main/org/apache/tools/ant/types/ZipFileSet.java Index: ZipFileSet.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/ZipFileSet.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- ZipFileSet.java 12 Jun 2005 15:54:15 - 1.30 +++ ZipFileSet.java 21 Jul 2005 20:25:25 - 1.31 @@ -130,6 +130,7 @@ * to have a reference to a ZipFileSet, only to a FileSet. * @param p the project to use * @return the source file + * @since Ant 1.6 */ public File getSrc(Project p) { if (isReference()) { @@ -139,6 +140,16 @@ } /** + * Get the zip file from which entries will be extracted. + * References are not followed, since it is not possible + * to have a reference to a ZipFileSet, only to a FileSet. + * @deprecated + */ +public File getSrc() { +return srcFile; +} + +/** * Prepend this prefix to the path for each zip entry. * Prevents both prefix and fullpath from being specified * @@ -155,6 +166,7 @@ * Return the prefix prepended to entries in the zip file. * @param p the project to use * @return the prefix + * @since Ant 1.6 */ public String getPrefix(Project p) { if (isReference()) { @@ -164,6 +176,14 @@ } /** + * Return the prefix prepended to entries in the zip file. + * @deprecated + */ +public String getPrefix() { +return prefix; +} + +/** * Set the full pathname of the single entry in this fileset. * Prevents both prefix and fullpath from being specified * @@ -180,6 +200,7 @@ * Return the full pathname of the single entry in this fileset. * @param p the project to use * @return the full path + * @since Ant 1.6 */ public String getFullpath(Project p) { if (isReference()) { @@ -187,6 +208,14 @@ } return fullpath; } + +/** + * Return the full pathname of the single entry in this fileset. + * @deprecated + */ +public String getFullpath() { +return fullpath; +} /** * Set the encoding used for this ZipFileSet. @@ -290,7 +319,7 @@ * Get the mode of the zip fileset * @param p the project to use * @return the mode - * @since Ant 1.5.2 + * @since Ant 1.6 */ public int getFileMode(Project p) { if (isReference()) { @@ -298,6 +327,15 @@ } return fileMode; } + +/** + * @since Ant 1.5.2 + * @deprecated + */ +public int getFileMode() { +return fileMode; +} + /** * Whether the user has specified the mode explicitly. @@ -329,7 +367,7 @@ * Get the dir mode of the zip fileset * @param p the project to use * @return the mode - * @since Ant 1.5.2 + * @since Ant 1.6 */ public int getDirMode(Project p) { if (isReference()) { @@ -337,6 +375,14 @@ } return dirMode; } + +/** + * @since Ant 1.5.2 + * @deprecated + */ +public int getDirMode() { +return dirMode; +} /** * Whether the user has specified the mode explicitly. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java
bodewig 2003/10/10 03:39:42 Modified:src/main/org/apache/tools/ant/types Tag: ANT_16_BRANCH ZipFileSet.java Log: Merge from HEAD Revision ChangesPath No revision No revision 1.22.2.1 +10 -15ant/src/main/org/apache/tools/ant/types/ZipFileSet.java Index: ZipFileSet.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/ZipFileSet.java,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -u -r1.22 -r1.22.2.1 --- ZipFileSet.java 15 Jul 2003 14:54:14 - 1.22 +++ ZipFileSet.java 10 Oct 2003 10:39:42 - 1.22.2.1 @@ -172,10 +172,7 @@ * @param prefix The prefix to prepend to entries in the zip file. */ public void setPrefix(String prefix) { -if (isReference()) { - throw tooManyAttributes(); - } -if (!fullpath.equals()) { +if (!prefix.equals() !fullpath.equals()) { throw new BuildException(Cannot set both fullpath and prefix attributes); } this.prefix = prefix; @@ -198,10 +195,7 @@ * @param fullpath the full pathname of the single entry in this fileset. */ public void setFullpath(String fullpath) { -if (isReference()) { - throw tooManyAttributes(); - } -if (!prefix.equals()) { +if (!prefix.equals() !fullpath.equals()) { throw new BuildException(Cannot set both fullpath and prefix attributes); } this.fullpath = fullpath; @@ -246,9 +240,6 @@ * @since Ant 1.5.2 */ public void setFileMode(String octalString) { -if (isReference()) { - throw tooManyAttributes(); -} fileModeHasBeenSet = true; this.fileMode = UnixStat.FILE_FLAG | Integer.parseInt(octalString, 8); @@ -284,9 +275,6 @@ * @since Ant 1.5.2 */ public void setDirMode(String octalString) { -if (isReference()) { - throw tooManyAttributes(); -} dirModeHasBeenSet = true; this.dirMode = UnixStat.DIR_FLAG | Integer.parseInt(octalString, 8); @@ -328,7 +316,14 @@ if (o instanceof ZipFileSet) { return (AbstractFileSet) o; } else if (o instanceof FileSet) { - return (new ZipFileSet((FileSet) o)); +ZipFileSet zfs = new ZipFileSet((FileSet) o); +zfs.setPrefix(prefix); +zfs.setFullpath(fullpath); +zfs.fileModeHasBeenSet = fileModeHasBeenSet; +zfs.fileMode = fileMode; +zfs.dirModeHasBeenSet = dirModeHasBeenSet; +zfs.dirMode = dirMode; +return zfs; } else { String msg = getRefid().getRefId() + doesn\'t denote a zipfileset or a fileset; throw new BuildException(msg); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java
On 10 Oct 2003, [EMAIL PROTECTED] wrote: Fix PR 23639 This change fixes a regression (it worked in 1.4) where fileset id=foo .../ war ... lib refid=foo/ /war would not place the contents of the fileset into WEB-INF/lib but into the root of the archive. I've also change the filemode and dirmode attribute setters as well as the one of fullpath so that ZipFileSet can now be used as a decorator for plain filesets. The decorator would add a prefix or fullpath and adds Unix-like permissions. So now fileset id=foo .../ zip ... zipfileset refid=foo filemode=755/ /zip will also work. Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java
:-) Well done, Stefan. Cheers, Antoine -Ursprungliche Nachricht- Von: Stefan Bodewig [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 10. Oktober 2003 12:45 An: [EMAIL PROTECTED] Betreff: Re: cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java On 10 Oct 2003, [EMAIL PROTECTED] wrote: Fix PR 23639 This change fixes a regression (it worked in 1.4) where fileset id=foo .../ war ... lib refid=foo/ /war would not place the contents of the fileset into WEB-INF/lib but into the root of the archive. I've also change the filemode and dirmode attribute setters as well as the one of fullpath so that ZipFileSet can now be used as a decorator for plain filesets. The decorator would add a prefix or fullpath and adds Unix-like permissions. So now fileset id=foo .../ zip ... zipfileset refid=foo filemode=755/ /zip will also work. Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java ZipScanner.java
bodewig 2003/07/03 08:43:09 Modified:src/main/org/apache/tools/ant/taskdefs Zip.java src/main/org/apache/tools/ant/types ZipFileSet.java ZipScanner.java Log: Base zip and zipfileset on new ZipFile code. This happens mainly for two reasons: * preserve stored permissions unless the user explicitly overrides them (PR 2130). This is now fixed for stored files, but not for directories. * deal with filename encoding of existing archives. Supposed to work properly now. Revision ChangesPath 1.108 +14 -6 ant/src/main/org/apache/tools/ant/taskdefs/Zip.java Index: Zip.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- Zip.java 25 Jun 2003 11:52:46 - 1.107 +++ Zip.java 3 Jul 2003 15:43:09 - 1.108 @@ -66,7 +66,6 @@ import java.util.Stack; import java.util.Vector; import java.util.zip.CRC32; -import java.util.zip.ZipFile; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; @@ -85,6 +84,7 @@ import org.apache.tools.ant.util.MergingMapper; import org.apache.tools.ant.util.ResourceUtils; import org.apache.tools.zip.ZipEntry; +import org.apache.tools.zip.ZipFile; import org.apache.tools.zip.ZipOutputStream; /** @@ -362,6 +362,7 @@ log(Adding file + files[j] + to fileset, Project.MSG_VERBOSE); ZipFileSet zf = new ZipFileSet(); +zf.setProject(getProject()); zf.setSrc(new File(basedir, files[j])); filesets.addElement(zf); filesetsFromGroupfilesets.addElement(zf); @@ -439,6 +440,7 @@ if (doUpdate) { addingNewFiles = false; ZipFileSet oldFiles = new ZipFileSet(); +oldFiles.setProject(getProject()); oldFiles.setSrc(renamedFile); for (int i = 0; i addedFiles.size(); i++) { @@ -447,6 +449,7 @@ } DirectoryScanner ds = oldFiles.getDirectoryScanner(getProject()); +((ZipScanner) ds).setEncoding(encoding); String[] f = ds.getIncludedFiles(); Resource[] r = new Resource[f.length]; for (int i = 0; i f.length; i++) { @@ -575,7 +578,7 @@ dealingWithFiles = true; base = fileset.getDir(getProject()); } else { -zf = new ZipFile(zfs.getSrc(getProject())); +zf = new ZipFile(zfs.getSrc(getProject()), encoding); } for (int i = 0; i resources.length; i++) { @@ -595,17 +598,18 @@ } addParentDirs(base, name, zOut, prefix, dirMode); - + if (!resources[i].isDirectory() dealingWithFiles) { File f = fileUtils.resolveFile(base, resources[i].getName()); zipFile(f, zOut, prefix + name, fileMode); } else if (!resources[i].isDirectory()) { -java.util.zip.ZipEntry ze = -zf.getEntry(resources[i].getName()); +ZipEntry ze = zf.getEntry(resources[i].getName()); if (ze != null) { zipFile(zf.getInputStream(ze), zOut, prefix + name, -ze.getTime(), zfs.getSrc(getProject()), fileMode); +ze.getTime(), zfs.getSrc(getProject()), +zfs.hasFileModeBeenSet() ? fileMode + : ze.getUnixMode()); } } } @@ -673,6 +677,7 @@ private synchronized ZipScanner getZipScanner() { if (zs == null) { zs = new ZipScanner(); +zs.setEncoding(encoding); zs.setSrc(zipFile); } return zs; @@ -849,6 +854,9 @@ for (int i = 0; i filesets.length; i++) { DirectoryScanner rs = filesets[i].getDirectoryScanner(getProject()); +if (rs instanceof ZipScanner) { +((ZipScanner) rs).setEncoding(encoding); +} Vector resources = new Vector(); String[] directories = rs.getIncludedDirectories(); for (int j = 0; j directories.length; j++) { 1.21 +35 -4
cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java
antoine 2003/04/22 16:33:32 Modified:src/main/org/apache/tools/ant/types ZipFileSet.java Log: fix because of class cast exception detected Revision ChangesPath 1.18 +4 -1 ant/src/main/org/apache/tools/ant/types/ZipFileSet.java Index: ZipFileSet.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/ZipFileSet.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- ZipFileSet.java 22 Apr 2003 23:16:30 - 1.17 +++ ZipFileSet.java 22 Apr 2003 23:33:32 - 1.18 @@ -295,7 +295,10 @@ } Object o = getRefid().getReferencedObject(p); -if (!(o instanceof ZipFileSet) !(o instanceof FileSet)) { +if (o instanceof FileSet) { + return (AbstractFileSet)(new ZipFileSet((FileSet)o)); +} +else if (!(o instanceof ZipFileSet)) { String msg = getRefid().getRefId() + doesn\'t denote a zipfileset or a fileset; throw new BuildException(msg); } else {
Re: cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java
On 22 Apr 2003, [EMAIL PROTECTED] wrote: +if (o instanceof FileSet) { + return (AbstractFileSet)(new ZipFileSet((FileSet)o)); the cast is not needed here. +} +else if (!(o instanceof ZipFileSet)) { will always be true as instanceof ZipFileSet implies instanceof FileSet. Maybe you really wanted something like if (o instanceof FileSet) { return (AbstractFileSet) o; } else if (o instanceof FileSet) { return (new ZipFileSet((FileSet) o)); } else { String msg = getRefid().getRefId() + doesn\'t denote a zipfileset or a fileset; throw new BuildException(msg); } Stefan
cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java
antoine 2003/04/23 00:20:17 Modified:src/main/org/apache/tools/ant/types ZipFileSet.java Log: fix ZipFileSet#getRef for referenced ZipFileSets Revision ChangesPath 1.19 +5 -7 ant/src/main/org/apache/tools/ant/types/ZipFileSet.java Index: ZipFileSet.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/ZipFileSet.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ZipFileSet.java 22 Apr 2003 23:33:32 - 1.18 +++ ZipFileSet.java 23 Apr 2003 07:20:17 - 1.19 @@ -293,16 +293,14 @@ stk.push(this); dieOnCircularReference(stk, p); } - Object o = getRefid().getReferencedObject(p); -if (o instanceof FileSet) { - return (AbstractFileSet)(new ZipFileSet((FileSet)o)); -} -else if (!(o instanceof ZipFileSet)) { +if (o instanceof ZipFileSet) { +return (AbstractFileSet) o; +} else if (o instanceof FileSet) { + return (new ZipFileSet((FileSet) o)); +} else { String msg = getRefid().getRefId() + doesn\'t denote a zipfileset or a fileset; throw new BuildException(msg); -} else { -return (AbstractFileSet) o; } } /**
Re: cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java defaults.properties
On Sat, 19 Apr 2003, Antoine Levy-Lambert [EMAIL PROTECTED] wrote: I have coded the calls to the getters of ZipFileSet similarly to the getters of FileSet or AbstractFileSet in Zip.java. They are the way they look right now because FileSet is much older than ProjectComponent and thus didn't have project instance (same for Path, BTW). Can we safely to change all the getters of AbstractFileSet As long as you keep the old method signatures (of released code, that is) for backwards compatibility, probably yes, but ... From: Conor MacNeill [EMAIL PROTECTED] Hmmm, it may even be a different project instance. is something to consider. I don't think we are testing a scenario where a fileset gets inherited by a subbuild thoroughly, if at all - still we may get away with the help of clone() that is performed in Ant.java. Stefan
Re: cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java defaults.properties
On Sat, 19 Apr 2003 08:02 am, [EMAIL PROTECTED] wrote: antoine 2003/04/18 15:02:59 Index: Zip.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- Zip.java27 Mar 2003 10:02:04 - 1.103 +++ Zip.java18 Apr 2003 22:02:58 - 1.104 @@ -67,7 +67,6 @@ import java.util.Vector; import java.util.zip.CRC32; import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; @@ -541,10 +540,10 @@ ZipFileSet zfs = null; if (fileset instanceof ZipFileSet) { zfs = (ZipFileSet) fileset; -prefix = zfs.getPrefix(); -fullpath = zfs.getFullpath(); -dirMode = zfs.getDirMode(); -fileMode = zfs.getFileMode(); +prefix = zfs.getPrefix(getProject()); +fullpath = zfs.getFullpath(getProject()); +dirMode = zfs.getDirMode(getProject()); +fileMode = zfs.getFileMode(getProject()); } Passing the project around like this should not be necessary since the zipfileset is a ProjectComponent and should have its own project reference. Hmmm, it may even be a different project instance. Conor
cvs commit: ant/src/main/org/apache/tools/ant/types ZipFileSet.java defaults.properties
antoine 2003/04/18 15:02:59 Modified:docs/manual conceptstypeslist.html docs/manual/CoreTasks zip.html src/main/org/apache/tools/ant/taskdefs Zip.java src/main/org/apache/tools/ant/types ZipFileSet.java defaults.properties Added: src/testcases/org/apache/tools/ant/types ZipFileSetTest.java docs/manual/CoreTypes zipfileset.html Log: allow to define ZipFileSet(s) outside of Zip task bugrep 17007 Revision ChangesPath 1.1 ant/src/testcases/org/apache/tools/ant/types/ZipFileSetTest.java Index: ZipFileSetTest.java === /* * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in *the documentation and/or other materials provided with the *distribution. * * 3. The end-user documentation included with the redistribution, if *any, must include the following acknowlegement: * This product includes software developed by the *Apache Software Foundation (http://www.apache.org/). *Alternately, this acknowlegement may appear in the software itself, *if and wherever such third-party acknowlegements normally appear. * * 4. The names Ant and Apache Software *Foundation must not be used to endorse or promote products derived *from this software without prior written permission. For written *permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called Apache *nor may Apache appear in their names without prior written *permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * http://www.apache.org/. */ package org.apache.tools.ant.types; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import junit.framework.TestCase; import junit.framework.AssertionFailedError; import java.io.File; /** * JUnit 3 testcases for org.apache.tools.ant.types.ZipFileSet. * * pThis doesn't actually test much, mainly reference handling. * * @author Antoine Levy-Lambert */ public class ZipFileSetTest extends AbstractFileSetTest { public ZipFileSetTest(String name) { super(name); } protected AbstractFileSet getInstance() { return new ZipFileSet(); } public final void testAttributes() { ZipFileSet f = (ZipFileSet)getInstance(); //check that dir and src are incompatible f.setSrc(new File(example.zip)); try { f.setDir(new File(examples)); fail(can add dir to + f.getDataTypeName() + when a src is already present); } catch (BuildException be) { assertEquals(Cannot set both dir and src attributes,be.getMessage()); } f = (ZipFileSet)getInstance(); //check that dir and src are incompatible f.setDir(new File(examples)); try { f.setSrc(new File(example.zip)); fail(can add src to + f.getDataTypeName() + when a dir is already present); } catch (BuildException be) { assertEquals(Cannot set both dir and src