From 5d31e00d27768a03aba5fec8a7d96b181fed7505 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Mon, 15 May 2017 14:35:07 +0300 Subject: [PATCH] Allopen, Gradle: Fix JPS build on Windows (KT-17830) Appears that plugin classpath can contain not only `File.separatorChar`, but also '/' on Windows. Without the proper handling of this case, Gradle importer may import the plugin JAR made for Gradle with shaded 'com.intellij' and cause an exception during the JPS build. --- .../src/idePluginUtils.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/annotation-based-compiler-plugins-ide-support/src/idePluginUtils.kt b/plugins/annotation-based-compiler-plugins-ide-support/src/idePluginUtils.kt index 142556688c6..8540a85760c 100644 --- a/plugins/annotation-based-compiler-plugins-ide-support/src/idePluginUtils.kt +++ b/plugins/annotation-based-compiler-plugins-ide-support/src/idePluginUtils.kt @@ -41,7 +41,11 @@ internal fun modifyCompilerArgumentsForPlugin( val newPluginOptions = oldPluginOptions + annotationOptions val oldPluginClasspaths = (commonArguments.pluginClasspaths ?: emptyArray()).filterTo(mutableListOf()) { - !it.substringAfterLast(File.separatorChar, missingDelimiterValue = "").matches("(kotlin-)?(maven-)?$pluginName-.*\\.jar".toRegex()) + val lastIndexOfFile = it.lastIndexOfAny(charArrayOf('/', File.separatorChar)) + if (lastIndexOfFile < 0) { + return@filterTo true + } + !it.drop(lastIndexOfFile + 1).matches("(kotlin-)?(maven-)?$pluginName-.*\\.jar".toRegex()) } val newPluginClasspaths = oldPluginClasspaths + (setup?.classpath ?: emptyList())