diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.kt
index 4b0ecdf636f..6c6c71fffe8 100644
--- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.kt
+++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.kt
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.cli.common.ExitCode.*
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback
import org.jetbrains.kotlin.cli.common.messages.*
+import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.INFO
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
@@ -161,8 +162,15 @@ abstract class CLICompiler : CLITool() {
protected abstract fun MutableList.addPlatformOptions(arguments: A)
protected fun loadPlugins(paths: KotlinPaths?, arguments: A, configuration: CompilerConfiguration): ExitCode {
- var pluginClasspaths: Iterable = arguments.pluginClasspaths?.asIterable() ?: emptyList()
- val pluginOptions = arguments.pluginOptions?.toMutableList() ?: ArrayList()
+ val pluginClasspaths = arguments.pluginClasspaths.orEmpty().toMutableList()
+ val pluginOptions = arguments.pluginOptions.orEmpty().toMutableList()
+ val messageCollector = configuration.getNotNull(MESSAGE_COLLECTOR_KEY)
+
+ for (classpath in pluginClasspaths) {
+ if (!File(classpath).exists()) {
+ messageCollector.report(ERROR, "Plugin classpath entry points to a non-existent location: $classpath")
+ }
+ }
if (!arguments.disableDefaultScriptingPlugin) {
val explicitOrLoadedScriptingPlugin =
@@ -174,9 +182,8 @@ abstract class CLICompiler : CLITool() {
val (jars, missingJars) =
PathUtil.KOTLIN_SCRIPTING_PLUGIN_CLASSPATH_JARS.map { File(libPath, it) }.partition { it.exists() }
if (missingJars.isEmpty()) {
- pluginClasspaths = jars.map { it.canonicalPath } + pluginClasspaths
+ pluginClasspaths.addAll(0, jars.map { it.canonicalPath })
} else {
- val messageCollector = configuration.getNotNull(MESSAGE_COLLECTOR_KEY)
messageCollector.report(
CompilerMessageSeverity.LOGGING,
"Scripting plugin will not be loaded: not all required jars are present in the classpath (missing files: $missingJars)"
diff --git a/compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.args b/compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.args
index 00d6472ea5c..3c469755853 100644
--- a/compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.args
+++ b/compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.args
@@ -1,5 +1,5 @@
--Xplugin
-non-existing-file.jar
+-Xjsr305
+strict
$TESTDATA_DIR$/simple.kt
-d
$TEMP_DIR$
diff --git a/compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.out b/compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.out
index 1f22a77f1c1..5c26bef242e 100644
--- a/compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.out
+++ b/compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.out
@@ -1,2 +1,2 @@
-warning: advanced option value is passed in an obsolete form. Please use the '=' character to specify the value: -Xplugin=...
+warning: advanced option value is passed in an obsolete form. Please use the '=' character to specify the value: -Xjsr305=...
OK
diff --git a/compiler/testData/cli/jvm/nonExistingPluginClassPath.args b/compiler/testData/cli/jvm/nonExistingPluginClassPath.args
new file mode 100644
index 00000000000..ae4b9838572
--- /dev/null
+++ b/compiler/testData/cli/jvm/nonExistingPluginClassPath.args
@@ -0,0 +1,4 @@
+$TESTDATA_DIR$/simple.kt
+-d
+$TEMP_DIR$
+-Xplugin=/non-existing-path
diff --git a/compiler/testData/cli/jvm/nonExistingPluginClassPath.out b/compiler/testData/cli/jvm/nonExistingPluginClassPath.out
new file mode 100644
index 00000000000..bd2715496c5
--- /dev/null
+++ b/compiler/testData/cli/jvm/nonExistingPluginClassPath.out
@@ -0,0 +1,2 @@
+error: plugin classpath entry points to a non-existent location: /non-existing-path
+COMPILATION_ERROR
diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java
index 46c09948989..5cb83aa19f7 100644
--- a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java
+++ b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java
@@ -784,6 +784,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/nonExistingPhaseName.args");
}
+ @TestMetadata("nonExistingPluginClassPath.args")
+ public void testNonExistingPluginClassPath() throws Exception {
+ runTest("compiler/testData/cli/jvm/nonExistingPluginClassPath.args");
+ }
+
@TestMetadata("nonExistingSourcePath.args")
public void testNonExistingSourcePath() throws Exception {
runTest("compiler/testData/cli/jvm/nonExistingSourcePath.args");