(file) Return to GWTCompile.java CVS log (file) (dir) Up to [Development] / GWTAntTasks / src / com / pjaol / gwt / ant

  1 pjaol 1.2 /*
  2            * Copyright 2006 pjaol.com
  3            * 
  4            * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5            * use this file except in compliance with the License. You may obtain a copy of
  6            * the License at
  7            * 
  8            * http://www.apache.org/licenses/LICENSE-2.0
  9 pjaol 1.1  * 
 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.
 15 pjaol 1.1  */
 16           package com.pjaol.gwt.ant;
 17           
 18           import org.apache.tools.ant.Project;
 19           import org.apache.tools.ant.Task;
 20           import org.apache.tools.ant.types.CommandlineJava;
 21           import org.apache.tools.ant.types.EnumeratedAttribute;
 22           import org.apache.tools.ant.types.Path;
 23           
 24           import com.google.gwt.dev.GWTCompiler;
 25           
 26           /**
 27            * @author Patrick O'Leary (pjaol@pjaol.com)
 28            * 
 29            *
 30            */
 31           public class GWTCompile extends Task {
 32           	
 33           	public static class logLevels extends EnumeratedAttribute{
 34           
 35           		@Override
 36 pjaol 1.1 		/**
 37           		 * log values for GWTCompiler
 38           		 */
 39           		public String[] getValues() {
 40           			// ide's such as eclipse, xdoclet editor lower case the enumerated values
 41           			return new String[] {"error", "warn", "info", "trace", "debug", "spam", "all"};
 42           		}
 43           		
 44           	}
 45           	public static class styleTypes extends EnumeratedAttribute {
 46           
 47           		@Override
 48           		public String[] getValues() {
 49           			return new String[] {"obf", "pretty", "detailed"};
 50           		}
 51           		
 52           	}
 53           	private int argpos = 0;
 54           	private String args[] = new String[8];
 55           	private String gen;
 56           	private String logLevel; 
 57 pjaol 1.1 	
 58           	
 59           	private String module;
 60           	private String out;
 61           	
 62           
 63           	private String src;
 64           	private String style;
 65           
 66           	
 67           	private void addArg(String key, String value) {
 68           		args[argpos]= key;
 69           		argpos++;
 70           		args[argpos]= value;
 71           		argpos++;
 72           	}
 73           
 74           	
 75           	public void execute () {
 76           		
 77           		CommandlineJava cmd = new CommandlineJava();
 78 pjaol 1.1 		Path cp = cmd.createClasspath(getProject()).concatSystemClasspath();
 79           		
 80           		cmd.setClassname(GWTCompiler.class.getName());
 81           		if (gen !=null) {
 82           			
 83           			addArg("-gen",gen);
 84           		}
 85           	
 86           		if (out != null) {
 87           			addArg("-out",out);
 88           		}
 89           		
 90           		if (style != null){
 91           			addArg("-style",style);
 92           		}
 93           		
 94           		if(logLevel != null){
 95           			addArg("-logLevel", logLevel);
 96           		}
 97           		
 98           		if (module != null) {
 99 pjaol 1.1 			log("module = " + module +" position = "+argpos, Project.MSG_INFO);
100           			args[argpos] = module;
101           			argpos++;
102           		}
103           		
104           		
105                   cp.add(new Path(getProject(), src));
106               
107           		new TaskUtils().run(getProject(),   cp,GWTCompiler.class.getName(), getArgs(), true);
108           		         
109           	}
110           	
111           	private String[] getArgs() {
112           		String[] a = new String[argpos];
113           		for (int x = 0; x< argpos; x++){
114           			a[x] = args[x];
115           		}
116           		
117           		return a;
118           	}
119           	public String getGen() {
120 pjaol 1.1 		return gen;
121           	}
122           	public String getLogLevel() {
123           		return logLevel;
124           	}
125           	public String getModule() {
126           		return module;
127           	}
128           	
129           	public String getOut() {
130           		return out;
131           	}
132           	public String getSrc() {
133           		return src;
134           	}
135           
136           	public String getStyle() {
137           		return style;
138           	}
139           	public void setGen(String gen) {
140           		this.gen = gen;
141 pjaol 1.1 	}
142           	
143           	public void setLogLevel(logLevels logLevel) {
144           		this.logLevel = logLevel.getValue().toUpperCase();
145           	}
146           	public void setModule(String module) {
147           		this.module = module;
148           	}
149           	
150           	public void setOut(String out) {
151           		this.out = out;
152           	}
153           	
154           	public void setSrc(String src){
155           		this.src = src;
156           	}
157           	
158           	public void setStyle(styleTypes style) {
159           		this.style = style.getValue().toUpperCase();
160           	}
161           	
162 pjaol 1.1 }

cvsadmin
Powered by
ViewCVS 0.9.2