Permalink
Browse files

Explicitly add common Javac options in CompilationData #SCL-6043

  • Loading branch information...
pavelfatin committed Sep 5, 2013
1 parent 4e6688a commit c481563518407dc718a45702d2d167ec3e65cc59
Showing with 31 additions and 3 deletions.
  1. +31 −3 jps-plugin/src/org/jetbrains/jps/incremental/scala/data/CompilationData.scala
@@ -10,6 +10,7 @@ import collection.JavaConverters._
import org.jetbrains.jps.incremental.scala.model.Order
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType
import org.jetbrains.jps.model.java.JpsJavaExtensionService
+import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions
import java.util
import java.util.Collections
@@ -63,18 +64,45 @@ object CompilationData {
}
private def javaOptionsFor(context: CompileContext, chunk: ModuleChunk): Seq[String] = {
- val annotationProcessingProfile = {
+ val compilerConfig = {
val project = context.getProjectDescriptor.getProject
- val compilerConfig = JpsJavaExtensionService.getInstance.getOrCreateCompilerConfiguration(project)
+ JpsJavaExtensionService.getInstance.getOrCreateCompilerConfiguration(project)
+ }
+
+ val options = new util.ArrayList[String]()
+
+ addCommonJavacOptions(options, compilerConfig.getCurrentCompilerOptions)
+
+ val annotationProcessingProfile = {
val module = chunk.representativeTarget.getModule
compilerConfig.getAnnotationProcessingProfile(module)
}
- val options = new util.ArrayList[String]()
JavaBuilder.addCompilationOptions(options, context, chunk, annotationProcessingProfile)
+
options.asScala
}
+ // TODO JavaBuilder.loadCommonJavacOptions should be public
+ def addCommonJavacOptions(options: util.ArrayList[String], compilerOptions: JpsJavaCompilerOptions) {
+ if (compilerOptions.DEBUGGING_INFO) {
+ options.add("-g")
+ }
+
+ if (compilerOptions.DEPRECATION) {
+ options.add("-deprecation")
+ }
+
+ if (compilerOptions.GENERATE_NO_WARNINGS) {
+ options.add("-nowarn")
+ }
+
+ if (!compilerOptions.ADDITIONAL_OPTIONS_STRING.isEmpty) {
+ // TODO extract VM options
+ options.addAll(compilerOptions.ADDITIONAL_OPTIONS_STRING.split("\\s+").toSeq.asJava)
+ }
+ }
+
private def createOutputToCacheMap(context: CompileContext): Either[String, Map[File, File]] = {
val targetToOutput = targetsIn(context).map(target => (target, target.getOutputDir))

0 comments on commit c481563

Please sign in to comment.