1 6 7 package SOFA.Connector.EEG.EEM.Actions; 8 9 import SOFA.Connector.EEG.EEM.ActionException; 10 import SOFA.Connector.EEG.EEM.ActionInterface; 11 12 17 public class JavaCompiler implements ActionInterface { 18 19 20 public JavaCompiler(java.util.HashMap props) { 21 } 22 23 public String getName() { 24 return "javac"; 25 } 26 27 public void perform(SOFA.Connector.Property[] params, String sourceDir, String sourcePackage, String destDir, String destPackage) throws ActionException { 28 String source; 29 String iface; 30 if ((source=SOFA.Connector.Property.findFirst(params,"source"))==null) { 31 throw new ActionException("source param not specified"); 32 } 33 if ((iface=SOFA.Connector.Property.findFirst(params,"iface"))==null) { 34 throw new ActionException("iface param not specified"); 35 } 36 37 int ret; 38 String classpath=""; 39 try { 40 classpath = SOFA.Util.ConnGenPathInfo.getConnGenClassPath(iface); 41 Runtime runtime=Runtime.getRuntime(); 42 Process process=runtime.exec("javac -classpath "+classpath+" "+destDir+"/"+source); 43 ret=process.waitFor(); 44 } catch (Exception e) { 45 throw new ActionException("Can't compile java source "+destDir+"/"+source+".",e); 46 } 47 if (ret!=0) { 48 throw new ActionException("Compilation 'javac -classpath "+classpath+" "+destDir+"/"+source+"' returned error ("+ret+")."); 49 } 50 } 51 52 } 53 | Popular Tags |