1 |
douglas |
974 |
// Unix Zip Ant Task |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
/* Copyright 2007 Douglas Thrift |
8 |
|
|
* |
9 |
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
10 |
|
|
* you may not use this file except in compliance with the License. |
11 |
|
|
* You may obtain a copy of the License at |
12 |
|
|
* |
13 |
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
14 |
|
|
* |
15 |
|
|
* Unless required by applicable law or agreed to in writing, software |
16 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
17 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
18 |
|
|
* See the License for the specific language governing permissions and |
19 |
|
|
* limitations under the License. |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
package net.douglasthrift.anttasks; |
23 |
|
|
|
24 |
douglas |
975 |
import java.io.ByteArrayInputStream; |
25 |
|
|
import java.io.IOException; |
26 |
|
|
import java.util.ArrayList; |
27 |
douglas |
974 |
|
28 |
|
|
import org.apache.tools.ant.Task; |
29 |
douglas |
975 |
import org.apache.tools.ant.taskdefs.Zip; |
30 |
douglas |
974 |
import org.apache.tools.zip.ZipOutputStream; |
31 |
|
|
|
32 |
douglas |
975 |
public class UnixZip extends Zip |
33 |
douglas |
974 |
{ |
34 |
douglas |
975 |
public static class Symlink extends Task |
35 |
douglas |
974 |
{ |
36 |
douglas |
975 |
private String link; |
37 |
|
|
private String resource; |
38 |
|
|
|
39 |
|
|
public void setLink(String link) |
40 |
|
|
{ |
41 |
|
|
this.link = link; |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
public void setResource(String resource) |
45 |
|
|
{ |
46 |
|
|
this.resource = resource; |
47 |
|
|
} |
48 |
douglas |
974 |
} |
49 |
douglas |
975 |
|
50 |
|
|
private ArrayList<Symlink> symlinks = new ArrayList<Symlink>(); |
51 |
|
|
|
52 |
|
|
public Symlink createSymlink() |
53 |
|
|
{ |
54 |
|
|
Symlink symlink = new Symlink(); |
55 |
|
|
|
56 |
|
|
this.symlinks.add(symlink); |
57 |
|
|
|
58 |
|
|
return symlink; |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
protected void finalizeZipOutputStream(ZipOutputStream output) throws IOException |
62 |
|
|
{ |
63 |
|
|
for (Symlink symlink: symlinks) |
64 |
|
|
this.zipFile(new ByteArrayInputStream(symlink.resource.getBytes()), output, symlink.link, System.currentTimeMillis(), null, 0120755); |
65 |
|
|
} |
66 |
douglas |
974 |
} |