// Unix Zip Ant Task // // Douglas Thrift // // $Id$ /* Copyright 2007 Douglas Thrift * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.douglasthrift.anttasks; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Zip; import org.apache.tools.zip.ZipOutputStream; public class UnixZip extends Zip { public static class Symlink extends Task { private String link; private String resource; public void setLink(String link) { this.link = link; } public void setResource(String resource) { this.resource = resource; } } private ArrayList symlinks = new ArrayList(); public Symlink createSymlink() { Symlink symlink = new Symlink(); this.symlinks.add(symlink); return symlink; } protected void finalizeZipOutputStream(ZipOutputStream output) throws IOException { for (Symlink symlink: symlinks) this.zipFile(new ByteArrayInputStream(symlink.resource.getBytes()), output, symlink.link, System.currentTimeMillis(), null, 0120755); } }