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)
|
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)
|
var allowKotlinPackage: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
@Argument(value = "-Xreport-output-files", description = "Report source to output files mapping")
|
@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.StandardFileSystems
|
||||||
import com.intellij.openapi.vfs.VfsUtilCore
|
import com.intellij.openapi.vfs.VfsUtilCore
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.openapi.vfs.VirtualFileManager
|
|
||||||
import com.intellij.psi.PsiJavaModule
|
import com.intellij.psi.PsiJavaModule
|
||||||
import com.intellij.psi.PsiManager
|
import com.intellij.psi.PsiManager
|
||||||
import com.intellij.psi.impl.light.LightJavaModule
|
import com.intellij.psi.impl.light.LightJavaModule
|
||||||
@@ -51,7 +50,8 @@ internal class ClasspathRootsResolver(
|
|||||||
private val messageCollector: MessageCollector?,
|
private val messageCollector: MessageCollector?,
|
||||||
private val additionalModules: List<String>,
|
private val additionalModules: List<String>,
|
||||||
private val contentRootToVirtualFile: (JvmContentRoot) -> VirtualFile?,
|
private val contentRootToVirtualFile: (JvmContentRoot) -> VirtualFile?,
|
||||||
private val javaModuleFinder: CliJavaModuleFinder
|
private val javaModuleFinder: CliJavaModuleFinder,
|
||||||
|
private val requireStdlibModule: Boolean
|
||||||
) {
|
) {
|
||||||
val javaModuleGraph = JavaModuleGraph(javaModuleFinder)
|
val javaModuleGraph = JavaModuleGraph(javaModuleFinder)
|
||||||
|
|
||||||
@@ -179,14 +179,15 @@ internal class ClasspathRootsResolver(
|
|||||||
|
|
||||||
if (javaModuleFinder.allObservableModules.none()) return
|
if (javaModuleFinder.allObservableModules.none()) return
|
||||||
|
|
||||||
|
val sourceModule = sourceModules.singleOrNull()
|
||||||
val addAllModulePathToRoots = "ALL-MODULE-PATH" in additionalModules
|
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")
|
report(ERROR, "-Xadd-modules=ALL-MODULE-PATH can only be used when compiling the unnamed module")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val rootModules = when {
|
val rootModules = when {
|
||||||
sourceModules.isNotEmpty() -> listOf(sourceModules.single().name) + additionalModules
|
sourceModule != null -> listOf(sourceModule.name) + additionalModules
|
||||||
addAllModulePathToRoots -> modules.map(JavaModule::name)
|
addAllModulePathToRoots -> modules.map(JavaModule::name)
|
||||||
else -> computeDefaultRootModules() + additionalModules
|
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
|
// See http://openjdk.java.net/jeps/261
|
||||||
|
|||||||
@@ -205,7 +205,8 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
messageCollector,
|
messageCollector,
|
||||||
configuration.getList(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES),
|
configuration.getList(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES),
|
||||||
this::contentRootToVirtualFile,
|
this::contentRootToVirtualFile,
|
||||||
javaModuleFinder
|
javaModuleFinder,
|
||||||
|
!configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE)
|
||||||
)
|
)
|
||||||
|
|
||||||
val (initialRoots, javaModules) =
|
val (initialRoots, javaModules) =
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ where advanced options include:
|
|||||||
-Xfriend-modules=<path> Paths to friend modules
|
-Xfriend-modules=<path> Paths to friend modules
|
||||||
-Xfriend-modules-disabled Disable internal declaration export
|
-Xfriend-modules-disabled Disable internal declaration export
|
||||||
-Xtyped-arrays Translate primitive arrays to JS typed arrays
|
-Xtyped-arrays Translate primitive arrays to JS typed arrays
|
||||||
-Xallow-kotlin-package Allow compiling code in package 'kotlin'
|
-Xallow-kotlin-package Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info
|
||||||
-Xcoroutines={enable|warn|error}
|
-Xcoroutines={enable|warn|error}
|
||||||
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
||||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ where advanced options include:
|
|||||||
-Xskip-runtime-version-check Allow Kotlin runtime libraries of incompatible versions in the classpath
|
-Xskip-runtime-version-check Allow Kotlin runtime libraries of incompatible versions in the classpath
|
||||||
-Xuse-javac Use javac for Java source and class files analysis
|
-Xuse-javac Use javac for Java source and class files analysis
|
||||||
-Xuse-old-class-files-reading Use old class files reading implementation (may slow down the build and should be used in case of problems with the new implementation)
|
-Xuse-old-class-files-reading Use old class files reading implementation (may slow down the build and should be used in case of problems with the new implementation)
|
||||||
-Xallow-kotlin-package Allow compiling code in package 'kotlin'
|
-Xallow-kotlin-package Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info
|
||||||
-Xcoroutines={enable|warn|error}
|
-Xcoroutines={enable|warn|error}
|
||||||
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
||||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||||
|
|||||||
Reference in New Issue
Block a user