Mercurial > cgi-bin > hgweb.cgi > JpegWasher
annotate lib/mod/src/de/masters_of_disaster/ant/tasks/ar/Ar.java @ 33:3d86f0391168
Work on improving the build system.
author | David Barts <davidb@stashtea.com> |
---|---|
date | Fri, 24 Apr 2020 19:45:57 -0700 |
parents | |
children |
rev | line source |
---|---|
33
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
1 package de.masters_of_disaster.ant.tasks.ar; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
2 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
3 import java.io.BufferedOutputStream; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
4 import java.io.File; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
5 import java.io.FileInputStream; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
6 import java.io.FileOutputStream; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
7 import java.io.IOException; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
8 import java.util.Enumeration; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
9 import java.util.Vector; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
10 import org.apache.tools.ant.BuildException; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
11 import org.apache.tools.ant.DirectoryScanner; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
12 import org.apache.tools.ant.Project; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
13 import org.apache.tools.ant.taskdefs.MatchingTask; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
14 import org.apache.tools.ant.types.EnumeratedAttribute; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
15 import org.apache.tools.ant.types.FileSet; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
16 import org.apache.tools.ant.util.FileUtils; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
17 import org.apache.tools.ant.util.MergingMapper; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
18 import org.apache.tools.ant.util.SourceFileScanner; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
19 import org.apache.tools.zip.UnixStat; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
20 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
21 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
22 * Creates an ar archive. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
23 * |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
24 * @ant.task category="packaging" |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
25 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
26 public class Ar extends MatchingTask { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
27 File destFile; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
28 File baseDir; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
29 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
30 private ArLongFileMode longFileMode = new ArLongFileMode(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
31 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
32 Vector filesets = new Vector(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
33 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
34 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
35 * Indicates whether the user has been warned about long files already. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
36 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
37 private boolean longWarningGiven = false; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
38 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
39 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
40 * Add a new fileset with the option to specify permissions |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
41 * @return the ar fileset to be used as the nested element. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
42 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
43 public ArFileSet createArFileSet() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
44 ArFileSet fileset = new ArFileSet(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
45 filesets.addElement(fileset); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
46 return fileset; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
47 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
48 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
49 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
50 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
51 * Set the name/location of where to create the ar file. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
52 * @param destFile The output of the tar |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
53 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
54 public void setDestFile(File destFile) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
55 this.destFile = destFile; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
56 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
57 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
58 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
59 * This is the base directory to look in for things to ar. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
60 * @param baseDir the base directory. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
61 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
62 public void setBasedir(File baseDir) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
63 this.baseDir = baseDir; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
64 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
65 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
66 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
67 * Set how to handle long files, those with a name>16 chars or containing spaces. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
68 * Optional, default=warn. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
69 * <p> |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
70 * Allowable values are |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
71 * <ul> |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
72 * <li> truncate - names are truncated to the maximum length, spaces are replaced by '_' |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
73 * <li> fail - names greater than the maximum cause a build exception |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
74 * <li> warn - names greater than the maximum cause a warning and TRUNCATE is used |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
75 * <li> bsd - BSD variant is used if any names are greater than the maximum. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
76 * <li> gnu - GNU variant is used if any names are greater than the maximum. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
77 * <li> omit - files with a name greater than the maximum are omitted from the archive |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
78 * </ul> |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
79 * @param mode the mode to handle long file names. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
80 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
81 public void setLongfile(ArLongFileMode mode) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
82 this.longFileMode = mode; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
83 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
84 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
85 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
86 * do the business |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
87 * @throws BuildException on error |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
88 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
89 public void execute() throws BuildException { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
90 if (destFile == null) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
91 throw new BuildException("destFile attribute must be set!", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
92 getLocation()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
93 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
94 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
95 if (destFile.exists() && destFile.isDirectory()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
96 throw new BuildException("destFile is a directory!", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
97 getLocation()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
98 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
99 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
100 if (destFile.exists() && !destFile.canWrite()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
101 throw new BuildException("Can not write to the specified destFile!", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
102 getLocation()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
103 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
104 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
105 Vector savedFileSets = (Vector) filesets.clone(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
106 try { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
107 if (baseDir != null) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
108 if (!baseDir.exists()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
109 throw new BuildException("basedir does not exist!", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
110 getLocation()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
111 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
112 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
113 // add the main fileset to the list of filesets to process. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
114 ArFileSet mainFileSet = new ArFileSet(fileset); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
115 mainFileSet.setDir(baseDir); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
116 filesets.addElement(mainFileSet); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
117 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
118 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
119 if (filesets.size() == 0) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
120 throw new BuildException("You must supply either a basedir " |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
121 + "attribute or some nested filesets.", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
122 getLocation()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
123 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
124 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
125 // check if ar is out of date with respect to each |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
126 // fileset |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
127 boolean upToDate = true; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
128 for (Enumeration e = filesets.elements(); e.hasMoreElements();) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
129 ArFileSet fs = (ArFileSet) e.nextElement(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
130 String[] files = fs.getFiles(getProject()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
131 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
132 if (!archiveIsUpToDate(files, fs.getDir(getProject()))) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
133 upToDate = false; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
134 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
135 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
136 for (int i = 0; i < files.length; ++i) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
137 if (destFile.equals(new File(fs.getDir(getProject()), |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
138 files[i]))) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
139 throw new BuildException("An ar file cannot include " |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
140 + "itself", getLocation()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
141 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
142 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
143 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
144 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
145 if (upToDate) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
146 log("Nothing to do: " + destFile.getAbsolutePath() |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
147 + " is up to date.", Project.MSG_INFO); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
148 return; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
149 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
150 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
151 log("Building ar: " + destFile.getAbsolutePath(), Project.MSG_INFO); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
152 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
153 ArOutputStream aOut = null; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
154 try { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
155 aOut = new ArOutputStream( |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
156 new BufferedOutputStream( |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
157 new FileOutputStream(destFile))); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
158 if (longFileMode.isTruncateMode() |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
159 || longFileMode.isWarnMode()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
160 aOut.setLongFileMode(ArOutputStream.LONGFILE_TRUNCATE); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
161 } else if (longFileMode.isFailMode() |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
162 || longFileMode.isOmitMode()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
163 aOut.setLongFileMode(ArOutputStream.LONGFILE_ERROR); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
164 } else if (longFileMode.isBsdMode()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
165 aOut.setLongFileMode(ArOutputStream.LONGFILE_BSD); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
166 } else { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
167 // GNU |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
168 aOut.setLongFileMode(ArOutputStream.LONGFILE_GNU); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
169 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
170 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
171 longWarningGiven = false; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
172 for (Enumeration e = filesets.elements(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
173 e.hasMoreElements();) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
174 ArFileSet fs = (ArFileSet) e.nextElement(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
175 String[] files = fs.getFiles(getProject()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
176 if (files.length > 1 && fs.getFullpath().length() > 0) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
177 throw new BuildException("fullpath attribute may only " |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
178 + "be specified for " |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
179 + "filesets that specify a " |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
180 + "single file."); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
181 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
182 for (int i = 0; i < files.length; i++) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
183 File f = new File(fs.getDir(getProject()), files[i]); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
184 arFile(f, aOut, fs); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
185 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
186 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
187 } catch (IOException ioe) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
188 String msg = "Problem creating AR: " + ioe.getMessage(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
189 throw new BuildException(msg, ioe, getLocation()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
190 } finally { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
191 FileUtils.close(aOut); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
192 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
193 } finally { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
194 filesets = savedFileSets; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
195 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
196 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
197 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
198 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
199 * ar a file |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
200 * @param file the file to ar |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
201 * @param aOut the output stream |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
202 * @param arFileSet the fileset that the file came from. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
203 * @throws IOException on error |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
204 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
205 protected void arFile(File file, ArOutputStream aOut, ArFileSet arFileSet) |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
206 throws IOException { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
207 FileInputStream fIn = null; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
208 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
209 if (file.isDirectory()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
210 return; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
211 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
212 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
213 String fileName = file.getName(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
214 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
215 String fullpath = arFileSet.getFullpath(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
216 if (fullpath.length() > 0) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
217 fileName = fullpath.substring(fullpath.lastIndexOf('/')); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
218 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
219 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
220 // don't add "" to the archive |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
221 if (fileName.length() <= 0) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
222 return; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
223 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
224 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
225 try { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
226 if ((fileName.length() >= ArConstants.NAMELEN) |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
227 || (-1 != fileName.indexOf(' '))) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
228 if (longFileMode.isOmitMode()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
229 log("Omitting: " + fileName, Project.MSG_INFO); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
230 return; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
231 } else if (longFileMode.isWarnMode()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
232 if (!longWarningGiven) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
233 log("Resulting ar file contains truncated or space converted filenames", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
234 Project.MSG_WARN); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
235 longWarningGiven = true; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
236 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
237 log("Entry: \"" + fileName + "\" longer than " |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
238 + ArConstants.NAMELEN + " characters or containing spaces.", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
239 Project.MSG_WARN); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
240 } else if (longFileMode.isFailMode()) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
241 throw new BuildException("Entry: \"" + fileName |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
242 + "\" longer than " + ArConstants.NAMELEN |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
243 + "characters or containting spaces.", getLocation()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
244 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
245 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
246 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
247 ArEntry ae = new ArEntry(fileName); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
248 ae.setFileDate(file.lastModified()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
249 ae.setUserId(arFileSet.getUid()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
250 ae.setGroupId(arFileSet.getGid()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
251 ae.setMode(arFileSet.getMode()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
252 ae.setSize(file.length()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
253 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
254 aOut.putNextEntry(ae); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
255 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
256 fIn = new FileInputStream(file); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
257 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
258 byte[] buffer = new byte[8 * 1024]; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
259 int count = 0; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
260 do { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
261 aOut.write(buffer, 0, count); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
262 count = fIn.read(buffer, 0, buffer.length); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
263 } while (count != -1); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
264 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
265 aOut.closeEntry(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
266 } finally { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
267 if (fIn != null) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
268 fIn.close(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
269 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
270 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
271 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
272 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
273 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
274 * Is the archive up to date in relationship to a list of files. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
275 * @param files the files to check |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
276 * @param dir the base directory for the files. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
277 * @return true if the archive is up to date. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
278 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
279 protected boolean archiveIsUpToDate(String[] files, File dir) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
280 SourceFileScanner sfs = new SourceFileScanner(this); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
281 MergingMapper mm = new MergingMapper(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
282 mm.setTo(destFile.getAbsolutePath()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
283 return sfs.restrict(files, dir, null, mm).length == 0; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
284 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
285 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
286 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
287 * This is a FileSet with the option to specify permissions |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
288 * and other attributes. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
289 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
290 public static class ArFileSet extends FileSet { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
291 private String[] files = null; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
292 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
293 private int fileMode = UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
294 private int uid; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
295 private int gid; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
296 private String fullpath = ""; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
297 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
298 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
299 * Creates a new <code>ArFileSet</code> instance. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
300 * Using a fileset as a constructor argument. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
301 * |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
302 * @param fileset a <code>FileSet</code> value |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
303 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
304 public ArFileSet(FileSet fileset) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
305 super(fileset); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
306 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
307 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
308 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
309 * Creates a new <code>ArFileSet</code> instance. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
310 * |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
311 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
312 public ArFileSet() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
313 super(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
314 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
315 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
316 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
317 * Get a list of files and directories specified in the fileset. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
318 * @param p the current project. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
319 * @return a list of file and directory names, relative to |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
320 * the baseDir for the project. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
321 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
322 public String[] getFiles(Project p) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
323 if (files == null) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
324 DirectoryScanner ds = getDirectoryScanner(p); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
325 files = ds.getIncludedFiles(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
326 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
327 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
328 return files; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
329 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
330 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
331 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
332 * A 3 digit octal string, specify the user, group and |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
333 * other modes in the standard Unix fashion; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
334 * optional, default=0644 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
335 * @param octalString a 3 digit octal string. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
336 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
337 public void setMode(String octalString) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
338 this.fileMode = |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
339 UnixStat.FILE_FLAG | Integer.parseInt(octalString, 8); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
340 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
341 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
342 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
343 * @return the current mode. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
344 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
345 public int getMode() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
346 return fileMode; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
347 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
348 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
349 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
350 * The UID for the ar entry; optional, default="0" |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
351 * @param uid the id of the user for the ar entry. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
352 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
353 public void setUid(int uid) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
354 this.uid = uid; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
355 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
356 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
357 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
358 * @return the UID for the ar entry |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
359 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
360 public int getUid() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
361 return uid; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
362 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
363 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
364 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
365 * The GID for the ar entry; optional, default="0" |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
366 * @param gid the group id. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
367 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
368 public void setGid(int gid) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
369 this.gid = gid; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
370 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
371 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
372 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
373 * @return the group identifier. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
374 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
375 public int getGid() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
376 return gid; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
377 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
378 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
379 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
380 * If the fullpath attribute is set, the file in the fileset |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
381 * is written with the last part of the path in the archive. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
382 * If the fullpath ends in '/' the file is omitted from the archive. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
383 * It is an error to have more than one file specified in such a fileset. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
384 * @param fullpath the path to use for the file in a fileset. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
385 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
386 public void setFullpath(String fullpath) { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
387 this.fullpath = fullpath; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
388 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
389 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
390 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
391 * @return the path to use for a single file fileset. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
392 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
393 public String getFullpath() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
394 return fullpath; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
395 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
396 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
397 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
398 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
399 * Set of options for long file handling in the task. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
400 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
401 public static class ArLongFileMode extends EnumeratedAttribute { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
402 /** permissible values for longfile attribute */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
403 public static final String |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
404 WARN = "warn", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
405 FAIL = "fail", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
406 TRUNCATE = "truncate", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
407 GNU = "gnu", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
408 BSD = "bsd", |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
409 OMIT = "omit"; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
410 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
411 private final String[] validModes = {WARN, FAIL, TRUNCATE, GNU, BSD, OMIT}; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
412 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
413 /** Constructor, defaults to "warn" */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
414 public ArLongFileMode() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
415 super(); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
416 setValue(WARN); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
417 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
418 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
419 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
420 * @return the possible values for this enumerated type. |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
421 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
422 public String[] getValues() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
423 return validModes; |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
424 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
425 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
426 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
427 * @return true if value is "truncate". |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
428 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
429 public boolean isTruncateMode() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
430 return TRUNCATE.equalsIgnoreCase(getValue()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
431 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
432 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
433 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
434 * @return true if value is "warn". |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
435 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
436 public boolean isWarnMode() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
437 return WARN.equalsIgnoreCase(getValue()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
438 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
439 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
440 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
441 * @return true if value is "gnu". |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
442 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
443 public boolean isGnuMode() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
444 return GNU.equalsIgnoreCase(getValue()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
445 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
446 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
447 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
448 * @return true if value is "bsd". |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
449 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
450 public boolean isBsdMode() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
451 return BSD.equalsIgnoreCase(getValue()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
452 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
453 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
454 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
455 * @return true if value is "fail". |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
456 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
457 public boolean isFailMode() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
458 return FAIL.equalsIgnoreCase(getValue()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
459 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
460 |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
461 /** |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
462 * @return true if value is "omit". |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
463 */ |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
464 public boolean isOmitMode() { |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
465 return OMIT.equalsIgnoreCase(getValue()); |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
466 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
467 } |
3d86f0391168
Work on improving the build system.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
468 } |