diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index 84c75152714..81a2301ec1e 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -732,13 +732,15 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { assertFilesExistInOutput(module, "foo/Bar.class") val buildResult = BuildResult() - val canceledStatus = object: CanceledStatus { + val canceledStatus = object : CanceledStatus { var checkFromIndex = 0 override fun isCanceled(): Boolean { val messages = buildResult.getMessages(BuildMessage.Kind.INFO) for (i in checkFromIndex..messages.size - 1) { - if (messages.get(i).messageText.startsWith("Kotlin JPS plugin version")) return true + if (messages[i].messageText.matches("kotlinc-jvm .+ \\(JRE .+\\)".toRegex())) { + return true + } } checkFromIndex = messages.size @@ -749,8 +751,6 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { touch("src/Bar.kt").apply() buildCustom(canceledStatus, TestProjectBuilderLogger(), buildResult) assertCanceled(buildResult) - - assertFilesNotExistInOutput(module, "foo/Bar.class") } fun testFileDoesNotExistWarning() { diff --git a/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt b/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt index 73f16541511..4d9f6be7c37 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt @@ -21,7 +21,6 @@ import org.jetbrains.jps.api.GlobalOptions import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY import org.jetbrains.kotlin.cli.common.arguments.* -import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.config.CompilerSettings import org.jetbrains.kotlin.config.additionalArgumentsAsList import org.jetbrains.kotlin.daemon.client.CompileServiceSession @@ -104,7 +103,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner() { compilerArgs: CommonCompilerArguments, environment: JpsCompilerEnvironment ): ExitCode { - environment.messageCollector.report(CompilerMessageSeverity.INFO, "Using kotlin-home = " + environment.kotlinPaths.homePath) + log.debug("Using kotlin-home = " + environment.kotlinPaths.homePath) return if (isDaemonEnabled()) { val daemonExitCode = compileWithDaemon(compilerClassName, compilerArgs, environment) diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt index 7a58d5feaaa..3cbcb30005c 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -230,7 +230,9 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { return NOTHING_DONE } - messageCollector.report(INFO, "Kotlin JPS plugin version " + KotlinCompilerVersion.VERSION) + messageCollector.report( + INFO, "Kotlin version " + KotlinCompilerVersion.VERSION + " (JRE " + System.getProperty("java.runtime.version") + ")" + ) val targetsWithoutOutputDir = targets.filter { it.outputDir == null } if (targetsWithoutOutputDir.isNotEmpty()) { @@ -258,7 +260,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { val start = System.nanoTime() val outputItemCollector = doCompileModuleChunk(allCompiledFiles, chunk, commonArguments, context, dirtyFilesHolder, - environment, filesToCompile, incrementalCaches, messageCollector, project) + environment, filesToCompile, incrementalCaches, project) statisticsLogger.registerStatistic(chunk, System.nanoTime() - start) @@ -416,7 +418,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { allCompiledFiles: MutableSet, chunk: ModuleChunk, commonArguments: CommonCompilerArguments, context: CompileContext, dirtyFilesHolder: DirtyFilesHolder, environment: JpsCompilerEnvironment, filesToCompile: MultiMap, incrementalCaches: Map>, - messageCollector: MessageCollectorAdapter, project: JpsProject + project: JpsProject ): OutputItemsCollector? { if (JpsUtils.isJsKotlinModule(chunk.representativeTarget())) { @@ -434,7 +436,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { val representativeTarget = chunk.representativeTarget() - fun concatenate(strings: Array?, cp: List) = arrayOf(*(strings ?: emptyArray()), *cp.toTypedArray()) + fun concatenate(strings: Array?, cp: List) = arrayOf(*strings.orEmpty(), *cp.toTypedArray()) for (argumentProvider in ServiceLoader.load(KotlinJpsCompilerArgumentsProvider::class.java)) { // appending to pluginOptions @@ -444,7 +446,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { commonArguments.pluginClasspaths = concatenate(commonArguments.pluginClasspaths, argumentProvider.getClasspath(representativeTarget, context)) - messageCollector.report(INFO, "Plugin loaded: ${argumentProvider::class.java.simpleName}") + LOG.debug("Plugin loaded: ${argumentProvider::class.java.simpleName}") } return compileToJvm(allCompiledFiles, chunk, commonArguments, context, dirtyFilesHolder, environment, filesToCompile) @@ -742,15 +744,22 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { if (severity == EXCEPTION) { prefix = INTERNAL_ERROR_PREFIX } - context.processMessage(CompilerMessage( - CompilerRunnerConstants.KOTLIN_COMPILER_NAME, - kind(severity), - prefix + message, - location?.path, - -1, -1, -1, - location?.line?.toLong() ?: -1, - location?.column?.toLong() ?: -1 - )) + val kind = kind(severity) + if (kind != null) { + context.processMessage(CompilerMessage( + CompilerRunnerConstants.KOTLIN_COMPILER_NAME, + kind, + prefix + message, + location?.path, + -1, -1, -1, + location?.line?.toLong() ?: -1, + location?.column?.toLong() ?: -1 + )) + } + else { + val path = if (location != null) "${location.path}:${location.line}:${location.column}: " else "" + KotlinBuilder.LOG.debug(path + message) + } } override fun clear() { @@ -759,12 +768,12 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { override fun hasErrors(): Boolean = hasErrors - private fun kind(severity: CompilerMessageSeverity): BuildMessage.Kind { + private fun kind(severity: CompilerMessageSeverity): BuildMessage.Kind? { return when (severity) { INFO -> BuildMessage.Kind.INFO ERROR, EXCEPTION -> BuildMessage.Kind.ERROR WARNING, STRONG_WARNING -> BuildMessage.Kind.WARNING - LOGGING -> BuildMessage.Kind.PROGRESS + LOGGING -> null else -> throw IllegalArgumentException("Unsupported severity: " + severity) } }