26 |
|
import java.util.ArrayList; |
27 |
|
import java.util.Iterator; |
28 |
|
|
29 |
+ |
import org.apache.tools.ant.Project; |
30 |
+ |
import org.apache.tools.ant.taskdefs.UpToDate; |
31 |
|
import org.apache.tools.ant.types.DirSet; |
32 |
+ |
import org.apache.tools.ant.types.FileSet; |
33 |
|
import org.apache.tools.ant.types.Path; |
34 |
+ |
import org.apache.tools.ant.types.resources.FileResource; |
35 |
+ |
import org.apache.tools.ant.types.resources.Union; |
36 |
|
|
37 |
|
public class AAPTPackage extends CommandTask |
38 |
|
{ |
43 |
|
private boolean extending_; |
44 |
|
private File manifest_; |
45 |
|
private Path include_; |
46 |
< |
private File assetSources_; |
46 |
> |
private File assets_; |
47 |
|
private File publicDefinitions_; |
48 |
< |
private File resource_; |
48 |
> |
private Path resource_; |
49 |
|
private File file_; |
50 |
|
private File java_; |
51 |
|
private ArrayList<DirSet> dirSets_ = new ArrayList<DirSet>(); |
85 |
|
include_ = include; |
86 |
|
} |
87 |
|
|
88 |
< |
public void setAssestSources(File assetSources) |
88 |
> |
public void setAssets(File assets) |
89 |
|
{ |
90 |
< |
assetSources_ = assetSources; |
90 |
> |
assets_ = assets; |
91 |
|
} |
92 |
|
|
93 |
|
public void setPublicDefinitions(File publicDefinitions) |
95 |
|
publicDefinitions_ = publicDefinitions; |
96 |
|
} |
97 |
|
|
98 |
< |
public void setResource(File resource) |
98 |
> |
public void setResource(Path resource) |
99 |
|
{ |
100 |
|
resource_ = resource; |
101 |
|
} |
146 |
|
for (Iterator iterator = include_.iterator(); iterator.hasNext();) |
147 |
|
arguments("-I", iterator.next().toString()); |
148 |
|
|
149 |
< |
if (assetSources_ != null && assetSources_.exists()) |
150 |
< |
arguments("-A", assetSources_); |
149 |
> |
if (assets_ != null && assets_.exists()) |
150 |
> |
arguments("-A", assets_); |
151 |
|
|
152 |
|
if (publicDefinitions_ != null) |
153 |
|
arguments("-P", publicDefinitions_); |
154 |
|
|
155 |
|
if (resource_ != null) |
156 |
< |
arguments("-S", resource_); |
156 |
> |
for (String resource : resource_.list()) |
157 |
> |
arguments("-S", resource); |
158 |
|
|
159 |
|
if (file_ != null) |
160 |
|
arguments("-F", file_); |
171 |
|
|
172 |
|
private boolean isUpToDate() |
173 |
|
{ |
174 |
< |
return false; |
174 |
> |
Project project = getProject(); |
175 |
> |
UpToDate upToDate = (UpToDate)project.createTask("uptodate"); |
176 |
> |
Union union = upToDate.createSrcResources(); |
177 |
> |
|
178 |
> |
if (manifest_ != null) |
179 |
> |
{ |
180 |
> |
FileSet fileSet = (FileSet)project.createDataType("fileset"); |
181 |
> |
|
182 |
> |
fileSet.setFile(manifest_); |
183 |
> |
union.add(fileSet); |
184 |
> |
} |
185 |
> |
|
186 |
> |
if (assets_ != null && assets_.exists()) |
187 |
> |
{ |
188 |
> |
FileSet fileSet = (FileSet)project.createDataType("fileset"); |
189 |
> |
|
190 |
> |
fileSet.setDir(assets_); |
191 |
> |
union.add(fileSet); |
192 |
> |
} |
193 |
> |
|
194 |
> |
if (resource_ != null) |
195 |
> |
union.add(resource_); |
196 |
> |
|
197 |
> |
union.addAll(dirSets_); |
198 |
> |
|
199 |
> |
// TODO: publicDefinitions_ |
200 |
> |
|
201 |
> |
if (file_ != null) |
202 |
> |
{ |
203 |
> |
upToDate.setTargetFile(file_); |
204 |
> |
|
205 |
> |
if (!upToDate.eval()) |
206 |
> |
return false; |
207 |
> |
} |
208 |
> |
|
209 |
> |
if (java_ != null) |
210 |
> |
{ |
211 |
> |
FileSet fileSet = (FileSet)project.createDataType("fileset"); |
212 |
> |
|
213 |
> |
fileSet.setDir(java_); |
214 |
> |
fileSet.setIncludes("**/R.java"); |
215 |
> |
|
216 |
> |
if (fileSet.size() == 0) |
217 |
> |
return false; |
218 |
> |
|
219 |
> |
for (Iterator iterator = fileSet.iterator(); iterator.hasNext();) |
220 |
> |
{ |
221 |
> |
upToDate.setTargetFile(((FileResource)iterator.next()).getFile()); |
222 |
> |
|
223 |
> |
if (!upToDate.eval()) |
224 |
> |
return false; |
225 |
> |
} |
226 |
> |
} |
227 |
> |
|
228 |
> |
return upToDate.eval(); |
229 |
|
} |
230 |
|
} |