Report error if Java 9 module "kotlin.stdlib" is not found in the graph
Use "-Xallow-kotlin-package" to suppress this error #KT-19176 Fixed
This commit is contained in:
+1
-1
@@ -76,7 +76,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
var skipMetadataVersionCheck: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(value = "-Xallow-kotlin-package", description = "Allow compiling code in package 'kotlin'")
|
||||
@Argument(value = "-Xallow-kotlin-package", description = "Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info")
|
||||
var allowKotlinPackage: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(value = "-Xreport-output-files", description = "Report source to output files mapping")
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
import com.intellij.openapi.vfs.StandardFileSystems
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.impl.light.LightJavaModule
|
||||
@@ -51,7 +50,8 @@ internal class ClasspathRootsResolver(
|
||||
private val messageCollector: MessageCollector?,
|
||||
private val additionalModules: List<String>,
|
||||
private val contentRootToVirtualFile: (JvmContentRoot) -> VirtualFile?,
|
||||
private val javaModuleFinder: CliJavaModuleFinder
|
||||
private val javaModuleFinder: CliJavaModuleFinder,
|
||||
private val requireStdlibModule: Boolean
|
||||
) {
|
||||
val javaModuleGraph = JavaModuleGraph(javaModuleFinder)
|
||||
|
||||
@@ -179,14 +179,15 @@ internal class ClasspathRootsResolver(
|
||||
|
||||
if (javaModuleFinder.allObservableModules.none()) return
|
||||
|
||||
val sourceModule = sourceModules.singleOrNull()
|
||||
val addAllModulePathToRoots = "ALL-MODULE-PATH" in additionalModules
|
||||
if (addAllModulePathToRoots && sourceModules.isNotEmpty()) {
|
||||
if (addAllModulePathToRoots && sourceModule != null) {
|
||||
report(ERROR, "-Xadd-modules=ALL-MODULE-PATH can only be used when compiling the unnamed module")
|
||||
return
|
||||
}
|
||||
|
||||
val rootModules = when {
|
||||
sourceModules.isNotEmpty() -> listOf(sourceModules.single().name) + additionalModules
|
||||
sourceModule != null -> listOf(sourceModule.name) + additionalModules
|
||||
addAllModulePathToRoots -> modules.map(JavaModule::name)
|
||||
else -> computeDefaultRootModules() + additionalModules
|
||||
}
|
||||
@@ -217,6 +218,15 @@ internal class ClasspathRootsResolver(
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
if (requireStdlibModule && sourceModule != null && "kotlin.stdlib" !in allDependencies) {
|
||||
report(
|
||||
ERROR,
|
||||
"The Kotlin standard library is not found in the module graph. " +
|
||||
"Please ensure you have the 'requires kotlin.stdlib' clause in your module definition",
|
||||
sourceModule.moduleInfoFile
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// See http://openjdk.java.net/jeps/261
|
||||
|
||||
@@ -205,7 +205,8 @@ class KotlinCoreEnvironment private constructor(
|
||||
messageCollector,
|
||||
configuration.getList(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES),
|
||||
this::contentRootToVirtualFile,
|
||||
javaModuleFinder
|
||||
javaModuleFinder,
|
||||
!configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE)
|
||||
)
|
||||
|
||||
val (initialRoots, javaModules) =
|
||||
|
||||
Reference in New Issue
Block a user