diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JoinToReadableStringTest.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JoinToReadableStringTest.kt new file mode 100644 index 00000000000..aca4447b45a --- /dev/null +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/JoinToReadableStringTest.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.testFramework.UsefulTestCase + +class JoinToReadableStringTest : UsefulTestCase() { + fun test0() { + assertEquals( + "", + listOf().joinToReadableString() + ) + } + + fun test1() { + assertEquals( + "a", + listOf("a").joinToReadableString() + ) + } + + fun test2() { + assertEquals( + "a and b", + listOf("a", "b").joinToReadableString() + ) + } + + fun test3() { + assertEquals( + "a, b and c", + listOf("a", "b", "c").joinToReadableString() + ) + } + + fun test4() { + assertEquals( + "a, b, c and d", + listOf("a", "b", "c", "d").joinToReadableString() + ) + } + + fun test5() { + assertEquals( + "a, b, c, d and e", + listOf("a", "b", "c", "d", "e").joinToReadableString() + ) + } + + fun test6() { + assertEquals( + "a, b, c, d, e and 1 more", + listOf("a", "b", "c", "d", "e", "f").joinToReadableString() + ) + } +} \ No newline at end of file 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 2a2fd5374c3..93b15883f54 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -143,6 +143,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { } kotlinContext.cleanupCaches() + kotlinContext.reportUnsupportedTargets() } LOG.info("Total Kotlin global compile context initialization time: $time ms") @@ -344,16 +345,6 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { return ABORT } - if (representativeTarget is KotlinUnsupportedModuleBuildTarget) { - val msg = "${representativeTarget.kind} is not yet supported in IDEA internal build system. " + - "Please use Gradle to build ${kotlinChunk.presentableShortName}." - - kotlinContext.testingLogger?.addCustomMessage(msg) - messageCollector.report(STRONG_WARNING, msg) - - return NOTHING_DONE - } - if (!kotlinChunk.isEnabled) { return NOTHING_DONE } diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt index c70eccb5ba9..5d1446d52a3 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinCompileContext.kt @@ -12,10 +12,12 @@ import org.jetbrains.jps.incremental.GlobalContextKey import org.jetbrains.jps.incremental.fs.CompilationRound import org.jetbrains.jps.incremental.messages.BuildMessage import org.jetbrains.jps.incremental.messages.CompilerMessage +import org.jetbrains.kotlin.config.CompilerRunnerConstants import org.jetbrains.kotlin.incremental.LookupSymbol import org.jetbrains.kotlin.jps.incremental.* import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndex import org.jetbrains.kotlin.jps.targets.KotlinTargetsIndexBuilder +import org.jetbrains.kotlin.jps.targets.KotlinUnsupportedModuleBuildTarget import java.io.File import java.util.concurrent.atomic.AtomicBoolean @@ -249,4 +251,50 @@ class KotlinCompileContext(val jpsContext: CompileContext) { return targetsIndex.chunksByJpsRepresentativeTarget[rawRepresentativeTarget] ?: error("Kotlin binding for chunk $this is not loaded at build start") } + + fun reportUnsupportedTargets() { + // group all KotlinUnsupportedModuleBuildTarget by kind + // only representativeTarget will be added + val byKind = mutableMapOf>() + + targetsIndex.chunks.forEach { + val target = it.representativeTarget + if (target is KotlinUnsupportedModuleBuildTarget) { + if (target.sourceFiles.isNotEmpty()) { + byKind.getOrPut(target.kind) { mutableListOf() }.add(target) + } + } + } + + byKind.forEach { (kind, targets) -> + targets.sortBy { it.module.name } + val chunkNames = targets.map { it.chunk.presentableShortName } + val presentableChunksListString = chunkNames.joinToReadableString() + + val msg = + if (kind == null) { + "$presentableChunksListString is not yet supported in IDEA internal build system. " + + "Please use Gradle to build them (enable 'Delegate IDE build/run actions to Gradle' in Settings)." + } else { + "$kind is not yet supported in IDEA internal build system. " + + "Please use Gradle to build $presentableChunksListString (enable 'Delegate IDE build/run actions to Gradle' in Settings)." + } + + testingLogger?.addCustomMessage(msg) + jpsContext.processMessage( + CompilerMessage( + CompilerRunnerConstants.KOTLIN_COMPILER_NAME, + BuildMessage.Kind.WARNING, + msg + ) + ) + } + } +} + +fun List.joinToReadableString(): String = when { + size > 5 -> take(5).joinToString() + " and ${size - 5} more" + size > 1 -> dropLast(1).joinToString() + " and ${last()}" + size == 1 -> single() + else -> "" } \ No newline at end of file diff --git a/jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/dependencies.txt b/jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/dependencies.txt index e87027d3bd8..38246e16ead 100644 --- a/jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/dependencies.txt +++ b/jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/dependencies.txt @@ -6,5 +6,8 @@ pJvm -> c [include] pJs [compilationAndSourceSetHolder, js] pJs -> c [include] -pNative [compilationAndSourceSetHolder, native] -pNative -> c [include] \ No newline at end of file +pNative1 [compilationAndSourceSetHolder, native] +pNative1 -> c [include] + +pNative2 [compilationAndSourceSetHolder, native] +pNative2 -> c [include] \ No newline at end of file diff --git a/jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin/build.log b/jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin/build.log index 0f9dc130161..eb005c653d4 100644 --- a/jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin/build.log +++ b/jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin/build.log @@ -1,8 +1,11 @@ ================ Step #1 create new service ================= Building c -Building pNative -Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative. +Building pNative2 +Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative1 and pNative2 (enable 'Delegate IDE build/run actions to Gradle' in Settings). +Exit code: NOTHING_DONE +------------------------------------------ +Building pNative1 Exit code: NOTHING_DONE ------------------------------------------ Building pJs @@ -21,8 +24,11 @@ Exit code: OK ================ Step #2 edit new service ================= Building c -Building pNative -Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative. +Building pNative2 +Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative1 and pNative2 (enable 'Delegate IDE build/run actions to Gradle' in Settings). +Exit code: NOTHING_DONE +------------------------------------------ +Building pNative1 Exit code: NOTHING_DONE ------------------------------------------ Building pJs @@ -50,8 +56,11 @@ Exit code: OK ================ Step #3 delete new service ================= Building c -Building pNative -Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative. +Building pNative2 +Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative1 and pNative2 (enable 'Delegate IDE build/run actions to Gradle' in Settings). +Exit code: NOTHING_DONE +------------------------------------------ +Building pNative1 Exit code: NOTHING_DONE ------------------------------------------ Cleaning output files: