1 23 24 package com.rift.coad.lib.thirdparty.ant; 26 27 import java.io.File ; 29 import java.io.ByteArrayOutputStream ; 30 import java.net.URL ; 31 32 import org.apache.tools.ant.Project; 34 import org.apache.tools.ant.Target; 35 import org.apache.tools.ant.taskdefs.Rmic; 36 import org.apache.tools.ant.types.Path; 37 38 import com.rift.coad.BaseClassLoader; 40 41 46 public class RMIC extends Rmic { 47 48 55 public RMIC(File [] base, String className, File dest) { 56 project = new Project(); 57 project.init(); 58 taskType = "rmic"; 59 taskName = "rmic"; 60 target = new Target(); 61 Path path = new Path(project); 62 for (int index = 0; index < base.length; index++) { 63 path.add(new Path(project,base[index].getAbsolutePath())); 64 } 65 if (this.getClass().getClassLoader() instanceof BaseClassLoader) { 66 BaseClassLoader baseClassLoader = 67 (BaseClassLoader)this.getClass().getClassLoader(); 68 URL urls[] = baseClassLoader.getURLs(); 69 for (int index = 0; index < urls.length; index++) { 70 path.add(new Path(project,urls[index].getFile())); 71 } 72 } 73 74 75 this.setProject(project); 76 this.setClasspath(path); 77 this.setClassname(className); 78 this.setBase(dest); 79 this.setIiop(true); 80 this.setIiopopts("-poa"); 81 } 82 83 84 92 public RMIC(File [] base, File source, String includes, File dest) { 93 project = new Project(); 94 project.init(); 95 taskType = "rmic"; 96 taskName = "rmic"; 97 target = new Target(); 98 Path path = new Path(project); 99 for (int index = 0; index < base.length; index++) { 100 path.add(new Path(project,base[index].getAbsolutePath())); 101 } 102 if (this.getClass().getClassLoader() instanceof BaseClassLoader) { 103 BaseClassLoader baseClassLoader = 104 (BaseClassLoader)this.getClass().getClassLoader(); 105 URL urls[] = baseClassLoader.getURLs(); 106 for (int index = 0; index < urls.length; index++) { 107 path.add(new Path(project,urls[index].getFile())); 108 } 109 } 110 111 112 this.setProject(project); 113 this.setClasspath(path); 114 this.setSourceBase(source); 115 this.setIncludes(includes); 116 this.setBase(dest); 117 this.setIiop(true); 118 this.setIiopopts("-poa"); 119 } 120 121 122 127 public void parse() throws AntException { 128 AntListener listener = new AntListener(); 129 project.addBuildListener(listener); 130 try { 131 execute(); 132 } catch (Exception ex) { 133 throw new AntException("Failed to parse the file : " 134 + ex.getMessage() + " [" + 135 listener.getMessage() + "]",ex); 136 } 137 } 138 } 139 | Popular Tags |