1 25 package org.objectweb.jonas.ant; 26 27 import java.io.File ; 28 import java.util.ArrayList ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.DirectoryScanner; 33 import org.apache.tools.ant.Project; 34 import org.apache.tools.ant.taskdefs.Java; 35 import org.apache.tools.ant.types.FileSet; 36 import org.apache.tools.ant.types.Path; 37 38 43 public class GenICTask extends BootstrapTask { 44 45 46 private static final String GENIC_CLASS = "org.objectweb.jonas_ejb.genic.GenIC"; 47 48 49 private boolean validation = true; 50 51 52 private String javac = null; 53 54 55 private String javacOpts = null; 56 57 58 private boolean keepGen = false; 59 60 61 private String protocols = null; 62 63 64 private boolean nocompil = false; 65 66 67 private boolean invokeCmd = false; 68 69 70 private String rmicOpts = null; 71 72 73 private String additionalArgs = null; 74 75 76 private boolean verbose = false; 77 78 79 private Path libraryClasspath = null; 80 81 82 private List filesets = new ArrayList (); 83 84 85 private boolean debug = false; 86 87 90 public Path createClasspath() { 91 libraryClasspath = new Path(getProject()); 92 return libraryClasspath; 93 } 94 95 98 public FileSet createFileSet() { 99 FileSet set = new FileSet(); 100 set.setProject(getProject()); 101 filesets.add(set); 102 return set; 103 } 104 105 109 public void setAdditionalargs(String added) { 110 additionalArgs = added; 111 } 112 113 117 public void setVerbose(boolean v) { 118 verbose = v; 119 } 120 121 125 public void setJvmdebug(boolean d) { 126 debug = d; 127 } 128 129 133 public void setInvokecmd(boolean inv) { 134 invokeCmd = inv; 135 } 136 137 141 public void setNocompil(boolean noc) { 142 nocompil = noc; 143 } 144 145 149 public void setRmicopts(String opts) { 150 rmicOpts = opts; 151 } 152 153 157 public void setValidation(boolean v) { 158 validation = v; 159 } 160 161 165 public void setJavac(String j) { 166 javac = j; 167 } 168 169 173 public void setJavacopts(String opts) { 174 javacOpts = opts; 175 } 176 177 181 public void setKeepgenerated(boolean k) { 182 keepGen = k; 183 } 184 185 189 public void setProtocols(String p) { 190 protocols = p; 191 } 192 193 197 public void execute() throws BuildException { 198 199 setServerName(null); 201 202 for (Iterator fsIterator = filesets.iterator(); fsIterator.hasNext();) { 203 FileSet set = (FileSet) fsIterator.next(); 204 DirectoryScanner ds = set.getDirectoryScanner(getProject()); 205 ds.scan(); 206 String [] files = ds.getIncludedFiles(); 207 File srcDirectory = set.getDir(getProject()); 208 for (int i = 0; i < files.length; i++) { 209 210 Java genic = getBootstraptask(GENIC_CLASS); 211 212 configureGenIC(genic, srcDirectory + File.separator + files[i]); 213 214 log("Calling GenIC task for '" + srcDirectory + File.separator + files[i] + "'.", Project.MSG_VERBOSE); 216 217 if (genic.executeJava() != 0) { 218 throw new BuildException("GenIC reported an error."); 219 } 220 } 221 } 222 223 } 224 225 231 private Java configureGenIC(Java genicJavaTask, String filename) throws BuildException { 232 233 if (keepGen) { 235 genicJavaTask.createArg().setValue("-keepgenerated"); 236 } 237 238 if (!validation) { 240 genicJavaTask.createArg().setValue("-novalidation"); 241 } 242 243 if (libraryClasspath != null) { 245 genicJavaTask.createArg().setValue("-classpath"); 246 genicJavaTask.createArg().setPath(libraryClasspath); 247 } 248 249 if (nocompil) { 251 genicJavaTask.createArg().setValue("-nocompil"); 252 } 253 254 if (invokeCmd) { 256 genicJavaTask.createArg().setValue("-invokecmd"); 257 } 258 259 if (javac != null) { 261 genicJavaTask.createArg().setValue("-javac"); 262 genicJavaTask.createArg().setLine(javac); 263 } 264 265 if (javacOpts != null && !javacOpts.equals("")) { 267 genicJavaTask.createArg().setValue("-javacopts"); 268 genicJavaTask.createArg().setLine(javacOpts); 269 } 270 271 if (rmicOpts != null && !rmicOpts.equals("")) { 273 genicJavaTask.createArg().setValue("-rmicopts"); 274 genicJavaTask.createArg().setValue(rmicOpts); 275 } 276 277 if (verbose) { 279 genicJavaTask.createArg().setValue("-verbose"); 280 } 281 282 if (debug) { 284 genicJavaTask.createJvmarg().setLine("-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=12345,suspend=y"); 285 } 286 287 if (additionalArgs != null) { 289 genicJavaTask.createArg().setLine(additionalArgs); 290 } 291 292 if (protocols != null) { 294 genicJavaTask.createArg().setValue("-protocols"); 295 genicJavaTask.createArg().setValue(protocols); 296 } 297 298 genicJavaTask.createArg().setValue(filename); 300 301 return genicJavaTask; 302 303 } 304 305 } 306 | Popular Tags |