1 28 29 30 package org.objectweb.ecm.taskdefs; 31 32 75 public class CIDLIDLTask 76 extends org.apache.tools.ant.Task 77 { 78 private java.io.File _cidlfile; 80 private String _scope; 81 private java.io.File _generateto; 82 private java.io.File _cfgdir; 83 84 public 86 CIDLIDLTask() 87 { 88 _cidlfile = null; 90 _scope = null; 91 _generateto = null; 92 _cfgdir = null; 93 } 94 95 99 100 private void 102 validate() 103 throws org.apache.tools.ant.BuildException 104 { 105 String msg = ""; 106 107 if (!OSHelper.isUnix() && !OSHelper.isWindows()) { 109 msg = "target os must be of unix or windows family"; 110 throw new org.apache.tools.ant.BuildException(msg); 111 } 112 113 if ((_cidlfile==null) && (_scope==null)) { 115 msg = "cidlfile or scope attribute is missing"; 116 throw new org.apache.tools.ant.BuildException(msg); 117 } 118 119 if (_generateto==null) { 121 msg = "generateto attribute is missing"; 122 throw new org.apache.tools.ant.BuildException(msg); 123 } 124 if ((!_generateto.exists()) || (!_generateto.isDirectory())) { 125 msg = "Generation directory does not exist or is not a directory"; 126 throw new org.apache.tools.ant.BuildException(msg); 127 } 128 129 if (_cfgdir==null) { 131 msg = "cfgdir attribute is missing"; 132 throw new org.apache.tools.ant.BuildException(msg); 133 } 134 if ((!_cfgdir.exists()) || (!_cfgdir.isDirectory())) { 135 msg = "Configuration directory does not exist or is not a directory"; 136 throw new org.apache.tools.ant.BuildException(msg); 137 } 138 139 String instdir = getProject().getProperty("ECM.install.dir"); 141 if (instdir==null) { 142 msg = "ECM.install.dir property must be set"; 143 throw new org.apache.tools.ant.BuildException(msg); 144 } 145 } 146 147 private void 148 cidltoidl(java.io.File cfgdir, 149 java.io.File cidlfile, 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 OSHelper.pathConvert(getProject(), "os.ECM.install.dir", "ECM.install.dir"); 160 String cmdname = null; 162 String instdir = getProject().getProperty("os.ECM.install.dir"); 163 164 if (OSHelper.isUnix()) { 165 cmdname = instdir+"/bin/cidl_idl.sh"; 166 } 167 else if (OSHelper.isWindows()) { 168 cmdname = instdir+"\\bin\\cidl_idl.bat"; 169 } 170 171 cmd.setExecutable(cmdname); 172 173 org.apache.tools.ant.types.Environment.Variable openccm_homedir = null; 175 org.apache.tools.ant.types.Environment.Variable openccm_cfgdir = null; 176 177 OSHelper.pathConvert(getProject(), "os.OpenCCM.install.dir", "OpenCCM.install.dir"); 179 String homedir = getProject().getProperty("os.OpenCCM.install.dir"); 180 openccm_homedir = new org.apache.tools.ant.types.Environment.Variable(); 181 openccm_homedir.setKey("OpenCCM_HOMEDIR"); 182 openccm_homedir.setValue(homedir); 183 cmd.addEnv(openccm_homedir); 184 185 openccm_cfgdir = new org.apache.tools.ant.types.Environment.Variable(); 186 openccm_cfgdir.setKey("OpenCCM_CONFIG_DIR"); 187 openccm_cfgdir.setValue(cfgdir.getPath()); 188 cmd.addEnv(openccm_cfgdir); 189 190 org.apache.tools.ant.types.Commandline.Argument arg = cmd.createArg(); 192 arg.setLine(" -d "+gento); 193 194 arg = cmd.createArg(); 195 arg.setValue(scope); 196 197 cmd.execute(); 199 } 200 201 205 final public void 206 setGenerateto(java.io.File dir) 207 { 208 _generateto = dir; 209 } 210 211 final public void 212 setCidlfile(java.io.File cidlfile) 213 { 214 _cidlfile = cidlfile; 215 } 216 217 final public void 218 setScope(String scope) 219 { 220 _scope = scope; 221 } 222 223 final public void 224 setCfgdir(java.io.File cfgdir) 225 { 226 _cfgdir = cfgdir; 227 } 228 229 233 final public void 234 execute() 235 throws org.apache.tools.ant.BuildException 236 { 237 validate(); 238 239 cidltoidl(_cfgdir, _cidlfile, _scope, _generateto); 241 } 242 } 243 | Popular Tags |