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_; |
49 |
|
private File file_; |
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) |
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_); |
170 |
|
|
171 |
|
private boolean isUpToDate() |
172 |
|
{ |
173 |
< |
return false; |
173 |
> |
Project project = getProject(); |
174 |
> |
UpToDate upToDate = (UpToDate)project.createTask("uptodate"); |
175 |
> |
Union union = upToDate.createSrcResources(); |
176 |
> |
|
177 |
> |
if (manifest_ != null) |
178 |
> |
{ |
179 |
> |
FileSet fileSet = (FileSet)project.createDataType("fileset"); |
180 |
> |
|
181 |
> |
fileSet.setFile(manifest_); |
182 |
> |
union.add(fileSet); |
183 |
> |
} |
184 |
> |
|
185 |
> |
if (assets_ != null && assets_.exists()) |
186 |
> |
{ |
187 |
> |
FileSet fileSet = (FileSet)project.createDataType("fileset"); |
188 |
> |
|
189 |
> |
fileSet.setDir(assets_); |
190 |
> |
union.add(fileSet); |
191 |
> |
} |
192 |
> |
|
193 |
> |
if (resource_ != null) |
194 |
> |
{ |
195 |
> |
FileSet fileSet = (FileSet)project.createDataType("fileset"); |
196 |
> |
|
197 |
> |
fileSet.setDir(resource_); |
198 |
> |
union.add(fileSet); |
199 |
> |
} |
200 |
> |
|
201 |
> |
union.addAll(dirSets_); |
202 |
> |
|
203 |
> |
// TODO: publicDefinitions_ |
204 |
> |
|
205 |
> |
if (file_ != null) |
206 |
> |
{ |
207 |
> |
upToDate.setTargetFile(file_); |
208 |
> |
|
209 |
> |
if (!upToDate.eval()) |
210 |
> |
return false; |
211 |
> |
} |
212 |
> |
|
213 |
> |
if (java_ != null) |
214 |
> |
{ |
215 |
> |
FileSet fileSet = (FileSet)project.createDataType("fileset"); |
216 |
> |
|
217 |
> |
fileSet.setDir(java_); |
218 |
> |
fileSet.setIncludes("**/R.java"); |
219 |
> |
|
220 |
> |
if (fileSet.size() == 0) |
221 |
> |
return false; |
222 |
> |
|
223 |
> |
for (Iterator iterator = fileSet.iterator(); iterator.hasNext();) |
224 |
> |
{ |
225 |
> |
upToDate.setTargetFile(((FileResource)iterator.next()).getFile()); |
226 |
> |
|
227 |
> |
if (!upToDate.eval()) |
228 |
> |
return false; |
229 |
> |
} |
230 |
> |
} |
231 |
> |
|
232 |
> |
return upToDate.eval(); |
233 |
|
} |
234 |
|
} |