From c954fa49004e5c580e886c07a259e3a3d09460d5 Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Mon, 14 Jun 2021 18:07:23 +0200 Subject: [PATCH] Make it possible to attach community version of kotlin-ide --- buildSrc/src/main/kotlin/CommonUtil.kt | 5 ++++- .../src/org/jetbrains/kotlin/generators/imltogradle/Main.kt | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/CommonUtil.kt b/buildSrc/src/main/kotlin/CommonUtil.kt index 84028c32dce..b41958810ac 100644 --- a/buildSrc/src/main/kotlin/CommonUtil.kt +++ b/buildSrc/src/main/kotlin/CommonUtil.kt @@ -86,4 +86,7 @@ val Project.isConfigurationCacheDisabled get() = (gradle.startParameter as? org.gradle.api.internal.StartParameterInternal)?.isConfigurationCache != true val Project.isIdeaActive - get() = providers.systemProperty("idea.active").forUseAtConfigurationTime().isPresent \ No newline at end of file + get() = providers.systemProperty("idea.active").forUseAtConfigurationTime().isPresent + +val Project.intellijCommunityDir: File + get() = rootDir.resolve("kotlin-ide/intellij/community").takeIf { it.isDirectory } ?: rootDir.resolve("kotlin-ide/intellij") \ No newline at end of file diff --git a/generators/ide-iml-to-gradle-generator/src/org/jetbrains/kotlin/generators/imltogradle/Main.kt b/generators/ide-iml-to-gradle-generator/src/org/jetbrains/kotlin/generators/imltogradle/Main.kt index 3813b3cbf7a..dea9952a179 100644 --- a/generators/ide-iml-to-gradle-generator/src/org/jetbrains/kotlin/generators/imltogradle/Main.kt +++ b/generators/ide-iml-to-gradle-generator/src/org/jetbrains/kotlin/generators/imltogradle/Main.kt @@ -102,10 +102,12 @@ fun convertJpsLibrary(lib: JpsLibrary, scope: JpsJavaDependencyScope, exported: return when { mavenRepositoryLibraryDescriptor == null -> { lib.getRootUrls(JpsOrderRootType.COMPILED) - .map { File(it.removePrefix("jar://").removeSuffix("!/")).relativeTo(KOTLIN_REPO_ROOT) } + .map { it.removePrefix("jar://").removeSuffix("!/").removePrefix(KOTLIN_REPO_ROOT.canonicalPath) } .map { + check(it.startsWith("/kotlin-ide/intellij/")) { "Only jars from Community repo are accepted $it" } + val relativeToCommunity = it.removePrefix("/kotlin-ide/intellij/").removePrefix("community/") JpsLikeJarDependency( - "files(rootDir.resolve(\"$it\").canonicalPath)", + "files(intellijCommunityDir.resolve(\"$relativeToCommunity\").canonicalPath)", scope, dependencyConfiguration = null, exported = exported