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.types.Commandline; 24 import org.apache.tools.ant.types.Path; 25 26 33 public class Jikes extends DefaultCompilerAdapter { 34 35 47 public boolean execute() throws BuildException { 48 attributes.log("Using jikes compiler", Project.MSG_VERBOSE); 49 50 Commandline cmd = new Commandline(); 51 52 Path sourcepath = null; 55 if (compileSourcepath != null) { 56 sourcepath = compileSourcepath; 57 } else { 58 sourcepath = src; 59 } 60 if (sourcepath.size() > 0) { 63 cmd.createArgument().setValue("-sourcepath"); 64 cmd.createArgument().setPath(sourcepath); 65 } 66 67 Path classpath = new Path(project); 68 69 if (bootclasspath == null || bootclasspath.size() == 0) { 70 includeJavaRuntime = true; 72 } else { 73 } 78 classpath.append(getCompileClasspath()); 79 80 String jikesPath = System.getProperty("jikes.class.path"); 82 if (jikesPath != null) { 83 classpath.append(new Path(project, jikesPath)); 84 } 85 86 if (extdirs != null && extdirs.size() > 0) { 87 cmd.createArgument().setValue("-extdirs"); 88 cmd.createArgument().setPath(extdirs); 89 } 90 91 String exec = getJavac().getExecutable(); 92 cmd.setExecutable(exec == null ? "jikes" : exec); 93 94 if (deprecation) { 95 cmd.createArgument().setValue("-deprecation"); 96 } 97 98 if (destDir != null) { 99 cmd.createArgument().setValue("-d"); 100 cmd.createArgument().setFile(destDir); 101 } 102 103 cmd.createArgument().setValue("-classpath"); 104 cmd.createArgument().setPath(classpath); 105 106 if (encoding != null) { 107 cmd.createArgument().setValue("-encoding"); 108 cmd.createArgument().setValue(encoding); 109 } 110 if (debug) { 111 String debugLevel = attributes.getDebugLevel(); 112 if (debugLevel != null) { 113 cmd.createArgument().setValue("-g:" + debugLevel); 114 } else { 115 cmd.createArgument().setValue("-g"); 116 } 117 } else { 118 cmd.createArgument().setValue("-g:none"); 119 } 120 if (optimize) { 121 cmd.createArgument().setValue("-O"); 122 } 123 if (verbose) { 124 cmd.createArgument().setValue("-verbose"); 125 } 126 if (depend) { 127 cmd.createArgument().setValue("-depend"); 128 } 129 130 if (target != null) { 131 cmd.createArgument().setValue("-target"); 132 cmd.createArgument().setValue(target); 133 } 134 135 141 142 148 String emacsProperty = project.getProperty("build.compiler.emacs"); 149 if (emacsProperty != null && Project.toBoolean(emacsProperty)) { 150 cmd.createArgument().setValue("+E"); 151 } 152 153 159 String warningsProperty = 160 project.getProperty("build.compiler.warnings"); 161 if (warningsProperty != null) { 162 attributes.log("!! the build.compiler.warnings property is " 163 + "deprecated. !!", Project.MSG_WARN); 164 attributes.log("!! Use the nowarn attribute instead. !!", 165 Project.MSG_WARN); 166 if (!Project.toBoolean(warningsProperty)) { 167 cmd.createArgument().setValue("-nowarn"); 168 } 169 } 170 if (attributes.getNowarn()) { 171 cmd.createArgument().setValue("-nowarn"); 172 } 173 174 177 String pedanticProperty = 178 project.getProperty("build.compiler.pedantic"); 179 if (pedanticProperty != null && Project.toBoolean(pedanticProperty)) { 180 cmd.createArgument().setValue("+P"); 181 } 182 183 188 String fullDependProperty = 189 project.getProperty("build.compiler.fulldepend"); 190 if (fullDependProperty != null 191 && Project.toBoolean(fullDependProperty)) { 192 cmd.createArgument().setValue("+F"); 193 } 194 195 if (attributes.getSource() != null) { 196 cmd.createArgument().setValue("-source"); 197 String source = attributes.getSource(); 198 if (source.equals("1.1") || source.equals("1.2")) { 199 attributes.log("Jikes doesn't support '-source " 202 + source + "', will use '-source 1.3' instead"); 203 cmd.createArgument().setValue("1.3"); 204 } else { 205 cmd.createArgument().setValue(source); 206 } 207 } 208 209 addCurrentCompilerArgs(cmd); 210 211 int firstFileName = cmd.size(); 212 213 Path boot = getBootClassPath(); 214 if (boot.size() > 0) { 215 cmd.createArgument().setValue("-bootclasspath"); 216 cmd.createArgument().setPath(boot); 217 } 218 219 logAndAddFilesToCompile(cmd); 220 221 return 222 executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; 223 } 224 225 226 } 227 | Popular Tags |