10 pjaol 1.2 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
|
18 pjaol 1.1 */
19 package com.pjaol.gwt.ant;
20
21 import org.apache.tools.ant.Project;
22 import org.apache.tools.ant.Task;
23 import org.apache.tools.ant.types.CommandlineJava;
24 import org.apache.tools.ant.types.EnumeratedAttribute;
25 import org.apache.tools.ant.types.Path;
26
27 import com.google.gwt.dev.GWTCompiler;
28
29 /**
30 * @author Patrick O'Leary (pjaol@pjaol.com)
31 *
32 *
33 */
34 public class GWTCompile extends Task {
35
36 public static class logLevels extends EnumeratedAttribute{
37
38 @Override
39 pjaol 1.1 /**
40 * log values for GWTCompiler
41 */
42 public String[] getValues() {
43 // ide's such as eclipse, xdoclet editor lower case the enumerated values
44 return new String[] {"error", "warn", "info", "trace", "debug", "spam", "all"};
45 }
46
47 }
48 public static class styleTypes extends EnumeratedAttribute {
49
50 @Override
51 public String[] getValues() {
52 return new String[] {"obf", "pretty", "detailed"};
53 }
54
55 }
56 private int argpos = 0;
57 private String args[] = new String[8];
58 private String gen;
59 private String logLevel;
60 pjaol 1.1
61
62 private String module;
63 private String out;
64
65
66 private String src;
67 private String style;
68
69
70 private void addArg(String key, String value) {
71 args[argpos]= key;
72 argpos++;
73 args[argpos]= value;
74 argpos++;
75 }
76
77
78 public void execute () {
79
80 CommandlineJava cmd = new CommandlineJava();
81 pjaol 1.1 Path cp = cmd.createClasspath(getProject()).concatSystemClasspath();
82
83 cmd.setClassname(GWTCompiler.class.getName());
84 if (gen !=null) {
85
86 addArg("-gen",gen);
87 }
88
89 if (out != null) {
90 addArg("-out",out);
91 }
92
93 if (style != null){
94 addArg("-style",style);
95 }
96
97 if(logLevel != null){
98 addArg("-logLevel", logLevel);
99 }
100
101 if (module != null) {
|
103 pjaol 1.1 args[argpos] = module;
104 argpos++;
105 }
106
107
108 cp.add(new Path(getProject(), src));
109
110 new TaskUtils().run(getProject(), cp,GWTCompiler.class.getName(), getArgs(), true);
111
112 }
113
114 private String[] getArgs() {
115 String[] a = new String[argpos];
116 for (int x = 0; x< argpos; x++){
117 a[x] = args[x];
118 }
119
120 return a;
121 }
122 public String getGen() {
123 return gen;
124 pjaol 1.1 }
125 public String getLogLevel() {
126 return logLevel;
127 }
128 public String getModule() {
129 return module;
130 }
131
132 public String getOut() {
133 return out;
134 }
135 public String getSrc() {
136 return src;
137 }
138
139 public String getStyle() {
140 return style;
141 }
142 public void setGen(String gen) {
143 this.gen = gen;
144 }
145 pjaol 1.1
146 public void setLogLevel(logLevels logLevel) {
147 this.logLevel = logLevel.getValue().toUpperCase();
148 }
149 public void setModule(String module) {
150 this.module = module;
151 }
152
153 public void setOut(String out) {
154 this.out = out;
155 }
156
157 public void setSrc(String src){
158 this.src = src;
159 }
160
161 public void setStyle(styleTypes style) {
162 this.style = style.getValue().toUpperCase();
163 }
164
165 }
|