Minor: report error instead of crash with exceptions when collect JetFiles to compile and remove obsolete (wrong now) code
#EA-61681 Obsolete
This commit is contained in:
@@ -171,19 +171,22 @@ public open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
val compilerConfiguration = KotlinToJVMBytecodeCompiler.createCompilerConfiguration(configuration, moduleScript.getModules(), directory)
|
val compilerConfiguration = KotlinToJVMBytecodeCompiler.createCompilerConfiguration(configuration, moduleScript.getModules(), directory)
|
||||||
environment = createCoreEnvironment(rootDisposable, compilerConfiguration)
|
environment = createCoreEnvironment(rootDisposable, compilerConfiguration)
|
||||||
|
|
||||||
|
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) return COMPILATION_ERROR
|
||||||
|
|
||||||
KotlinToJVMBytecodeCompiler.compileModules(environment, configuration, moduleScript.getModules(), directory, jar, arguments.includeRuntime)
|
KotlinToJVMBytecodeCompiler.compileModules(environment, configuration, moduleScript.getModules(), directory, jar, arguments.includeRuntime)
|
||||||
}
|
}
|
||||||
else if (arguments.script) {
|
else if (arguments.script) {
|
||||||
val scriptArgs = arguments.freeArgs.subList(1, arguments.freeArgs.size())
|
val scriptArgs = arguments.freeArgs.subList(1, arguments.freeArgs.size())
|
||||||
environment = createCoreEnvironment(rootDisposable, configuration)
|
environment = createCoreEnvironment(rootDisposable, configuration)
|
||||||
|
|
||||||
|
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) return COMPILATION_ERROR
|
||||||
|
|
||||||
KotlinToJVMBytecodeCompiler.compileAndExecuteScript(configuration, paths, environment, scriptArgs)
|
KotlinToJVMBytecodeCompiler.compileAndExecuteScript(configuration, paths, environment, scriptArgs)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
environment = createCoreEnvironment(rootDisposable, configuration)
|
environment = createCoreEnvironment(rootDisposable, configuration)
|
||||||
|
|
||||||
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) {
|
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) return COMPILATION_ERROR
|
||||||
return COMPILATION_ERROR
|
|
||||||
}
|
|
||||||
|
|
||||||
if (environment.getSourceFiles().isEmpty()) {
|
if (environment.getSourceFiles().isEmpty()) {
|
||||||
messageSeverityCollector.report(CompilerMessageSeverity.ERROR, "No source files", CompilerMessageLocation.NO_LOCATION)
|
messageSeverityCollector.report(CompilerMessageSeverity.ERROR, "No source files", CompilerMessageLocation.NO_LOCATION)
|
||||||
|
|||||||
-5
@@ -85,11 +85,6 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
if (!source.isAbsolute()) {
|
if (!source.isAbsolute()) {
|
||||||
source = new File(directory, sourceFile);
|
source = new File(directory, sourceFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!source.exists()) {
|
|
||||||
throw new CompileEnvironmentException("'" + source + "' does not exist in module " + module.getModuleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
result.add(source.getAbsolutePath());
|
result.add(source.getAbsolutePath());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-module
|
||||||
|
$TESTDATA_DIR$/nonexistentPathInModule.xml
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
error: source file or directory not found: $TESTDATA_DIR$/nonexistentFile.kt
|
||||||
|
error: source file or directory not found: $TESTDATA_DIR$/some/nonexistent/dir
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<modules>
|
||||||
|
<module name="name" outputDir="whatever" type="java-production">
|
||||||
|
<sources path="nonexistentFile.kt"/>
|
||||||
|
<sources path="some/nonexistent/dir/"/>
|
||||||
|
</module>
|
||||||
|
</modules>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-script
|
||||||
|
path/to/nonexistent.kts
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
error: source file or directory not found: path/to/nonexistent.kts
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -53,6 +53,16 @@ public class CliCommonTest extends CliBaseTest {
|
|||||||
executeCompilerCompareOutputJVM();
|
executeCompilerCompareOutputJVM();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nonexistentPathInModule() throws Exception {
|
||||||
|
executeCompilerCompareOutputJVM();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nonexistentScript() throws Exception {
|
||||||
|
executeCompilerCompareOutputJVM();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void diagnosticsOrder() throws Exception {
|
public void diagnosticsOrder() throws Exception {
|
||||||
executeCompilerCompareOutputJVM();
|
executeCompilerCompareOutputJVM();
|
||||||
|
|||||||
@@ -169,6 +169,18 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nonexistentPathInModule.args")
|
||||||
|
public void testNonexistentPathInModule() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/nonexistentPathInModule.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nonexistentScript.args")
|
||||||
|
public void testNonexistentScript() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/nonexistentScript.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("pluginSimple.args")
|
@TestMetadata("pluginSimple.args")
|
||||||
public void testPluginSimple() throws Exception {
|
public void testPluginSimple() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/pluginSimple.args");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/pluginSimple.args");
|
||||||
|
|||||||
Reference in New Issue
Block a user