1 18 package org.apache.tools.ant.taskdefs; 19 20 import org.apache.tools.ant.Project; 21 import org.apache.tools.ant.BuildException; 22 import org.apache.tools.ant.taskdefs.compilers.AptExternalCompilerAdapter; 23 import org.apache.tools.ant.types.Path; 24 import org.apache.tools.ant.types.Reference; 25 import org.apache.tools.ant.util.JavaEnvUtils; 26 27 import java.util.Vector ; 28 import java.io.File ; 29 30 37 38 39 public class Apt 40 extends Javac { 41 private boolean compile = true; 42 private String factory; 43 private Path factoryPath; 44 private Vector options = new Vector (); 45 private File preprocessDir; 46 47 public static final String EXECUTABLE_NAME = "apt"; 48 49 public static final String ERROR_IGNORING_COMPILER_OPTION 50 = "Ignoring compiler attribute for the APT task, as it is fixed"; 51 52 public static final String ERROR_WRONG_JAVA_VERSION 53 = "Apt task requires Java 1.5+"; 54 55 58 public static final String WARNING_IGNORING_FORK = 59 "Apt only runs in its own JVM; fork=false option ignored"; 60 61 64 public static final class Option { 65 private String name; 66 private String value; 67 68 69 public Option() { 70 } 72 73 77 public String getName() { 78 return name; 79 } 80 81 85 public void setName(String name) { 86 this.name = name; 87 } 88 89 93 public String getValue() { 94 return value; 95 } 96 97 101 public void setValue(String value) { 102 this.value = value; 103 } 104 } 105 106 110 public Apt() { 111 super(); 112 super.setCompiler(AptExternalCompilerAdapter.class.getName()); 113 setFork(true); 114 } 115 116 121 public String getAptExecutable() { 122 return JavaEnvUtils.getJdkExecutable(EXECUTABLE_NAME); 123 } 124 125 130 public void setCompiler(String compiler) { 131 log(ERROR_IGNORING_COMPILER_OPTION, Project.MSG_WARN); 132 } 133 134 141 public void setFork(boolean fork) { 142 if (!fork) { 143 log(WARNING_IGNORING_FORK, Project.MSG_WARN); 144 } 145 } 146 147 151 public String getCompiler() { 152 return super.getCompiler(); 153 } 154 155 160 public boolean isCompile() { 161 return compile; 162 } 163 164 169 public void setCompile(boolean compile) { 170 this.compile = compile; 171 } 172 173 178 public String getFactory() { 179 return factory; 180 } 181 182 187 public void setFactory(String factory) { 188 this.factory = factory; 189 } 190 191 195 public void setFactoryPathRef(Reference ref) { 196 createFactoryPath().setRefid(ref); 197 } 198 199 203 public Path createFactoryPath() { 204 if (factoryPath == null) { 205 factoryPath = new Path(getProject()); 206 } 207 return factoryPath.createPath(); 208 } 209 210 216 public Path getFactoryPath() { 217 return factoryPath; 218 } 219 220 224 public Option createOption() { 225 Option opt = new Option(); 226 options.add(opt); 227 return opt; 228 } 229 230 235 public Vector getOptions() { 236 return options; 237 } 238 239 245 public File getPreprocessDir() { 246 return preprocessDir; 247 } 248 249 253 public void setPreprocessDir(File preprocessDir) { 254 this.preprocessDir = preprocessDir; 255 } 256 257 261 public void execute() 262 throws BuildException { 263 super.execute(); 264 } 265 } 266 | Popular Tags |