1 18 19 package org.apache.tools.ant.taskdefs.rmic; 20 21 import org.apache.tools.ant.BuildException; 22 import org.apache.tools.ant.Project; 23 import org.apache.tools.ant.taskdefs.ExecuteJava; 24 import org.apache.tools.ant.types.Commandline; 25 26 31 public class KaffeRmic extends DefaultRmicAdapter { 32 private static final String [] RMIC_CLASSNAMES = new String [] { 34 "gnu.classpath.tools.rmi.rmic.RMIC", 35 "gnu.java.rmi.rmic.RMIC", 37 "kaffe.rmi.rmic.RMIC", 39 }; 40 41 44 public static final String COMPILER_NAME = "kaffe"; 45 46 47 public boolean execute() throws BuildException { 48 getRmic().log("Using Kaffe rmic", Project.MSG_VERBOSE); 49 Commandline cmd = setupRmicCommand(); 50 51 Class c = getRmicClass(); 52 if (c == null) { 53 StringBuffer buf = new StringBuffer ("Cannot use Kaffe rmic, as it" 54 + " is not available. None" 55 + " of "); 56 for (int i = 0; i < RMIC_CLASSNAMES.length; i++) { 57 if (i != 0) { 58 buf.append(", "); 59 } 60 61 buf.append(RMIC_CLASSNAMES[i]); 62 } 63 buf.append(" have been found. A common solution is to set the" 64 + " environment variable JAVA_HOME or CLASSPATH."); 65 throw new BuildException(buf.toString(), 66 getRmic().getLocation()); 67 } 68 69 cmd.setExecutable(c.getName()); 70 if (!c.getName().equals(RMIC_CLASSNAMES[RMIC_CLASSNAMES.length - 1])) { 71 cmd.createArgument().setValue("-verbose"); 73 getRmic().log(Commandline.describeCommand(cmd)); 74 } 75 ExecuteJava ej = new ExecuteJava(); 76 ej.setJavaCommand(cmd); 77 return ej.fork(getRmic()) == 0; 78 } 79 80 84 public static boolean isAvailable() { 85 return getRmicClass() != null; 86 } 87 88 94 private static Class getRmicClass() { 95 for (int i = 0; i < RMIC_CLASSNAMES.length; i++) { 96 try { 97 return Class.forName(RMIC_CLASSNAMES[i]); 98 } catch (ClassNotFoundException cnfe) { 99 } 101 } 102 return null; 103 } 104 } 105 | Popular Tags |