1 28 29 30 package org.objectweb.ecm.taskdefs; 31 32 75 public class CIDLJImplTask 76 extends org.apache.tools.ant.Task 77 { 78 private String _scope; 80 private java.io.File _generateto; 81 private java.io.File _cfgdir; 82 83 public 85 CIDLJImplTask() 86 { 87 _scope = null; 89 _generateto = null; 90 _cfgdir = null; 91 } 92 93 97 98 private void 100 validate() 101 throws org.apache.tools.ant.BuildException 102 { 103 String msg = ""; 104 105 if (!OSHelper.isUnix() && !OSHelper.isWindows()) { 107 msg = "target os must be of unix or windows family"; 108 throw new org.apache.tools.ant.BuildException(msg); 109 } 110 111 if (_scope==null) { 113 msg = "scope attribute is missing"; 114 throw new org.apache.tools.ant.BuildException(msg); 115 } 116 117 if (_generateto==null) { 119 msg = "generateto attribute is missing"; 120 throw new org.apache.tools.ant.BuildException(msg); 121 } 122 if ((!_generateto.exists()) || (!_generateto.isDirectory())) { 123 msg = "Generation directory does not exist or is not a directory"; 124 throw new org.apache.tools.ant.BuildException(msg); 125 } 126 127 if (_cfgdir==null) { 129 msg = "cfgdir attribute is missing"; 130 throw new org.apache.tools.ant.BuildException(msg); 131 } 132 if ((!_cfgdir.exists()) || (!_cfgdir.isDirectory())) { 133 msg = "Configuration directory does not exist or is not a directory"; 134 throw new org.apache.tools.ant.BuildException(msg); 135 } 136 137 String instdir = getProject().getProperty("ECM.install.dir"); 139 if (instdir==null) { 140 msg = "ECM.install.dir property must be set"; 141 throw new org.apache.tools.ant.BuildException(msg); 142 } 143 } 144 145 private void 146 cidltojimpl(java.io.File cfgdir, 147 String scope, 148 java.io.File gento) 149 throws org.apache.tools.ant.BuildException 150 { 151 org.apache.tools.ant.taskdefs.ExecTask cmd = null; 153 cmd = (org.apache.tools.ant.taskdefs.ExecTask)getProject().createTask("exec"); 154 155 OSHelper.pathConvert(getProject(), "os.ECM.install.dir", "ECM.install.dir"); 157 String cmdname = null; 159 String instdir = getProject().getProperty("os.ECM.install.dir"); 160 if (OSHelper.isUnix()) { 161 cmdname = instdir+"/bin/cidl_jimpl.sh"; 162 } 163 else if (OSHelper.isWindows()) { 164 cmdname = instdir+"\\bin\\cidl_jimpl.bat"; 165 } 166 167 cmd.setExecutable(cmdname); 168 169 org.apache.tools.ant.types.Environment.Variable openccm_homedir = null; 171 org.apache.tools.ant.types.Environment.Variable openccm_cfgdir = null; 172 173 OSHelper.pathConvert(getProject(), "os.OpenCCM.install.dir", "OpenCCM.install.dir"); 175 String homedir = getProject().getProperty("os.OpenCCM.install.dir"); 176 openccm_homedir = new org.apache.tools.ant.types.Environment.Variable(); 177 openccm_homedir.setKey("OpenCCM_HOMEDIR"); 178 openccm_homedir.setValue(homedir); 179 cmd.addEnv(openccm_homedir); 180 181 openccm_cfgdir = new org.apache.tools.ant.types.Environment.Variable(); 182 openccm_cfgdir.setKey("OpenCCM_CONFIG_DIR"); 183 openccm_cfgdir.setValue(cfgdir.getPath()); 184 cmd.addEnv(openccm_cfgdir); 185 186 org.apache.tools.ant.types.Commandline.Argument arg = cmd.createArg(); 188 arg.setLine(" -d "+gento); 189 190 arg = cmd.createArg(); 191 arg.setValue(scope); 192 193 cmd.execute(); 195 } 196 197 201 final public void 202 setGenerateto(java.io.File dir) 203 { 204 _generateto = dir; 205 } 206 207 final public void 208 setScope(String scope) 209 { 210 _scope = scope; 211 } 212 213 final public void 214 setCfgdir(java.io.File cfgdir) 215 { 216 _cfgdir = cfgdir; 217 } 218 219 223 final public void 224 execute() 225 throws org.apache.tools.ant.BuildException 226 { 227 validate(); 228 229 cidltojimpl(_cfgdir, _scope, _generateto); 231 } 232 } 233 | Popular Tags |