1 28 29 30 package org.objectweb.ecm.taskdefs; 31 32 78 public class IR3toIDL2Task 79 extends org.apache.tools.ant.Task 80 { 81 private String _scope; 83 private java.io.File _generateto; 84 private java.io.File _cfgdir; 85 86 public 88 IR3toIDL2Task() 89 { 90 _scope = null; 92 _generateto = null; 93 _cfgdir = null; 94 } 95 96 100 101 private void 103 validate() 104 throws org.apache.tools.ant.BuildException 105 { 106 String msg = ""; 107 108 if (!OSHelper.isUnix() && !OSHelper.isWindows()) { 110 msg = "target os must be of unix or windows family"; 111 throw new org.apache.tools.ant.BuildException(msg); 112 } 113 114 if (_scope==null) { 116 msg = "scope attribute is missing"; 117 throw new org.apache.tools.ant.BuildException(msg); 118 } 119 120 if (_generateto==null) { 122 msg = "generateto attribute is missing"; 123 throw new org.apache.tools.ant.BuildException(msg); 124 } 125 if ((!_generateto.exists()) || (!_generateto.isDirectory())) { 126 msg = "Generation directory does not exist or is not a directory"; 127 throw new org.apache.tools.ant.BuildException(msg); 128 } 129 130 if (_cfgdir==null) { 132 msg = "cfgdir attribute is missing"; 133 throw new org.apache.tools.ant.BuildException(msg); 134 } 135 if ((!_cfgdir.exists()) || (!_cfgdir.isDirectory())) { 136 msg = "Configuration directory does not exist or is not a directory"; 137 throw new org.apache.tools.ant.BuildException(msg); 138 } 139 140 String bindir = getProject().getProperty("OpenCCM.install.bin.dir"); 142 if (bindir==null) { 143 msg = "OpenCCM.install.bin.dir property must be set"; 144 throw new org.apache.tools.ant.BuildException(msg); 145 } 146 } 147 148 private void 149 ir3toidl2(java.io.File cfgdir, 150 String scope, 151 java.io.File gento) 152 throws org.apache.tools.ant.BuildException 153 { 154 org.apache.tools.ant.taskdefs.ExecTask cmd = null; 156 cmd = (org.apache.tools.ant.taskdefs.ExecTask)getProject().createTask("exec"); 157 158 String cmdname = null; 160 OSHelper.pathConvert(getProject(), "os.OpenCCM.install.bin.dir", "OpenCCM.install.bin.dir"); 162 String bindir = getProject().getProperty("os.OpenCCM.install.bin.dir"); 163 if (OSHelper.isUnix()) { 164 cmdname = bindir+"/ir3_idl2"; 165 } 166 else if (OSHelper.isWindows()) { 167 cmdname = bindir+"\\ir3_idl2.bat"; 168 } 169 170 cmd.setExecutable(cmdname); 171 172 org.apache.tools.ant.types.Environment.Variable openccm_homedir = null; 174 org.apache.tools.ant.types.Environment.Variable openccm_cfgdir = null; 175 176 OSHelper.pathConvert(getProject(), "os.OpenCCM.install.dir", "OpenCCM.install.dir"); 178 String homedir = getProject().getProperty("os.OpenCCM.install.dir"); 179 openccm_homedir = new org.apache.tools.ant.types.Environment.Variable(); 180 openccm_homedir.setKey("OpenCCM_HOMEDIR"); 181 openccm_homedir.setValue(homedir); 182 cmd.addEnv(openccm_homedir); 183 184 openccm_cfgdir = new org.apache.tools.ant.types.Environment.Variable(); 185 openccm_cfgdir.setKey("OpenCCM_CONFIG_DIR"); 186 openccm_cfgdir.setValue(cfgdir.getPath()); 187 cmd.addEnv(openccm_cfgdir); 188 189 String filename = scope.replaceAll("::", "_")+".idl"; 191 if (filename.startsWith("_")) { 192 filename = filename.substring(1); 193 } 194 195 java.io.File idl2file = new java.io.File (gento, filename); 196 197 org.apache.tools.ant.types.Commandline.Argument arg = cmd.createArg(); 199 arg.setLine(" -o "+idl2file.getPath()); 200 201 arg = cmd.createArg(); 202 arg.setValue(scope); 203 204 cmd.execute(); 206 } 207 208 212 final public void 213 setGenerateto(java.io.File dir) 214 { 215 _generateto = dir; 216 } 217 218 final public void 219 setScope(String scope) 220 { 221 _scope = scope; 222 } 223 224 final public void 225 setCfgdir(java.io.File cfgdir) 226 { 227 _cfgdir = cfgdir; 228 } 229 230 234 final public void 235 execute() 236 throws org.apache.tools.ant.BuildException 237 { 238 validate(); 239 240 ir3toidl2(_cfgdir, _scope, _generateto); 242 } 243 } 244 | Popular Tags |