From 16e6fe0e083f2c40a8c887dd3a7558466d8500bb Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Tue, 8 Jun 2021 15:52:08 +0200 Subject: [PATCH] Fix compilation for some Kotlin plugin modules when IJ infra is attached to kotlin repo For example it fixes compilation of `:kotlin-ide.kotlin.generators:testClasses` This commit fixes that Gradle tries to find jars of 202 IDEA in ivy repo of 211 IDEA: ``` * What went wrong: Execution failed for task ':kotlin-ide.kotlin.tests-common:compileTestKotlin'. > Could not resolve all files for configuration ':kotlin-ide.kotlin.tests-common:testCompileClasspath'. > Could not find extensions-211.6693.111.jar (kotlin.build:ideaIC:211.6693.111). Searched in the following locations: file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/lib/extensions.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/extensions.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/intellij-core/211.6693.111/artifacts/extensions.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/plugins/ideaIC/lib/extensions.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/sources/extensions-211.6693.111.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/extensions.jar > Could not find guava-29.0-jre-211.6693.111.jar (kotlin.build:ideaIC:211.6693.111). Searched in the following locations: file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/lib/guava-29.0-jre.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/guava-29.0-jre.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/intellij-core/211.6693.111/artifacts/guava-29.0-jre.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/plugins/ideaIC/lib/guava-29.0-jre.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/sources/guava-29.0-jre-211.6693.111.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/guava-29.0-jre.jar > Could not find asm-all-8.0.1-211.6693.111.jar (kotlin.build:ideaIC:211.6693.111). Searched in the following locations: file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/lib/asm-all-8.0.1.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/asm-all-8.0.1.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/intellij-core/211.6693.111/artifacts/asm-all-8.0.1.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/plugins/ideaIC/lib/asm-all-8.0.1.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/sources/asm-all-8.0.1-211.6693.111.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/asm-all-8.0.1.jar > Could not find streamex-0.7.2-211.6693.111.jar (kotlin.build:ideaIC:211.6693.111). Searched in the following locations: file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/lib/streamex-0.7.2.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/streamex-0.7.2.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/intellij-core/211.6693.111/artifacts/streamex-0.7.2.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/artifacts/plugins/ideaIC/lib/streamex-0.7.2.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/sources/streamex-0.7.2-211.6693.111.jar file:/home/bobko/.gradle/kotlin-build-dependencies/repo/kotlin.build/ideaIC/211.6693.111/streamex-0.7.2.jar ``` --- buildSrc/src/main/kotlin/artifacts.kt | 10 ++++++++++ buildSrc/src/main/kotlin/localDependencies.kt | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/artifacts.kt b/buildSrc/src/main/kotlin/artifacts.kt index fb5645b203f..bc5116b0fbc 100644 --- a/buildSrc/src/main/kotlin/artifacts.kt +++ b/buildSrc/src/main/kotlin/artifacts.kt @@ -240,6 +240,11 @@ fun Project.publishJarsForIde(projects: List, libraryDependencies: List< idePluginDependency { publishProjectJars(projects, libraryDependencies) } + configurations.all { + // Don't allow `ideaIC` from compiler to leak into Kotlin plugin modules. Compiler and + // plugin may depend on different versions of IDEA and it will lead to version conflict + exclude(module = ideModuleName()) + } dependencies { projects.forEach { jpsLikeJarDependency(project(it), JpsDepScope.COMPILE, { isTransitive = false }, exported = true) @@ -254,6 +259,11 @@ fun Project.publishTestJarsForIde(projectNames: List) { idePluginDependency { publishTestJar(projectNames) } + configurations.all { + // Don't allow `ideaIC` from compiler to leak into Kotlin plugin modules. Compiler and + // plugin may depend on different versions of IDEA and it will lead to version conflict + exclude(module = ideModuleName()) + } dependencies { for (projectName in projectNames) { jpsLikeJarDependency(projectTests(projectName), JpsDepScope.COMPILE, exported = true) diff --git a/buildSrc/src/main/kotlin/localDependencies.kt b/buildSrc/src/main/kotlin/localDependencies.kt index e5d97c5939c..0cbe5f6b531 100644 --- a/buildSrc/src/main/kotlin/localDependencies.kt +++ b/buildSrc/src/main/kotlin/localDependencies.kt @@ -35,7 +35,7 @@ private fun Project.kotlinBuildLocalDependenciesDir(): File = private fun Project.kotlinBuildLocalRepoDir(): File = kotlinBuildLocalDependenciesDir().resolve("repo") -private fun Project.ideModuleName() = when (IdeVersionConfigurator.currentIde.kind) { +fun Project.ideModuleName() = when (IdeVersionConfigurator.currentIde.kind) { Ide.Kind.AndroidStudio -> "android-studio-ide" Ide.Kind.IntelliJ -> { if (kotlinBuildProperties.intellijUltimateEnabled) "ideaIU" else "ideaIC"