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

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

cvsadmin
Powered by
ViewCVS 0.9.2