Minor: log the content of module.xml when a source root not found on FS
Related issues: #KT-9587 #KT-10394
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -164,6 +164,8 @@ open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
val directory = File(arguments.module).absoluteFile.parentFile
|
||||
|
||||
val compilerConfiguration = KotlinToJVMBytecodeCompiler.createCompilerConfiguration(configuration, moduleScript.modules, directory)
|
||||
compilerConfiguration.put(JVMConfigurationKeys.MODULE_XML_FILE_PATH, arguments.module)
|
||||
|
||||
environment = createCoreEnvironment(rootDisposable, compilerConfiguration)
|
||||
|
||||
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) return COMPILATION_ERROR
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
@@ -37,7 +38,9 @@ import org.jetbrains.kotlin.backend.common.output.OutputFile;
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.kotlin.cli.common.modules.ModuleScriptData;
|
||||
import org.jetbrains.kotlin.cli.common.modules.ModuleXmlParser;
|
||||
import org.jetbrains.kotlin.cli.jvm.config.JVMConfigurationKeys;
|
||||
import org.jetbrains.kotlin.codegen.ClassFileFactory;
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
@@ -54,6 +57,7 @@ import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation.N
|
||||
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR;
|
||||
|
||||
public class CompileEnvironmentUtil {
|
||||
private static Logger LOG = Logger.getInstance(CompileEnvironmentUtil.class);
|
||||
|
||||
@NotNull
|
||||
public static ModuleScriptData loadModuleDescriptions(String moduleDefinitionFile, MessageCollector messageCollector) {
|
||||
@@ -141,8 +145,9 @@ public class CompileEnvironmentUtil {
|
||||
public static List<KtFile> getKtFiles(
|
||||
@NotNull final Project project,
|
||||
@NotNull Collection<String> sourceRoots,
|
||||
@NotNull CompilerConfiguration configuration,
|
||||
@NotNull Function1<String, Unit> reportError
|
||||
) {
|
||||
) throws IOException {
|
||||
final VirtualFileSystem localFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL);
|
||||
|
||||
final Set<VirtualFile> processedFiles = Sets.newHashSet();
|
||||
@@ -155,7 +160,17 @@ public class CompileEnvironmentUtil {
|
||||
|
||||
VirtualFile vFile = localFileSystem.findFileByPath(sourceRootPath);
|
||||
if (vFile == null) {
|
||||
reportError.invoke("Source file or directory not found: " + sourceRootPath);
|
||||
String message = "Source file or directory not found: " + sourceRootPath;
|
||||
|
||||
String moduleFilePath = configuration.get(JVMConfigurationKeys.MODULE_XML_FILE_PATH);
|
||||
if (moduleFilePath != null) {
|
||||
String moduleFileContent = FileUtil.loadFile(new File(moduleFilePath));
|
||||
LOG.warn(message +
|
||||
"\n\nmodule file path: " + moduleFilePath +
|
||||
"\ncontent:\n" + moduleFileContent);
|
||||
}
|
||||
|
||||
reportError.invoke(message);
|
||||
continue;
|
||||
}
|
||||
if (!vFile.isDirectory() && vFile.getFileType() != KotlinFileType.INSTANCE) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -131,7 +131,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
val index = JvmDependenciesIndex(javaRoots)
|
||||
(fileManager as KotlinCliJavaFileManagerImpl).initIndex(index)
|
||||
|
||||
sourceFiles.addAll(CompileEnvironmentUtil.getKtFiles(project, getSourceRootsCheckingForDuplicates(), {
|
||||
sourceFiles.addAll(CompileEnvironmentUtil.getKtFiles(project, getSourceRootsCheckingForDuplicates(), this.configuration, {
|
||||
message ->
|
||||
report(ERROR, message)
|
||||
}))
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -115,7 +115,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
for (module in chunk) {
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
val ktFiles = CompileEnvironmentUtil.getKtFiles(
|
||||
environment.project, getAbsolutePaths(directory, module)) { s -> throw IllegalStateException("Should have been checked before: " + s) }
|
||||
environment.project, getAbsolutePaths(directory, module), configuration) { s -> throw IllegalStateException("Should have been checked before: " + s) }
|
||||
if (!checkKotlinPackageUsage(environment, ktFiles)) return false
|
||||
val moduleOutputDirectory = File(module.getOutputDirectory())
|
||||
val generationState = generate(environment, result, ktFiles, module, moduleOutputDirectory,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,6 +44,8 @@ public class JVMConfigurationKeys {
|
||||
public static final CompilerConfigurationKey<CompilerJarLocator> COMPILER_JAR_LOCATOR =
|
||||
CompilerConfigurationKey.create("Compiler jar locator");
|
||||
|
||||
public static final CompilerConfigurationKey<String> MODULE_XML_FILE_PATH = CompilerConfigurationKey.create("path to module.xml");
|
||||
|
||||
public static final CompilerConfigurationKey<List<Module>> MODULES =
|
||||
CompilerConfigurationKey.create("module data");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user