1 18 package org.apache.tools.ant.taskdefs; 19 20 import java.io.File ; 21 import java.io.FileWriter ; 22 import java.io.IOException ; 23 import java.io.PrintWriter ; 24 import java.util.Random ; 25 26 import org.apache.tools.ant.BuildException; 27 import org.apache.tools.ant.Project; 28 import org.apache.tools.ant.util.FileUtils; 29 30 41 public class Jikes { 42 43 protected JikesOutputParser jop; 45 protected String command; 46 protected Project project; 47 49 55 protected Jikes(JikesOutputParser jop, String command, Project project) { 56 super(); 57 58 System.err.println("As of Ant 1.2 released in October 2000, " 59 + "the Jikes class"); 60 System.err.println("is considered to be dead code by the Ant " 61 + "developers and is unmaintained."); 62 System.err.println("Don\'t use it!"); 63 64 this.jop = jop; 65 this.command = command; 66 this.project = project; 67 } 68 69 73 protected void compile(String [] args) { 74 String [] commandArray = null; 75 File tmpFile = null; 76 77 try { 78 String myos = System.getProperty("os.name"); 79 80 83 if (myos.toLowerCase().indexOf("windows") >= 0 86 && args.length > 250) { 87 PrintWriter out = null; 88 try { 89 String tempFileName = "jikes" 90 + (new Random (System.currentTimeMillis())).nextLong(); 91 tmpFile = new File (tempFileName); 92 out = new PrintWriter (new FileWriter (tmpFile)); 93 for (int i = 0; i < args.length; i++) { 94 out.println(args[i]); 95 } 96 out.flush(); 97 commandArray = new String [] {command, 98 "@" + tmpFile.getAbsolutePath()}; 99 } catch (IOException e) { 100 throw new BuildException("Error creating temporary file", 101 e); 102 } finally { 103 FileUtils.close(out); 104 } 105 } else { 106 commandArray = new String [args.length + 1]; 107 commandArray[0] = command; 108 System.arraycopy(args, 0, commandArray, 1, args.length); 109 } 110 111 try { 116 Execute exe = new Execute(jop); 117 exe.setAntRun(project); 118 exe.setWorkingDirectory(project.getBaseDir()); 119 exe.setCommandline(commandArray); 120 exe.execute(); 121 } catch (IOException e) { 122 throw new BuildException("Error running Jikes compiler", e); 123 } 124 } finally { 125 if (tmpFile != null) { 126 tmpFile.delete(); 127 } 128 } 129 } 130 } 131 | Popular Tags |