Rename -module argument to -Xbuild-file

To prevent confusion with Java 9 module-related arguments

 #KT-18754 Fixed
This commit is contained in:
Alexander Udalov
2017-06-23 20:59:01 +03:00
parent 6200d07808
commit 55468735df
15 changed files with 71 additions and 69 deletions
@@ -22,6 +22,8 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
import org.jetbrains.kotlin.cli.common.arguments.validateArguments
import org.jetbrains.kotlin.cli.common.messages.*
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.INFO
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.STRONG_WARNING
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.cli.jvm.compiler.CompileEnvironmentException
import org.jetbrains.kotlin.config.KotlinCompilerVersion
@@ -106,32 +108,24 @@ abstract class CLITool<A : CommonToolArguments> {
private fun reportArgumentParseProblems(collector: MessageCollector, errors: ArgumentParseErrors) {
for (flag in errors.unknownExtraFlags) {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
"Flag is not supported by this version of the compiler: " + flag, null)
collector.report(STRONG_WARNING, "Flag is not supported by this version of the compiler: $flag")
}
for (argument in errors.extraArgumentsPassedInObsoleteForm) {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
"Advanced option value is passed in an obsolete form. Please use the '=' character " +
"to specify the value: " + argument + "=...", null)
collector.report(STRONG_WARNING, "Advanced option value is passed in an obsolete form. Please use the '=' character " +
"to specify the value: $argument=...")
}
for ((key, value) in errors.duplicateArguments) {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
"Argument $key is passed multiple times. Only the last value will be used: $value", null)
collector.report(STRONG_WARNING, "Argument $key is passed multiple times. Only the last value will be used: $value")
}
for ((deprecatedName, newName) in errors.deprecatedArguments) {
collector.report(STRONG_WARNING, "Argument $deprecatedName is deprecated. Please use $newName instead")
}
}
protected fun <A : CommonToolArguments> printVersionIfNeeded(messageCollector: MessageCollector, arguments: A) {
if (!arguments.version) return
private fun <A : CommonToolArguments> printVersionIfNeeded(messageCollector: MessageCollector, arguments: A) {
if (arguments.version) {
val jreVersion = System.getProperty("java.runtime.version")
messageCollector.report(CompilerMessageSeverity.INFO,
"${executableScriptFileName()} ${KotlinCompilerVersion.VERSION} (JRE $jreVersion)",
null
)
messageCollector.report(INFO, "${executableScriptFileName()} ${KotlinCompilerVersion.VERSION} (JRE $jreVersion)")
}
}
@@ -91,7 +91,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
return INTERNAL_ERROR
}
if (!arguments.script && arguments.module == null) {
if (!arguments.script && arguments.buildFile == null) {
for (arg in arguments.freeArgs) {
val file = File(arg)
if (file.extension == JavaFileType.DEFAULT_EXTENSION) {
@@ -114,7 +114,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
configuration.put(CommonConfigurationKeys.MODULE_NAME, arguments.moduleName ?: JvmAbi.DEFAULT_MODULE_NAME)
if (arguments.module == null && arguments.freeArgs.isEmpty() && !arguments.version) {
if (arguments.buildFile == null && arguments.freeArgs.isEmpty() && !arguments.version) {
if (arguments.script) {
messageCollector.report(ERROR, "Specify script source path to evaluate")
return COMPILATION_ERROR
@@ -150,18 +150,18 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
try {
val destination = arguments.destination
if (arguments.module != null) {
if (arguments.buildFile != null) {
val sanitizedCollector = FilteringMessageCollector(messageCollector, VERBOSE::contains)
val moduleScript = CompileEnvironmentUtil.loadModuleDescriptions(arguments.module, sanitizedCollector)
val moduleScript = CompileEnvironmentUtil.loadModuleDescriptions(arguments.buildFile, sanitizedCollector)
if (destination != null) {
messageCollector.report(
STRONG_WARNING,
"The '-d' option with a directory destination is ignored because '-module' is specified"
"The '-d' option with a directory destination is ignored because '-Xbuild-file' is specified"
)
}
val moduleFile = File(arguments.module)
val moduleFile = File(arguments.buildFile)
val directory = moduleFile.absoluteFile.parentFile
KotlinToJVMBytecodeCompiler.configureSourceRoots(configuration, moduleScript.modules, directory)
@@ -168,12 +168,11 @@ public class CompileEnvironmentUtil {
if (vFile == null) {
String message = "Source file or directory not found: " + sourceRootPath;
File moduleFilePath = configuration.get(JVMConfigurationKeys.MODULE_XML_FILE);
if (moduleFilePath != null && Logger.isInitialized()) {
String moduleFileContent = FileUtil.loadFile(moduleFilePath);
File buildFilePath = configuration.get(JVMConfigurationKeys.MODULE_XML_FILE);
if (buildFilePath != null && Logger.isInitialized()) {
LOG.warn(message +
"\n\nmodule file path: " + moduleFilePath +
"\ncontent:\n" + moduleFileContent);
"\n\nbuild file path: " + buildFilePath +
"\ncontent:\n" + FileUtil.loadFile(buildFilePath));
}
reportError.invoke(message);