|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 107-169
Link Here
|
| 107 |
*/ |
107 |
*/ |
| 108 |
cmd.createArgument().setValue("-noExit"); //$NON-NLS-1$ |
108 |
cmd.createArgument().setValue("-noExit"); //$NON-NLS-1$ |
| 109 |
|
109 |
|
| 110 |
if (this.bootclasspath != null) { |
110 |
if (this.bootclasspath != null) { |
| 111 |
cmd.createArgument().setValue("-bootclasspath"); //$NON-NLS-1$ |
111 |
cmd.createArgument().setValue("-bootclasspath"); //$NON-NLS-1$ |
| 112 |
if (this.bootclasspath.size() != 0) { |
112 |
if (this.bootclasspath.size() != 0) { |
| 113 |
/* |
113 |
/* |
| 114 |
* Set the bootclasspath for the Eclipse compiler. |
114 |
* Set the bootclasspath for the Eclipse compiler. |
| 115 |
*/ |
115 |
*/ |
| 116 |
cmd.createArgument().setPath(this.bootclasspath); |
116 |
cmd.createArgument().setPath(this.bootclasspath); |
| 117 |
} else { |
117 |
} else { |
| 118 |
cmd.createArgument().setValue(Util.EMPTY_STRING); |
118 |
cmd.createArgument().setValue(Util.EMPTY_STRING); |
| 119 |
} |
119 |
} |
| 120 |
} |
120 |
} |
| 121 |
|
121 |
|
| 122 |
Path classpath = new Path(this.project); |
122 |
Path classpath = new Path(this.project); |
| 123 |
|
123 |
|
| 124 |
/* |
124 |
/* |
| 125 |
* Eclipse compiler doesn't support -extdirs. |
125 |
* Eclipse compiler doesn't support -extdirs. |
| 126 |
* It is emulated using the classpath. We add extdirs entries after the |
126 |
* It is emulated using the classpath. We add extdirs entries after the |
| 127 |
* bootclasspath. |
127 |
* bootclasspath. |
| 128 |
*/ |
128 |
*/ |
| 129 |
if (this.extdirs != null) { |
129 |
if (this.extdirs != null) { |
| 130 |
cmd.createArgument().setValue("-extdirs"); //$NON-NLS-1$ |
130 |
cmd.createArgument().setValue("-extdirs"); //$NON-NLS-1$ |
| 131 |
cmd.createArgument().setPath(this.extdirs); |
131 |
cmd.createArgument().setPath(this.extdirs); |
| 132 |
} |
132 |
} |
| 133 |
|
133 |
|
| 134 |
/* |
134 |
/* |
| 135 |
* The java runtime is already handled, so we simply want to retrieve the |
135 |
* The java runtime is already handled, so we simply want to retrieve the |
| 136 |
* ant runtime and the compile classpath. |
136 |
* ant runtime and the compile classpath. |
| 137 |
*/ |
137 |
*/ |
| 138 |
classpath.append(getCompileClasspath()); |
138 |
classpath.append(getCompileClasspath()); |
|
|
139 |
|
| 140 |
// For -sourcepath, use the "sourcepath" value if present. |
| 141 |
// Otherwise default to the "srcdir" value. |
| 142 |
Path sourcepath = null; |
| 139 |
|
143 |
|
| 140 |
// For -sourcepath, use the "sourcepath" value if present. |
144 |
// retrieve the method getSourcepath() using reflect |
| 141 |
// Otherwise default to the "srcdir" value. |
145 |
// This is done to improve the compatibility to ant 1.5 |
| 142 |
Path sourcepath = null; |
146 |
Method getSourcepathMethod = null; |
| 143 |
|
147 |
try { |
| 144 |
// retrieve the method getSourcepath() using reflect |
148 |
getSourcepathMethod = javacClass.getMethod("getSourcepath", null); //$NON-NLS-1$ |
| 145 |
// This is done to improve the compatibility to ant 1.5 |
149 |
} catch(NoSuchMethodException e) { |
| 146 |
Method getSourcepathMethod = null; |
150 |
// if not found, then we cannot use this method (ant 1.5) |
| 147 |
try { |
151 |
} |
| 148 |
getSourcepathMethod = javacClass.getMethod("getSourcepath", null); //$NON-NLS-1$ |
152 |
Path compileSourcePath = null; |
| 149 |
} catch(NoSuchMethodException e) { |
153 |
if (getSourcepathMethod != null) { |
| 150 |
// if not found, then we cannot use this method (ant 1.5) |
154 |
try { |
| 151 |
} |
|
|
| 152 |
Path compileSourcePath = null; |
| 153 |
if (getSourcepathMethod != null) { |
| 154 |
try { |
| 155 |
compileSourcePath = (Path) getSourcepathMethod.invoke(this.attributes, null); |
155 |
compileSourcePath = (Path) getSourcepathMethod.invoke(this.attributes, null); |
| 156 |
} catch (IllegalAccessException e) { |
156 |
} catch (IllegalAccessException e) { |
| 157 |
// should never happen |
157 |
// should never happen |
| 158 |
} catch (InvocationTargetException e) { |
158 |
} catch (InvocationTargetException e) { |
| 159 |
// should never happen |
159 |
// should never happen |
| 160 |
} |
160 |
} |
| 161 |
} |
161 |
} |
| 162 |
if (compileSourcePath != null) { |
162 |
if (compileSourcePath != null) { |
| 163 |
sourcepath = compileSourcePath; |
163 |
sourcepath = compileSourcePath; |
| 164 |
} else { |
164 |
} else { |
| 165 |
sourcepath = this.src; |
165 |
sourcepath = this.src; |
| 166 |
} |
166 |
} |
| 167 |
classpath.append(sourcepath); |
167 |
classpath.append(sourcepath); |
| 168 |
/* |
168 |
/* |
| 169 |
* Set the classpath for the Eclipse compiler. |
169 |
* Set the classpath for the Eclipse compiler. |
|
Lines 171-208
Link Here
|
| 171 |
cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$ |
171 |
cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$ |
| 172 |
createClasspathArgument(cmd, classpath); |
172 |
createClasspathArgument(cmd, classpath); |
| 173 |
|
173 |
|
| 174 |
final String javaVersion = JavaEnvUtils.getJavaVersion(); |
174 |
final String javaVersion = JavaEnvUtils.getJavaVersion(); |
| 175 |
String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$ |
175 |
String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$ |
| 176 |
if (this.memoryInitialSize != null) { |
176 |
if (this.memoryInitialSize != null) { |
| 177 |
if (!this.attributes.isForkedJavac()) { |
177 |
if (!this.attributes.isForkedJavac()) { |
| 178 |
this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryInitialSize"), Project.MSG_WARN); //$NON-NLS-1$ |
178 |
this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryInitialSize"), Project.MSG_WARN); //$NON-NLS-1$ |
| 179 |
} else { |
179 |
} else { |
| 180 |
cmd.createArgument().setValue(memoryParameterPrefix |
180 |
cmd.createArgument().setValue(memoryParameterPrefix |
| 181 |
+ "ms" + this.memoryInitialSize); //$NON-NLS-1$ |
181 |
+ "ms" + this.memoryInitialSize); //$NON-NLS-1$ |
| 182 |
} |
182 |
} |
| 183 |
} |
183 |
} |
| 184 |
|
184 |
|
| 185 |
if (this.memoryMaximumSize != null) { |
185 |
if (this.memoryMaximumSize != null) { |
| 186 |
if (!this.attributes.isForkedJavac()) { |
186 |
if (!this.attributes.isForkedJavac()) { |
| 187 |
this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryMaximumSize"), Project.MSG_WARN); //$NON-NLS-1$ |
187 |
this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryMaximumSize"), Project.MSG_WARN); //$NON-NLS-1$ |
| 188 |
} else { |
188 |
} else { |
| 189 |
cmd.createArgument().setValue(memoryParameterPrefix |
189 |
cmd.createArgument().setValue(memoryParameterPrefix |
| 190 |
+ "mx" + this.memoryMaximumSize); //$NON-NLS-1$ |
190 |
+ "mx" + this.memoryMaximumSize); //$NON-NLS-1$ |
| 191 |
} |
191 |
} |
| 192 |
} |
192 |
} |
| 193 |
|
193 |
|
| 194 |
if (this.debug) { |
194 |
if (this.debug) { |
| 195 |
// retrieve the method getSourcepath() using reflect |
195 |
// retrieve the method getSourcepath() using reflect |
| 196 |
// This is done to improve the compatibility to ant 1.5 |
196 |
// This is done to improve the compatibility to ant 1.5 |
| 197 |
Method getDebugLevelMethod = null; |
197 |
Method getDebugLevelMethod = null; |
| 198 |
try { |
198 |
try { |
| 199 |
getDebugLevelMethod = javacClass.getMethod("getDebugLevel", null); //$NON-NLS-1$ |
199 |
getDebugLevelMethod = javacClass.getMethod("getDebugLevel", null); //$NON-NLS-1$ |
| 200 |
} catch(NoSuchMethodException e) { |
200 |
} catch(NoSuchMethodException e) { |
| 201 |
// if not found, then we cannot use this method (ant 1.5) |
201 |
// if not found, then we cannot use this method (ant 1.5) |
| 202 |
// debug level is only available with ant 1.5.x |
202 |
// debug level is only available with ant 1.5.x |
| 203 |
} |
203 |
} |
| 204 |
String debugLevel = null; |
204 |
String debugLevel = null; |
| 205 |
if (getDebugLevelMethod != null) { |
205 |
if (getDebugLevelMethod != null) { |
| 206 |
try { |
206 |
try { |
| 207 |
debugLevel = (String) getDebugLevelMethod.invoke(this.attributes, null); |
207 |
debugLevel = (String) getDebugLevelMethod.invoke(this.attributes, null); |
| 208 |
} catch (IllegalAccessException e) { |
208 |
} catch (IllegalAccessException e) { |
|
Lines 210-216
Link Here
|
| 210 |
} catch (InvocationTargetException e) { |
210 |
} catch (InvocationTargetException e) { |
| 211 |
// should never happen |
211 |
// should never happen |
| 212 |
} |
212 |
} |
| 213 |
} |
213 |
} |
| 214 |
if (debugLevel != null) { |
214 |
if (debugLevel != null) { |
| 215 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); |
215 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); |
| 216 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); |
216 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); |
|
Lines 230-247
Link Here
|
| 230 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); |
230 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); |
| 231 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); |
231 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); |
| 232 |
this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.GENERATE); |
232 |
this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.GENERATE); |
| 233 |
} |
233 |
} |
| 234 |
} else { |
234 |
} else { |
| 235 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); |
235 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); |
| 236 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); |
236 |
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); |
| 237 |
this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.DO_NOT_GENERATE); |
237 |
this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.DO_NOT_GENERATE); |
| 238 |
} |
238 |
} |
| 239 |
|
239 |
|
| 240 |
/* |
240 |
/* |
| 241 |
* Handle the nowarn option. If none, then we generate all warnings. |
241 |
* Handle the nowarn option. If none, then we generate all warnings. |
| 242 |
*/ |
242 |
*/ |
| 243 |
if (this.attributes.getNowarn()) { |
243 |
if (this.attributes.getNowarn()) { |
| 244 |
// disable all warnings |
244 |
// disable all warnings |
| 245 |
Object[] entries = this.customDefaultOptions.entrySet().toArray(); |
245 |
Object[] entries = this.customDefaultOptions.entrySet().toArray(); |
| 246 |
for (int i = 0, max = entries.length; i < max; i++) { |
246 |
for (int i = 0, max = entries.length; i < max; i++) { |
| 247 |
Map.Entry entry = (Map.Entry) entries[i]; |
247 |
Map.Entry entry = (Map.Entry) entries[i]; |
|
Lines 269-275
Link Here
|
| 269 |
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED); |
269 |
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED); |
| 270 |
} |
270 |
} |
| 271 |
|
271 |
|
| 272 |
/* |
272 |
/* |
| 273 |
* destDir option. |
273 |
* destDir option. |
| 274 |
*/ |
274 |
*/ |
| 275 |
if (this.destDir != null) { |
275 |
if (this.destDir != null) { |
|
Lines 302-321
Link Here
|
| 302 |
* source option |
302 |
* source option |
| 303 |
*/ |
303 |
*/ |
| 304 |
String source = this.attributes.getSource(); |
304 |
String source = this.attributes.getSource(); |
| 305 |
if (source != null) { |
305 |
if (source != null) { |
| 306 |
this.customDefaultOptions.put(CompilerOptions.OPTION_Source, source); |
306 |
this.customDefaultOptions.put(CompilerOptions.OPTION_Source, source); |
| 307 |
} |
307 |
} |
| 308 |
|
|
|
| 309 |
/* |
| 310 |
* encoding option |
| 311 |
*/ |
| 312 |
if (this.encoding != null) { |
| 313 |
cmd.createArgument().setValue("-encoding"); //$NON-NLS-1$ |
| 314 |
cmd.createArgument().setValue(this.encoding); |
| 315 |
} |
| 316 |
|
308 |
|
| 317 |
if (compilerArgs != null) { |
309 |
if (compilerArgs != null) { |
| 318 |
/* |
310 |
/* |
| 319 |
* Add extra argument on the command line |
311 |
* Add extra argument on the command line |
| 320 |
*/ |
312 |
*/ |
| 321 |
final int length = compilerArgs.length; |
313 |
final int length = compilerArgs.length; |
|
Lines 325-341
Link Here
|
| 325 |
if (this.logFileName == null && "-log".equals(arg) && ((i + 1) < max)) { //$NON-NLS-1$ |
317 |
if (this.logFileName == null && "-log".equals(arg) && ((i + 1) < max)) { //$NON-NLS-1$ |
| 326 |
this.logFileName = compilerArgs[i + 1]; |
318 |
this.logFileName = compilerArgs[i + 1]; |
| 327 |
} |
319 |
} |
| 328 |
cmd.createArgument().setValue(arg); |
320 |
cmd.createArgument().setValue(arg); |
| 329 |
} |
321 |
} |
| 330 |
} |
322 |
} |
| 331 |
} |
323 |
} |
| 332 |
/* |
324 |
/* |
|
|
325 |
* encoding option. javac task encoding property must be the last encoding on the command |
| 326 |
* line as compiler arg might also specify an encoding. |
| 327 |
*/ |
| 328 |
if (this.encoding != null) { |
| 329 |
cmd.createArgument().setValue("-encoding"); //$NON-NLS-1$ |
| 330 |
cmd.createArgument().setValue(this.encoding); |
| 331 |
} |
| 332 |
|
| 333 |
/* |
| 333 |
* Eclipse compiler doesn't have a -sourcepath option. This is |
334 |
* Eclipse compiler doesn't have a -sourcepath option. This is |
| 334 |
* handled through the javac task that collects all source files in |
335 |
* handled through the javac task that collects all source files in |
| 335 |
* srcdir option. |
336 |
* srcdir option. |
| 336 |
*/ |
337 |
*/ |
| 337 |
logAndAddFilesToCompile(cmd); |
338 |
logAndAddFilesToCompile(cmd); |
| 338 |
return cmd; |
339 |
return cmd; |
| 339 |
} |
340 |
} |
| 340 |
|
341 |
|
| 341 |
/** |
342 |
/** |