| AW: Bugzilla #6266, my workarround. | AW: Bugzilla #6266, my workarround. 2003-03-05 - By Nestel, Frank IZ/HZA-IC4
Hmm, seems as attachments do not get through to the list. Guess I could have read it somewhere, but there are so many lists ...
Here is the source as textual inclusion:
package de.spieleck.helper;
import java.io.File; import java.io.IOException; import java.io.InputStream;
import org.apache.tools.zip.ZipOutputStream;
import org.apache.tools.ant.taskdefs.Zip;
/** * Create a Zipfile allow relocation of zipfile contents. * That is, we have an extra attribute <globalprefix> * which is textually prepended to all names in zipfile. For example * you can use * <pre> * <taskdef classname="de.spieleck.helper.PrefixZipTask" name="xzip" * classpath="${name}.jar" /> * <xzip zipfile="${release.zip}" globalprefix="${zip.prefix}/"> * <fileset refid="releaseFileset"/> * <fileset refid="sampleFileset"/> * </xzip> * </pre> * with filesets instead of zipfilesets. */ public class PrefixZipTask extends Zip {
/** Allow a global prefix for names within the Zipfile */ protected String globalPrefix = null;
/** * Allow a global prefix for names within the Zipfile * @(protected) globalPrefix the String to prefix all names. */ public void setGlobalPrefix(String globalPrefix) { this.globalPrefix = globalPrefix; }
/** * Patch the path for inclusion in zipfile. * @(protected) vPath the unpatched path * @(protected) the patched path */ protected String zipPath(String vPath) { return globalPrefix == null ? vPath : globalPrefix + vPath; }
/** * Patch zipDir(), insert {@(protected) globalPrefix} if appropriate. * @(protected) patch */ protected void zipDir(File dir, ZipOutputStream zOut, String vPath, int mode) throws IOException { super.zipDir(dir, zOut, zipPath(vPath), mode); }
/** * Patch zipFile(), insert {@(protected) globalPrefix} if appropriate. * @(protected) patch */ protected void zipFile(InputStream in, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode) throws IOException { super.zipFile(in, zOut, zipPath(vPath), lastModified,fromArchive,mode); }
/** * @(protected) patch */ public void reset() { globalPrefix = null; super.reset(); }
}
> -----Urspr?ngliche Nachricht----- > Von: Nestel, Frank IZ/HZA-IC4 [mailto:nestefan@(protected)] > Gesendet: Dienstag, 4. M?rz 2003 15:59 > An: 'Ant Users List' > Betreff: Bugzilla #6266, my workarround. > > > Attached find my personal solution to bugzilla #6266. > It is almost trivial, but very helpful in my setting. > Maybe someone can build that into the mainstream of the > zip task. I cannot see any special reason why it is not > there. > > Thanks. > Frank > > > >
|
|
 |