[Compiler CLI] Use reading language version settings from environment only if the resource is presented or flag is set
This commit is contained in:
committed by
teamcity
parent
683a3e74a0
commit
5c8ca0ca9b
@@ -26,7 +26,9 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.INFO
|
|||||||
import org.jetbrains.kotlin.cli.jvm.compiler.CompileEnvironmentException
|
import org.jetbrains.kotlin.cli.jvm.compiler.CompileEnvironmentException
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.setupIdeaStandaloneExecution
|
import org.jetbrains.kotlin.cli.jvm.compiler.setupIdeaStandaloneExecution
|
||||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.net.URLConnection
|
import java.net.URLConnection
|
||||||
@@ -48,7 +50,11 @@ abstract class CLITool<A : CommonToolArguments> {
|
|||||||
): ExitCode {
|
): ExitCode {
|
||||||
val arguments = createArguments()
|
val arguments = createArguments()
|
||||||
parseCommandLineArguments(args.asList(), arguments)
|
parseCommandLineArguments(args.asList(), arguments)
|
||||||
parseCommandLineArgumentsFromEnvironment(arguments)
|
|
||||||
|
if (isReadingSettingsFromEnvironmentAllowed) {
|
||||||
|
parseCommandLineArgumentsFromEnvironment(arguments)
|
||||||
|
}
|
||||||
|
|
||||||
val collector = PrintingMessageCollector(errStream, messageRenderer, arguments.verbose)
|
val collector = PrintingMessageCollector(errStream, messageRenderer, arguments.verbose)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -128,6 +134,9 @@ abstract class CLITool<A : CommonToolArguments> {
|
|||||||
|
|
||||||
abstract fun executableScriptFileName(): String
|
abstract fun executableScriptFileName(): String
|
||||||
|
|
||||||
|
var isReadingSettingsFromEnvironmentAllowed: Boolean =
|
||||||
|
this::class.java.classLoader.getResource(LanguageVersionSettings.RESOURCE_NAME_TO_ALLOW_READING_FROM_ENVIRONMENT) != null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private fun defaultMessageRenderer(): MessageRenderer =
|
private fun defaultMessageRenderer(): MessageRenderer =
|
||||||
when (System.getProperty(MessageRenderer.PROPERTY_KEY)) {
|
when (System.getProperty(MessageRenderer.PROPERTY_KEY)) {
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ import org.jetbrains.kotlin.name.isSubpackageOf
|
|||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.util.Logger
|
import org.jetbrains.kotlin.util.Logger
|
||||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipFile
|
||||||
|
import java.util.zip.ZipOutputStream
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
fun incrementalCompilationIsEnabled(arguments: CommonCompilerArguments): Boolean {
|
fun incrementalCompilationIsEnabled(arguments: CommonCompilerArguments): Boolean {
|
||||||
@@ -97,4 +101,5 @@ fun MessageCollector.toLogger(): Logger =
|
|||||||
override fun log(message: String) {
|
override fun log(message: String) {
|
||||||
report(CompilerMessageSeverity.LOGGING, message)
|
report(CompilerMessageSeverity.LOGGING, message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
|
|||||||
import org.jetbrains.kotlin.asJava.classes.FacadeCache
|
import org.jetbrains.kotlin.asJava.classes.FacadeCache
|
||||||
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
|
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
|
||||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
import org.jetbrains.kotlin.cli.common.*
|
||||||
import org.jetbrains.kotlin.cli.common.CliModuleVisibilityManagerImpl
|
|
||||||
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
|
|
||||||
import org.jetbrains.kotlin.cli.common.config.ContentRoot
|
import org.jetbrains.kotlin.cli.common.config.ContentRoot
|
||||||
import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
|
import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
|
||||||
import org.jetbrains.kotlin.cli.common.config.kotlinSourceRoots
|
import org.jetbrains.kotlin.cli.common.config.kotlinSourceRoots
|
||||||
@@ -66,7 +64,6 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
|||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.STRONG_WARNING
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.STRONG_WARNING
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.cli.common.toBooleanLenient
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.jarfs.FastJarFileSystem
|
import org.jetbrains.kotlin.cli.jvm.compiler.jarfs.FastJarFileSystem
|
||||||
import org.jetbrains.kotlin.cli.jvm.config.*
|
import org.jetbrains.kotlin.cli.jvm.config.*
|
||||||
import org.jetbrains.kotlin.cli.jvm.index.*
|
import org.jetbrains.kotlin.cli.jvm.index.*
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
File environmentTestConfig = new File(fileName.replaceFirst("\\.args$", ".env"));
|
File environmentTestConfig = new File(fileName.replaceFirst("\\.args$", ".env"));
|
||||||
if (environmentTestConfig.exists()) {
|
if (environmentTestConfig.exists()) {
|
||||||
|
compiler.setReadingSettingsFromEnvironmentAllowed(true);
|
||||||
CompilerSystemProperties.LANGUAGE_VERSION_SETTINGS.setValue(FilesKt.readText(environmentTestConfig, Charsets.UTF_8));
|
CompilerSystemProperties.LANGUAGE_VERSION_SETTINGS.setValue(FilesKt.readText(environmentTestConfig, Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -464,6 +464,10 @@ interface LanguageVersionSettings {
|
|||||||
|
|
||||||
// Please do not use this to enable/disable specific features/checks. Instead add a new LanguageFeature entry and call supportsFeature
|
// Please do not use this to enable/disable specific features/checks. Instead add a new LanguageFeature entry and call supportsFeature
|
||||||
val languageVersion: LanguageVersion
|
val languageVersion: LanguageVersion
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val RESOURCE_NAME_TO_ALLOW_READING_FROM_ENVIRONMENT = "META-INF/allow-configuring-from-environment"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LanguageVersionSettingsImpl @JvmOverloads constructor(
|
class LanguageVersionSettingsImpl @JvmOverloads constructor(
|
||||||
|
|||||||
Reference in New Issue
Block a user