1 |
// AAPT Package Ant Task |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
/* Copyright 2008 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 |
import java.io.File; |
25 |
|
26 |
import java.util.ArrayList; |
27 |
import java.util.Iterator; |
28 |
|
29 |
import org.apache.tools.ant.types.DirSet; |
30 |
import org.apache.tools.ant.types.Path; |
31 |
|
32 |
public class AAPTPackage extends CommandTask |
33 |
{ |
34 |
private boolean force_; |
35 |
private boolean update_; |
36 |
private boolean make_; |
37 |
private boolean verbose_; |
38 |
private boolean extending_; |
39 |
private File manifest_; |
40 |
private Path include_; |
41 |
private File assetSources_; |
42 |
private File publicDefinitions_; |
43 |
private File resource_; |
44 |
private File file_; |
45 |
private File java_; |
46 |
private ArrayList<DirSet> dirSets_ = new ArrayList<DirSet>(); |
47 |
|
48 |
public void setForce(boolean force) |
49 |
{ |
50 |
force_ = force; |
51 |
} |
52 |
|
53 |
public void setUpdate(boolean update) |
54 |
{ |
55 |
update_ = update; |
56 |
} |
57 |
|
58 |
public void setMake(boolean make) |
59 |
{ |
60 |
make_ = make; |
61 |
} |
62 |
|
63 |
public void setVerbose(boolean verbose) |
64 |
{ |
65 |
verbose_ = verbose; |
66 |
} |
67 |
|
68 |
public void setExtending(boolean extending) |
69 |
{ |
70 |
extending_ = extending; |
71 |
} |
72 |
|
73 |
public void setManifest(File manifest) |
74 |
{ |
75 |
manifest_ = manifest; |
76 |
} |
77 |
|
78 |
public void setInclude(Path include) |
79 |
{ |
80 |
include_ = include; |
81 |
} |
82 |
|
83 |
public void setAssestSources(File assetSources) |
84 |
{ |
85 |
assetSources_ = assetSources; |
86 |
} |
87 |
|
88 |
public void setPublicDefinitions(File publicDefinitions) |
89 |
{ |
90 |
publicDefinitions_ = publicDefinitions; |
91 |
} |
92 |
|
93 |
public void setResource(File resource) |
94 |
{ |
95 |
resource_ = resource; |
96 |
} |
97 |
|
98 |
public void setFile(File file) |
99 |
{ |
100 |
file_ = file; |
101 |
} |
102 |
|
103 |
public void setJava(File java) |
104 |
{ |
105 |
java_ = java; |
106 |
} |
107 |
|
108 |
public void add(DirSet dirSet) |
109 |
{ |
110 |
dirSets_.add(dirSet); |
111 |
} |
112 |
|
113 |
@Override |
114 |
public void execute() |
115 |
{ |
116 |
if (isUpToDate()) |
117 |
return; |
118 |
|
119 |
command("aapt"); |
120 |
argument("package"); |
121 |
|
122 |
if (force_) |
123 |
argument("-f"); |
124 |
|
125 |
if (update_) |
126 |
argument("-u"); |
127 |
|
128 |
if (make_) |
129 |
argument("-m"); |
130 |
|
131 |
if (verbose_) |
132 |
argument("-v"); |
133 |
|
134 |
if (extending_) |
135 |
argument("-x"); |
136 |
|
137 |
if (manifest_ != null) |
138 |
arguments("-M", manifest_); |
139 |
|
140 |
if (include_ != null) |
141 |
for (Iterator iterator = include_.iterator(); iterator.hasNext();) |
142 |
arguments("-I", iterator.next().toString()); |
143 |
|
144 |
if (assetSources_ != null && assetSources_.exists()) |
145 |
arguments("-A", assetSources_); |
146 |
|
147 |
if (publicDefinitions_ != null) |
148 |
arguments("-P", publicDefinitions_); |
149 |
|
150 |
if (resource_ != null) |
151 |
arguments("-S", resource_); |
152 |
|
153 |
if (file_ != null) |
154 |
arguments("-F", file_); |
155 |
|
156 |
if (java_ != null) |
157 |
arguments("-J", java_); |
158 |
|
159 |
for (DirSet dirSet : dirSets_) |
160 |
for (Iterator iterator = dirSet.iterator(); iterator.hasNext();) |
161 |
argument(iterator.next().toString()); |
162 |
|
163 |
super.execute(); |
164 |
} |
165 |
|
166 |
private boolean isUpToDate() |
167 |
{ |
168 |
return false; |
169 |
} |
170 |
} |