mirror of https://github.com/sbt/sbt.git
Don't pass `-J<flag>` option to local Java compiler
These options can only be given to a forked Java compiler. If we run a local java compiler, we filter these options out and emit a warning. Fixes sbt/sbt#1968
This commit is contained in:
parent
33478132c5
commit
7af0fea54e
|
|
@ -66,6 +66,14 @@ final class LocalJavaCompiler(compiler: javax.tools.JavaCompiler) extends JavaCo
|
|||
val diagnostics = new DiagnosticsReporter(reporter)
|
||||
val fileManager = compiler.getStandardFileManager(diagnostics, null, null)
|
||||
val jfiles = fileManager.getJavaFileObjectsFromFiles(sources.asJava)
|
||||
compiler.getTask(logWriter, fileManager, diagnostics, options.asJava, null, jfiles).call()
|
||||
|
||||
// Local Java compiler doesn't accept `-J<flag>` options. We emit a warning if we find
|
||||
// such options and don't pass them to the compiler.
|
||||
val (invalidOptions, cleanedOptions) = options partition (_ startsWith "-J")
|
||||
if (invalidOptions.nonEmpty) {
|
||||
log.warn("Javac is running in 'local' mode. These flags have been removed:")
|
||||
log.warn(invalidOptions.mkString("\t", ", ", ""))
|
||||
}
|
||||
compiler.getTask(logWriter, fileManager, diagnostics, cleanedOptions.asJava, null, jfiles).call()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue