| @@ -259,16 +259,17 @@ private String getOutOfProcessJavacVersion(String executable) throws CompilerExc |
|
|
| 259 |
259 |
*/ |
| 260 |
260 |
cli.addArguments(new String[] {"-version"}); // |
| 261 |
261 |
CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); |
|
262 |
+CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); |
| 262 |
263 |
try { |
| 263 |
|
-int exitCode = CommandLineUtils.executeCommandLine(cli, out, out); |
|
264 |
+int exitCode = CommandLineUtils.executeCommandLine(cli, out, err); |
| 264 |
265 |
if (exitCode != 0) { |
| 265 |
266 |
throw new CompilerException("Could not retrieve version from " + executable + ". Exit code " |
| 266 |
|
- + exitCode + ", Output: " + out.getOutput()); |
|
267 |
+ + exitCode + ", Output: " + out.getOutput() + ", Error: " + err.getOutput()); |
| 267 |
268 |
} |
| 268 |
269 |
} catch (CommandLineException e) { |
| 269 |
270 |
throw new CompilerException("Error while executing the external compiler " + executable, e); |
| 270 |
271 |
} |
| 271 |
|
-version = extractMajorAndMinorVersion(out.getOutput()); |
|
272 |
+version = tryParseVersion(out.getOutput().trim()); |
| 272 |
273 |
VERSION_PER_EXECUTABLE.put(executable, version); |
| 273 |
274 |
} |
| 274 |
275 |
return version; |
| @@ -282,6 +283,19 @@ static String extractMajorAndMinorVersion(String text) { |
|
|
| 282 |
283 |
return matcher.group(); |
| 283 |
284 |
} |
| 284 |
285 |
|
|
286 |
+private String tryParseVersion(String version) { |
|
287 |
+if (version.startsWith("javac ")) { |
|
288 |
+version = version.substring(6); |
|
289 |
+if (version.startsWith("1.")) { |
|
290 |
+version = version.substring(0, 3); |
|
291 |
+ } else { |
|
292 |
+version = version.substring(0, 2); |
|
293 |
+ } |
|
294 |
+return version; |
|
295 |
+ } |
|
296 |
+return null; |
|
297 |
+ } |
|
298 |
+ |
| 285 |
299 |
@Override |
| 286 |
300 |
public CompilerResult performCompile(CompilerConfiguration config) throws CompilerException { |
| 287 |
301 |
File destinationDir = new File(config.getOutputLocation()); |