Improve messages printed by JPS plugin in Messages view
- Don't print "Loaded plugin: KotlinAndroidJpsPlugin" and "Using kotlin-home = ..." for every build. They are rarely useful; they can be found in the build log now - Instead of potentially confusing for the user "Kotlin JPS plugin version ..." output simply "Kotlin version ...". Also add the version of the JRE, where the compiler is being run - Do not treat messages reported with severity LOGGING as BuildMessage with kind PROGRESS. Such build messages are displayed to the user in the progress/status bar when IDEA Make process is running, but LOGGING messages never had this meaning. In particular, users could be confused by the progress bar message "Kotlin: Configuring the compilation environment" visible for a very long time during compilation. This message just happens to be the last LOGGING message reported by the compiler before the actual compilation; its presence there created an illusion that Kotlin spends most of the time configuring the compilation environment #KT-17387 Fixed
This commit is contained in:
@@ -732,13 +732,15 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
assertFilesExistInOutput(module, "foo/Bar.class")
|
assertFilesExistInOutput(module, "foo/Bar.class")
|
||||||
|
|
||||||
val buildResult = BuildResult()
|
val buildResult = BuildResult()
|
||||||
val canceledStatus = object: CanceledStatus {
|
val canceledStatus = object : CanceledStatus {
|
||||||
var checkFromIndex = 0
|
var checkFromIndex = 0
|
||||||
|
|
||||||
override fun isCanceled(): Boolean {
|
override fun isCanceled(): Boolean {
|
||||||
val messages = buildResult.getMessages(BuildMessage.Kind.INFO)
|
val messages = buildResult.getMessages(BuildMessage.Kind.INFO)
|
||||||
for (i in checkFromIndex..messages.size - 1) {
|
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
|
checkFromIndex = messages.size
|
||||||
@@ -749,8 +751,6 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
touch("src/Bar.kt").apply()
|
touch("src/Bar.kt").apply()
|
||||||
buildCustom(canceledStatus, TestProjectBuilderLogger(), buildResult)
|
buildCustom(canceledStatus, TestProjectBuilderLogger(), buildResult)
|
||||||
assertCanceled(buildResult)
|
assertCanceled(buildResult)
|
||||||
|
|
||||||
assertFilesNotExistInOutput(module, "foo/Bar.class")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testFileDoesNotExistWarning() {
|
fun testFileDoesNotExistWarning() {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import org.jetbrains.jps.api.GlobalOptions
|
|||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||||
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
|
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
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.CompilerSettings
|
||||||
import org.jetbrains.kotlin.config.additionalArgumentsAsList
|
import org.jetbrains.kotlin.config.additionalArgumentsAsList
|
||||||
import org.jetbrains.kotlin.daemon.client.CompileServiceSession
|
import org.jetbrains.kotlin.daemon.client.CompileServiceSession
|
||||||
@@ -104,7 +103,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
compilerArgs: CommonCompilerArguments,
|
compilerArgs: CommonCompilerArguments,
|
||||||
environment: JpsCompilerEnvironment
|
environment: JpsCompilerEnvironment
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
environment.messageCollector.report(CompilerMessageSeverity.INFO, "Using kotlin-home = " + environment.kotlinPaths.homePath)
|
log.debug("Using kotlin-home = " + environment.kotlinPaths.homePath)
|
||||||
|
|
||||||
return if (isDaemonEnabled()) {
|
return if (isDaemonEnabled()) {
|
||||||
val daemonExitCode = compileWithDaemon(compilerClassName, compilerArgs, environment)
|
val daemonExitCode = compileWithDaemon(compilerClassName, compilerArgs, environment)
|
||||||
|
|||||||
@@ -230,7 +230,9 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
return NOTHING_DONE
|
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 }
|
val targetsWithoutOutputDir = targets.filter { it.outputDir == null }
|
||||||
if (targetsWithoutOutputDir.isNotEmpty()) {
|
if (targetsWithoutOutputDir.isNotEmpty()) {
|
||||||
@@ -258,7 +260,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
|
|
||||||
val start = System.nanoTime()
|
val start = System.nanoTime()
|
||||||
val outputItemCollector = doCompileModuleChunk(allCompiledFiles, chunk, commonArguments, context, dirtyFilesHolder,
|
val outputItemCollector = doCompileModuleChunk(allCompiledFiles, chunk, commonArguments, context, dirtyFilesHolder,
|
||||||
environment, filesToCompile, incrementalCaches, messageCollector, project)
|
environment, filesToCompile, incrementalCaches, project)
|
||||||
|
|
||||||
statisticsLogger.registerStatistic(chunk, System.nanoTime() - start)
|
statisticsLogger.registerStatistic(chunk, System.nanoTime() - start)
|
||||||
|
|
||||||
@@ -416,7 +418,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
allCompiledFiles: MutableSet<File>, chunk: ModuleChunk, commonArguments: CommonCompilerArguments, context: CompileContext,
|
allCompiledFiles: MutableSet<File>, chunk: ModuleChunk, commonArguments: CommonCompilerArguments, context: CompileContext,
|
||||||
dirtyFilesHolder: DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget>, environment: JpsCompilerEnvironment,
|
dirtyFilesHolder: DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget>, environment: JpsCompilerEnvironment,
|
||||||
filesToCompile: MultiMap<ModuleBuildTarget, File>, incrementalCaches: Map<ModuleBuildTarget, IncrementalCacheImpl<*>>,
|
filesToCompile: MultiMap<ModuleBuildTarget, File>, incrementalCaches: Map<ModuleBuildTarget, IncrementalCacheImpl<*>>,
|
||||||
messageCollector: MessageCollectorAdapter, project: JpsProject
|
project: JpsProject
|
||||||
): OutputItemsCollector? {
|
): OutputItemsCollector? {
|
||||||
|
|
||||||
if (JpsUtils.isJsKotlinModule(chunk.representativeTarget())) {
|
if (JpsUtils.isJsKotlinModule(chunk.representativeTarget())) {
|
||||||
@@ -434,7 +436,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
|
|
||||||
val representativeTarget = chunk.representativeTarget()
|
val representativeTarget = chunk.representativeTarget()
|
||||||
|
|
||||||
fun concatenate(strings: Array<String>?, cp: List<String>) = arrayOf(*(strings ?: emptyArray()), *cp.toTypedArray())
|
fun concatenate(strings: Array<String>?, cp: List<String>) = arrayOf(*strings.orEmpty(), *cp.toTypedArray())
|
||||||
|
|
||||||
for (argumentProvider in ServiceLoader.load(KotlinJpsCompilerArgumentsProvider::class.java)) {
|
for (argumentProvider in ServiceLoader.load(KotlinJpsCompilerArgumentsProvider::class.java)) {
|
||||||
// appending to pluginOptions
|
// appending to pluginOptions
|
||||||
@@ -444,7 +446,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
commonArguments.pluginClasspaths = concatenate(commonArguments.pluginClasspaths,
|
commonArguments.pluginClasspaths = concatenate(commonArguments.pluginClasspaths,
|
||||||
argumentProvider.getClasspath(representativeTarget, context))
|
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)
|
return compileToJvm(allCompiledFiles, chunk, commonArguments, context, dirtyFilesHolder, environment, filesToCompile)
|
||||||
@@ -742,15 +744,22 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
if (severity == EXCEPTION) {
|
if (severity == EXCEPTION) {
|
||||||
prefix = INTERNAL_ERROR_PREFIX
|
prefix = INTERNAL_ERROR_PREFIX
|
||||||
}
|
}
|
||||||
context.processMessage(CompilerMessage(
|
val kind = kind(severity)
|
||||||
CompilerRunnerConstants.KOTLIN_COMPILER_NAME,
|
if (kind != null) {
|
||||||
kind(severity),
|
context.processMessage(CompilerMessage(
|
||||||
prefix + message,
|
CompilerRunnerConstants.KOTLIN_COMPILER_NAME,
|
||||||
location?.path,
|
kind,
|
||||||
-1, -1, -1,
|
prefix + message,
|
||||||
location?.line?.toLong() ?: -1,
|
location?.path,
|
||||||
location?.column?.toLong() ?: -1
|
-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() {
|
override fun clear() {
|
||||||
@@ -759,12 +768,12 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
|
|
||||||
override fun hasErrors(): Boolean = hasErrors
|
override fun hasErrors(): Boolean = hasErrors
|
||||||
|
|
||||||
private fun kind(severity: CompilerMessageSeverity): BuildMessage.Kind {
|
private fun kind(severity: CompilerMessageSeverity): BuildMessage.Kind? {
|
||||||
return when (severity) {
|
return when (severity) {
|
||||||
INFO -> BuildMessage.Kind.INFO
|
INFO -> BuildMessage.Kind.INFO
|
||||||
ERROR, EXCEPTION -> BuildMessage.Kind.ERROR
|
ERROR, EXCEPTION -> BuildMessage.Kind.ERROR
|
||||||
WARNING, STRONG_WARNING -> BuildMessage.Kind.WARNING
|
WARNING, STRONG_WARNING -> BuildMessage.Kind.WARNING
|
||||||
LOGGING -> BuildMessage.Kind.PROGRESS
|
LOGGING -> null
|
||||||
else -> throw IllegalArgumentException("Unsupported severity: " + severity)
|
else -> throw IllegalArgumentException("Unsupported severity: " + severity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user