1 18 19 package org.apache.tools.ant.taskdefs.compilers; 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 import org.apache.tools.ant.types.Path; 26 27 34 public class Kjc extends DefaultCompilerAdapter { 35 36 41 public boolean execute() throws BuildException { 42 attributes.log("Using kjc compiler", Project.MSG_VERBOSE); 43 Commandline cmd = setupKjcCommand(); 44 cmd.setExecutable("at.dms.kjc.Main"); 45 ExecuteJava ej = new ExecuteJava(); 46 ej.setJavaCommand(cmd); 47 return ej.fork(getJavac()) == 0; 48 } 49 50 54 protected Commandline setupKjcCommand() { 55 Commandline cmd = new Commandline(); 56 57 Path classpath = getCompileClasspath(); 59 60 if (deprecation) { 61 cmd.createArgument().setValue("-deprecation"); 62 } 63 64 if (destDir != null) { 65 cmd.createArgument().setValue("-d"); 66 cmd.createArgument().setFile(destDir); 67 } 68 69 cmd.createArgument().setValue("-classpath"); 71 72 Path cp = new Path(project); 73 74 Path p = getBootClassPath(); 76 if (p.size() > 0) { 77 cp.append(p); 78 } 79 80 if (extdirs != null) { 81 cp.addExtdirs(extdirs); 82 } 83 84 cp.append(classpath); 85 if (compileSourcepath != null) { 86 cp.append(compileSourcepath); 87 } else { 88 cp.append(src); 89 } 90 91 cmd.createArgument().setPath(cp); 92 93 if (encoding != null) { 96 cmd.createArgument().setValue("-encoding"); 97 cmd.createArgument().setValue(encoding); 98 } 99 100 if (debug) { 101 cmd.createArgument().setValue("-g"); 102 } 103 104 if (optimize) { 105 cmd.createArgument().setValue("-O2"); 106 } 107 108 if (verbose) { 109 cmd.createArgument().setValue("-verbose"); 110 } 111 112 addCurrentCompilerArgs(cmd); 113 114 logAndAddFilesToCompile(cmd); 115 return cmd; 116 } 117 } 118 119 120 | Popular Tags |